Smart Irrigation - save water by precisely watering your lawn/garden

interesting … I noticed just now:

image

same “unavailable” state for hourly and daily sensors …

without touching anything few minutes later back again to normal:

image

errors captured in HA log:

2020-05-26 22:00:54 ERROR (MainThread) [custom_components.smart_irrigation.OWMClient] Failed to get OWM URL {"cod":"500","message":"Internal error: 500001"}
2020-05-26 22:00:54 ERROR (MainThread) [custom_components.smart_irrigation.OWMClient] Cannot talk to OWM API, check API key.
2020-05-26 22:00:54 ERROR (MainThread) [custom_components.smart_irrigation] Error fetching smart_irrigation data: 
2020-05-26 23:11:47 ERROR (MainThread) [custom_components.smart_irrigation.OWMClient] Failed to get OWM URL <html>
<head><title>504 Gateway Time-out</title></head>
<body>
<center><h1>504 Gateway Time-out</h1></center>
<hr><center>openresty</center>
</body>
</html>

2020-05-26 23:11:47 ERROR (MainThread) [custom_components.smart_irrigation] Error fetching smart_irrigation data: 'JSONDecodeError' object has no attribute 'strerror'

interesting :slight_smile:

@posixx happy to let you know you can now add this component multiple times.

Thanks for all your suggestions!

I have created these issues so I can track them:

can you elaborate a little bit more on this? not sure I understand.

also, the value for bucket should stay between HA reboots, is it not the case for you?

1 Like

happy to hear it!

openresty? I think Open Weather Map must have had an outage for a couple of seconds, because that is a return message from them…

ok, I went ahead and implemented the following:
-runtime in minutes
-maximum duration
-extra services.

force mode is still pending, need a bit more work for this.

2 Likes

thx for adding my “minutes” in attributes, pls add the same to the base index sensor :slight_smile: i will be able to get rid of few template sensors :frowning:

Re % adjustment … I think first of all you would have to add support for zones :slight_smile: but anyway this is what I currently implemented in my system -> as 2 layers of adjustments:

  1. generic adjustment … if I decide that "daily"run time is too short or too long I can adjust it by multiplying sensor result by some % defined. e.g. 10 min * 50% = 5 min applied for my irrigation

  2. second level is adjustment per zone. idea the same … if one zone is bigger than other one or have a different water flow I can adjust it by some %. e.g. 5 min * 100% for zone1 = 5 min but 5 min * 150% for zone2 = 7,5 min.

Of course at all adjustment levels I take into account general adjustment and general maximum irrigation time… full example :slight_smile:

  • daily run time = 10 min
  • general adj. = 50%
  • zone1 adj = 100%
  • zone2 adj. = 150%
  • max irrigation time = 6 min

calcs looks like that (done in sensor template):
zone1 duration = 10 min * 50% * 100% = 5 min
zone2 duration = 10 min * 50% * 150% = 7,5 min but set to 6 min as this is the max defined.

1 Like

Multiple zones is possible with the new version: you can add the intergration multiple times to HA; one for each zone. It will have some redundant config / fetch settings but it will do fine.

could you please verify service smart_irrigation.calculate_hourly_adjusted_run_time
seems doesn’t work as I tried to push my value into sensor and call service. didn’t changed back state of the sensor.

the other one “smart_irrigation.calculate_daily_adjusted_run_time” seems to works fine … i could push my value and service changed back to previous state.

bucket survives HA restart :slight_smile: but sensor’s state/value not. so if “daily” sensor is being set at 23:00 we should not restart HA after that time as we will loose sensor state and irrigation will not gonna happen. solution can be to call newly added service just before irrigation starts but it complicate things IMO

I know :slight_smile: there are several options available as for ex. I did it in my implantation via % adjustments per zone so no issue at all …

The only comment is that having zones in the garden is quite common thing and adding the same integration several times makes things a bit complicated and time consuming … easier would be to have a systems supporting zones … anyhow, no issue as the same functionality can be achieved easily in many different ways, so I’m cool with the way how it is done now :slight_smile:

