Coder Social home page Coder Social logo

Comments (6)

rgc99 avatar rgc99 commented on August 15, 2024

You are right, split the automation into two separate tasks; adjustment and bucket reset. I think history_stats may be your friend here. First create a sensor to count the number of times the system was on yesterday and then an automation to reset the bucket if the system was on:

sensor:
  - platform: history_stats
    name: Irrigation Unlimited yesterday run count
    entity_id: binary_sensor.irrigation_unlimited_c1_m
    state: β€œon” 
    type: count 
    end: "{{ now().replace(hour=0, minute=0, second=0) }}" 
    duration: 
      hours: 24 
 
automation: 
  - alias: HA Smart Irrigation reset bucket 
    trigger: 
    - platform: time
      at: 04:30
    condition:
      condition: numeric_state
      entity_id: sensor.irrigation_unlimited_yesterday_run_count
      above: 0
    action:
    - service: smart_irrigation.smart_irrigation_reset_bucket
    mode: single

Lots of possibilities here but hopefully this will get you going. Let me know how you get on so we share it.

from irrigation_unlimited.

Stan-Gobien avatar Stan-Gobien commented on August 15, 2024

Hey, thanks for your answer.
So the idea is that we count the number of times irrigation unlimited has run in the past 24 hours (yesterday might be a misleading name). If the count is higher than 0, meaning it has run then we reset the bucket.
Good idea.

The question is, when should we call the reset bucket automation?
Ideally it should be called right after the run has finished, but because of variable schedules that's a bit difficult.
The "sensor.smart_irrigation_daily_adjusted_run_time" gets calculated at 23h.
I'm pretty sure that the result of that calculation is very different depending on the value of the bucket.
So would it be best to run the automation at for instance 22h?

from irrigation_unlimited.

Stan-Gobien avatar Stan-Gobien commented on August 15, 2024

Considering if the run was perhaps at sunrise we still loose most of the day of raining or vaporization if we reset only at 22h in the evening.

So still not ideal. In my situation I can schedule the reset perhaps at 9h in the morning, because I will always schedule the automatic runs a bit before sunrise.

The best solution would be some kind of sensor "run finished" that changes from off to on on finish and could thus trigger the reset automation.

Could we not trigger the reset automation on the state attribute "Status" of "binary_sensor.irrigation_unlimited_c1_m" changing from 'on' to 'off'?

from irrigation_unlimited.

Stan-Gobien avatar Stan-Gobien commented on August 15, 2024

Just thinking a bit out loud here:

Could we not trigger the reset automation on the state attribute "Status" of "binary_sensor.irrigation_unlimited_c1_m" changing from 'on' to 'off'?

from irrigation_unlimited.

rgc99 avatar rgc99 commented on August 15, 2024

Rereading the docs; calculations are done at 23:00 and the bucket should be reset after any irrigation so yes let's do that. Here is the complete automation.

automation:
  - alias: Smart Irrigation adjustment
    description: Adjust watering times based on smart irrigation calculations
    trigger:
      - platform: time
        at: "23:30"
    action:
      - service: irrigation_unlimited.adjust_time
        data:
          entity_id: binary_sensor.irrigation_unlimited_c1_z1
          actual: >
            {% set t = states('sensor.smart_irrigation_daily_adjusted_run_time') | int %}
            {{ '{:02d}:{:02d}:{:02d}'.format((t // 3600) % 24, (t % 3600) // 60, (t % 3600) % 60) }}
    mode: single

  - alias: Smart Irrigation reset bucket
    description: Resets the Smart Irrigation bucket after watering
    trigger:
      - platform: state
        entity_id:
          # Add Irrigation Unlimited sensors here
          - binary_sensor.irrigation_unlimited_c1_m
        from: "on"
        to: "off"
    action:
      - service: smart_irrigation.reset_bucket

from irrigation_unlimited.

Stan-Gobien avatar Stan-Gobien commented on August 15, 2024

I've implemented the new automations as suggested.

from irrigation_unlimited.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.