ok, I can add it to the base schedule index as well. tracking that here: https://github.com/jeroenterheerdt/HAsmartirrigation/issues/15

zones support can be done already by adding the component more than once. I have also added lead-time, so wouldn’t that cover your scenario 1? Maximum irrigation time is also included already.

that is weird. I remember designing it that the daily adjusted run time should survive as well. I will check. Tracking it here: https://github.com/jeroenterheerdt/HAsmartirrigation/issues/16

fixed in version 0.0.14

base schedule index minutes added in version 0.0.15

yeep I see it but can you please remove ‘min’ from attributes ? in all three sensors please :slight_smile:
name itself is a self explaining about what units are we talking here …

adjusted_run_time_minutes: 1.62 min

with ‘min’ suffix it is a string so I can’t easily use it for my further calcs :frowning:

yes I think now most of ti can be done now directly by the component :slight_smile: thanks

1 Like

thanks - implemented this in version 0.0.16.

Can you share you yaml of the irrigation stats?

sure … e.g. zone 1

sensor:
  - platform: history_stats
    name: rainbird_zone_1_history_today
    entity_id: switch.rainbird_zone_1
    state: 'on'
    type: time
    start: '{{ now().replace(hour=0, minute=0, second=0) }}'
    end: '{{ now() }}'
  - platform: history_stats
    name: rainbird_zone_1_history_yesterday
    entity_id: switch.rainbird_zone_1
    state: 'on'
    type: time
    end: '{{ now().replace(hour=0, minute=0, second=0) }}'
    duration:
      hours: 24
  - platform: history_stats
    name: rainbird_zone_1_history_week
    entity_id: switch.rainbird_zone_1
    state: 'on'
    type: time
    start: '{{ as_timestamp( now().replace(hour=0, minute=0, second=0) ) - now().weekday() * 86400 }}'
    end: '{{ now() }}'
  - platform: history_stats
    name: rainbird_zone_1_history_month
    entity_id: switch.rainbird_zone_1
    state: 'on'
    type: time
    start: '{{ now().replace(day=1).replace(hour=0).replace(minute=0).replace(second=0) }}'
    end: '{{ now() }}'
  - platform: history_stats
    name: rainbird_zone_1_history_year
    entity_id: switch.rainbird_zone_1
    state: 'on'
    type: time
    start: '{{ now().replace(month=1).replace(day=1).replace(hour=0).replace(minute=0).replace(second=0) }}'
    end: '{{ now() }}'

  - platform: template
    sensors:
      rainbird_zone_1_stats:
        icon_template: >-
          {% if is_state('switch.rainbird_zone_1', 'on') %}
            mdi:chart-line-stacked
          {% else %}
            mdi:chart-line
          {% endif %}
        value_template: >-
          {{ state_attr('sensor.rainbird_zone_1_history_today', 'value') }}
        attribute_templates:
          today: >-
            {{ state_attr('sensor.rainbird_zone_1_history_today', 'value') }}
          yesterday: >-
            {{ state_attr('sensor.rainbird_zone_1_history_yesterday', 'value') }}
          week: >-
            {{ state_attr('sensor.rainbird_zone_1_history_week', 'value') }}
          month: >-
            {{ state_attr('sensor.rainbird_zone_1_history_month', 'value') }}
          year: >-
            {{ states('sensor.rainbird_zone_1_history_year') + state_attr('sensor.rainbird_zone_1_history_year', 'unit_of_measurement') }}

in front end I use custom component multiple-entity-row available in HACS

  entities:
    - type: section
    - entities:
        - attribute: today
          name: today
        - attribute: yesterday
          name: yesterday
        - attribute: week
          name: week
        - attribute: month
          name: month
        - attribute: year
          name: year
      entity: sensor.rainbird_zone_1_stats
      name: Zone 1 Front
      secondary_info: counters
      show_state: false
      type: 'custom:multiple-entity-row'
1 Like