Coder Social home page Coder Social logo

rgc99 / irrigation_unlimited Goto Github PK

View Code? Open in Web Editor NEW
303.0 13.0 43.0 2.59 MB

♒Irrigation controller for Home Assistant

License: MIT License

Python 99.91% Shell 0.09%
irrigation-control-system irrigation-controller home-assistant hacs sprinkler-controller home-automation watering-system watering-controller irrigation water

irrigation_unlimited's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

irrigation_unlimited's Issues

I would like to send a mqtt command to run sprinklers

Is your feature request related to a problem? Please describe.
I want my valve controller to handle the timings incase there is an issue with home assistant

Describe the solution you'd like
The ability to send mqtt commands with time to run included

Describe alternatives you've considered
If you could point me in the right direction as to where to add custom run code I would happily work on it myself

Controller status during sequence delay

First of all, excellent work on this project!

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

  • When the controller is on the delay between zones in a sequence, the status of the controller changes to Off, which doesn't fully represent the situation. (A quick glance at its status during this time could lead you to believe it's not running at all, rather than just in-between zones.)

Describe the solution you'd like
A clear and concise description of what you want to happen.

  • Maybe having the controller's status be something like Delay while delayed would work?

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

  • As-is, basing an automation or Node-RED flow on the status of the controller would require making sure the status remains Off for more than the length of the delay, to be sure the system is actually off, off.

Additional context
Add any other context or screenshots about the feature request here.

  • Version: 2021.3.29
  • Test code:
irrigation_unlimited:
  controllers:
    zones:
      - zone_id: 1
        name: "Irrigation Zone 1"
        entity_id: "switch.irrigation_zone_1"
      - zone_id: 2
        name: "Irrigation Zone 2"
        entity_id: "switch.irrigation_zone_2"
      - zone_id: 3
        name: "Irrigation Zone 3"
        entity_id: "switch.irrigation_zone_3"
      - zone_id: 4
        name: "Irrigation Zone 4"
        entity_id: "switch.irrigation_zone_4"
    sequences:
      - name: "Everything"
        delay: "00:01"
        schedules:
          - name: "Morning - Every Day"
            time: "06:00"
            weekday: [mon, tue, wed, thu, fri, sat, sun]
        zones:
          - zone_id: 1
            duration: "00:01"
          - zone_id: 2
            duration: "00:01"
          - zone_id: 4
            duration: "00:01"

Time adjustment ignored for a sequence.

First of all, thank you for contributing with this great component.
I'm planning all my watering control around irrigation_unlimited but I found an issue that I couldn't solve by myself.
It is related to the update of the times of a sequence based on an evapotraspiration calculator (Smart_Irrigation).
It seems that time adjustments are ignored.
Maybe you can help me.

Version of the custom_component

v2021.10.0

Configuration

irrigation_unlimited:
    refresh_interval: 10
    controllers:
      name: Principal
      preamble: "00:30"
      postamble: "00:30"
      zones:
        - name: 'Césped'
          entity_id: 'switch.1'
        - name: 'Borde'
          entity_id: 'switch.2'
        - name: 'Frente'
          entity_id: 'switch.3'
      sequences:
        - delay: '00:02'
          repeat: 12
          schedules:
            - time: '19:32'
              name: Test Schedule
          zones:
            - zone_id: 1
              duration: '00:01'
            - zone_id: 2
              duration: '00:01'
            - zone_id: 3
              duration: '00:01'

Describe the bug

After calling service irrigation_unlimited.adjust_time

service: irrigation_unlimited.adjust_time
data:
  entity_id: binary_sensor.irrigation_unlimited_c1_m
  sequence_id: 1
  actual: '00:04:00'

the entities shows the value in "next_adjustment".
While zone is running the attribute "adjustment" is set.

zone_id: '2'
index: 1
enabled: true
status: 'off'
schedule_count: 0
schedules: ''
adjustment: None
current_schedule: not running
percent_complete: 0
next_schedule: 1
next_name: Test Schedule
next_start: '2021-11-18T19:44:00+01:00'
next_duration: '0:01:00'
next_adjustment: '=0:04:00'
today_total: 33
friendly_name: Borde
icon: mdi:valve-closed

But when executing the sequence the adjustment never is used.
All the zones are switched on for the very "duration" configured in the yaml file.

The following image shows that the running time is 1 minute and the adjustment is ignored.

image

The logbook shows that the switch was on during 1 minute:

image

Debug log

2021-11-18 19:31:31 DEBUG (MainThread) [custom_components.irrigation_unlimited] REGISTER [2021-11-18 19:31:00] controller: 1, zone: 0, entity: binary_sensor.irrigation_unlimited_c1_m
2021-11-18 19:31:31 DEBUG (MainThread) [custom_components.irrigation_unlimited] CALL [2021-11-18 19:31:00] service: enable, controller: 1, zone: 0, data: null
2021-11-18 19:31:31 DEBUG (MainThread) [custom_components.irrigation_unlimited] REGISTER [2021-11-18 19:31:00] controller: 1, zone: 1, entity: binary_sensor.irrigation_unlimited_c1_z1
2021-11-18 19:31:31 DEBUG (MainThread) [custom_components.irrigation_unlimited] CALL [2021-11-18 19:31:00] service: enable, controller: 1, zone: 1, data: null
2021-11-18 19:31:31 DEBUG (MainThread) [custom_components.irrigation_unlimited] REGISTER [2021-11-18 19:31:00] controller: 1, zone: 2, entity: binary_sensor.irrigation_unlimited_c1_z2
2021-11-18 19:31:31 DEBUG (MainThread) [custom_components.irrigation_unlimited] CALL [2021-11-18 19:31:00] service: enable, controller: 1, zone: 2, data: null
2021-11-18 19:31:31 DEBUG (MainThread) [custom_components.irrigation_unlimited] REGISTER [2021-11-18 19:31:00] controller: 1, zone: 3, entity: binary_sensor.irrigation_unlimited_c1_z3
2021-11-18 19:31:31 DEBUG (MainThread) [custom_components.irrigation_unlimited] CALL [2021-11-18 19:31:00] service: enable, controller: 1, zone: 3, data: null
2021-11-18 19:31:41 DEBUG (MainThread) [custom_components.irrigation_unlimited] INITIALISED
2021-11-18 19:31:41 INFO (MainThread) [custom_components.irrigation_unlimited] EVENT [2021-11-18 19:31:00] controller: 1, zone: 0, state: 1
2021-11-18 19:32:01 INFO (MainThread) [custom_components.irrigation_unlimited] EVENT [2021-11-18 19:32:00] controller: 1, zone: 1, state: 1, data: 1.1.1.1.1
2021-11-18 19:33:01 INFO (MainThread) [custom_components.irrigation_unlimited] EVENT [2021-11-18 19:33:00] controller: 1, zone: 1, state: 0
2021-11-18 19:34:22 DEBUG (MainThread) [custom_components.irrigation_unlimited] CALL [2021-11-18 19:34:00] service: adjust_time, controller: 1, zone: 0, data: "{'entity_id': 'binary_sensor.irrigation_unlimited_c1_m', 'sequence_id': 1, 'actual': datetime.timedelta(seconds=4)}"
2021-11-18 19:35:01 INFO (MainThread) [custom_components.irrigation_unlimited] EVENT [2021-11-18 19:35:00] controller: 1, zone: 2, state: 1, data: 2.1.1.2.2
2021-11-18 19:35:58 DEBUG (MainThread) [custom_components.irrigation_unlimited] CALL [2021-11-18 19:35:00] service: adjust_time, controller: 1, zone: 0, data: "{'entity_id': 'binary_sensor.irrigation_unlimited_c1_m', 'sequence_id': 1, 'actual': datetime.timedelta(seconds=240)}"
2021-11-18 19:36:01 INFO (MainThread) [custom_components.irrigation_unlimited] EVENT [2021-11-18 19:36:00] controller: 1, zone: 2, state: 0
2021-11-18 19:38:01 INFO (MainThread) [custom_components.irrigation_unlimited] EVENT [2021-11-18 19:38:00] controller: 1, zone: 3, state: 1, data: 3.1.1.3.3
2021-11-18 19:39:01 INFO (MainThread) [custom_components.irrigation_unlimited] EVENT [2021-11-18 19:39:00] controller: 1, zone: 3, state: 0
2021-11-18 19:41:01 INFO (MainThread) [custom_components.irrigation_unlimited] EVENT [2021-11-18 19:41:00] controller: 1, zone: 1, state: 1, data: 1.1.1.1.4
2021-11-18 19:42:01 INFO (MainThread) [custom_components.irrigation_unlimited] EVENT [2021-11-18 19:42:00] controller: 1, zone: 1, state: 0
2021-11-18 19:44:01 INFO (MainThread) [custom_components.irrigation_unlimited] EVENT [2021-11-18 19:44:00] controller: 1, zone: 2, state: 1, data: 2.1.1.2.5
2021-11-18 19:45:01 INFO (MainThread) [custom_components.irrigation_unlimited] EVENT [2021-11-18 19:45:00] controller: 1, zone: 2, state: 0
2021-11-18 19:47:01 INFO (MainThread) [custom_components.irrigation_unlimited] EVENT [2021-11-18 19:47:00] controller: 1, zone: 3, state: 1, data: 3.1.1.3.6
2021-11-18 19:48:01 INFO (MainThread) [custom_components.irrigation_unlimited] EVENT [2021-11-18 19:48:00] controller: 1, zone: 3, state: 0
2021-11-18 19:50:01 INFO (MainThread) [custom_components.irrigation_unlimited] EVENT [2021-11-18 19:50:00] controller: 1, zone: 1, state: 1, data: 1.1.1.1.7

Integration setup on start up takes more than 3mins

Describe the bug
The integration takes a very very long time to start up after a restart. It's halting HA's starting up sequence quite a while.

Expected behavior
Is this integration so so heavy that such long time to startup is normal? (or even acceptable?)

Screenshots
image

Adjust runtime of sequence

Thank you for that great tool. I like und use it in my garden a lot.
Over night I adjust the runtime of all zones with the result from HAsmartirrigation. The irrigation starts before the sun comes up. That works greate.

No I would like to add a additional sequence that runs in the afternoon in summer with a fix value. But I can't define the sequence in the adjust_time command.

Is it possible to add a parameter to select the sequence that should be changed?

Or do you have a different idea?

Use a better available weather service source in examples

I love what WeatherUndergrond is doing. But there are alternatives that don't require you to run your own weather station.

May I suggest you change your examples to use OpenWeatherMap or Meteorologisk institutt (Met.no) which are used by default or at least give you easy access to the API.

Template support in service calls is highly valuable

It would be very useful to support the template processing in service calls:

For example, to support this template in a tap_action of the card:
Screenshot 2022-04-11 160359

    . . .
    - icon: mdi:play
      state_color: true
      tap_action:
        action: call-service
        service: irrigation_unlimited.manual_run
        service_data:
          entity_id: binary_sensor.irrigation_unlimited_c1_z1
          time: >
            {# to increase currently running zone to 30 minutes #}
            {%- set delta = 30 -%}
            {%- set remaining = state_attr('binary_sensor.irrigation_unlimited_c1_z4', 'time_remaining') -%}
            {%- if remaining -%}
            {%-   set time = strptime(remaining, "%H:%M:%S") + timedelta(minutes = delta) -%}
                  {{ '{:02d}:{:02d}:{:02d}'.format(time.hour, time.minute, time.second) }}'
            {%- else -%}
                  {{ '00:{:02d}'.format(delta) }}'
            {%- endif -%}

For the moment the validation of the 'time' attribute is not passed.

[Question] HAsmartirrigation Integration

Since it was mentioned in the description of the project, how exactly would an integration of HAsmartirrigation to distinguish dynamic watering duration look like? How would the result value of the HAsmartirrigation sensor have to be integrated into the yaml file exactly?
Thanks for creating this wonderful integration which really helps a lot.

HA Smart Irrigation automation - reset bucket only when

Not an issue, rather an idea.
I'm using the HA Smart Irrigation integration and your automation example to adjust the run time of Irrigation Unlimited.
(I have a dripline system by the way, no sprinklers, but it's not really relevant)

Because it's raining a lot my Smart Irrigation bucket has filled quite a lot. For that reason the adjusted runtime is now 0 seconds.
The automation example from the documentation here works fine, except that when the adjusted run time is 0 the next action still resets the bucket. Which brings the bucket back at 0. However since there was no run it shouldn't do that in my opinion.
So my suggestion is to add a condition to the action 'reset bucket' only when sensor.smart_irrigation_daily_adjusted_run_time is > 0 so when a run will actually take place.

Furthermore I have set different schedules for Irrigation Unlimited according to the months. The automation for the adjust runtime is now triggered daily, but my irrigation only runs twice a week. So every night the runtime gets adjusted, and that's absolutely fine. But also every night the bucket gets reset even though no run might be scheduled for that night.

Can we add another conditon on the action and do the reset bucket only when a run (either manual or scheduled) will take place? Or do we split the automation and is it possible to trigger to reset the bucket only when irrigation unlimited does a run and the adjusted runtime is > 0 ?

PS: This is the automation I'm talking about.

- alias: Smart Irrigation
  description: Adjust watering times
  trigger:
  - platform: time
    at: 04:00
  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) }}
  - service: smart_irrigation.smart_irrigation_reset_bucket
  mode: single

Thanks for the great integration!

manual_run card not listing zones/sequences

Version of the custom_component

HA 2021.11.0
Pyscript 1.3.2

Configuration

Both
input_select.irrigation_unlimited_entities
input_select.irrigation_unlimited_sequences

list only:
options:

Describe the bug

Using the card_manual_run does not propagate any values for zones/sequences. I installed required py script and yaml file, but no values are being populated.

Debug log

Logger: homeassistant.components.automation.irrigation_unlimited_load_ui_controls
Source: components/automation/init.py:520
Integration: Automation (documentation, issues)
First occurred: 2:57:19 PM (1 occurrences)
Last logged: 2:57:19 PM

Error while executing automation automation.irrigation_unlimited_load_ui_controls: Unable to find service irrigation_unlimited.list_config

Logger: homeassistant.components.automation.irrigation_unlimited_load_ui_controls
Source: helpers/script.py:1365
Integration: Automation (documentation, issues)
First occurred: 2:57:19 PM (1 occurrences)
Last logged: 2:57:19 PM

Irrigation Unlimited Load UI Controls: Error executing script. Service not found for call_service at pos 1: Unable to find service irrigation_unlimited.list_config

Request or clarification - Pad start time based off smart-irrigation run times

First, thanks for the great effort you have put in with this customization. It really completes my HAsmartirrigation installation.

Is your feature request related to a problem? Please describe.
I came from the home bridge world where I used homebridge-smart-irrigation (https://github.com/MTry/homebridge-smart-irrigation) and particularly like the feature where the irrigation start time would be sunrise (minus) the total of the calculated runtimes of the days zones. This system also used the evaporative calculation that HAsmartirrigation uses. In my case I have 11 zones which have a maximum runtime of 30 min for 5.5 hrs total in the maximum case. So since I want the irrigation to finish up at sunrise I subtract the 5.5 hrs and it starts usually just after midnight. But sometimes there is a very low amount of watering needed and if the system starts at just after midnight it is finished by 2am so there will be several hours before sunrise.

Describe the solution you'd like
Is there an action that would allow me to specify a dynamic adjustment of the start time based off of the sum of the zones to be watered (from HAsmartirrigation)? Right now your component fires at 23:30 and automatically adjusts the runtimes. This would be a (probably large) effort to get the sum of that runtime inserted into the controller -> sequences -> schedule -> time -> sun event options. I guess it could also be applied to a fixed time option as well.

Describe alternatives you've considered
None.

Additional context
None.

Thanks again for your component.

Log Error

Hi
Could someone help me with this error log please.
It show up twice in the log list.
2021.7.0

Logger: homeassistant.components.automation.irrigation_unlimited_adjustment
Source: components/automation/init.py:505
Integration: Automation (documentation, issues)
First occurred: 10:12:27 AM (1 occurrences)
Last logged: 10:12:27 AM

Error while executing automation automation.irrigation_unlimited_adjustment: Error rendering data template: ZeroDivisionError: float division by zero

Logger: homeassistant.components.automation.irrigation_unlimited_adjustment
Source: helpers/script.py:1344
Integration: Automation (documentation, issues)
First occurred: 10:12:27 AM (1 occurrences)
Last logged: 10:12:27 AM

Irrigation Unlimited Adjustment: Error executing script. Error for call_service at pos 1: Error rendering data template: ZeroDivisionError: float division by zero

# Filename: irrigation_unlimited_adjustment.yaml
#
# This file is a package and should be located in the config/packages
# folder. If you do not have a packages folder then create it and add
# the following to configuration.yaml
#
# homeassistant:
#  packages: !include_dir_named packages
#
# More information on packages can be found at https://www.home-assistant.io/docs/configuration/packages
#
# Set up some observation sensors.
# This uses the Weather Underground (WUnderground) https://www.home-assistant.io/integrations/wunderground/ integration.
# Rain information (wupws_preciptotal) is a daily accumulation total. So we want to grab the
# data just before midnight to get the daily total. We shouldn't be too eager to look after midnight
# because the reset from WU may take a few minutes to come through, currently 10 min. Increase this
# if data is unreliable.
# Note: Requires the ha-average integration to be installed https://github.com/Limych/ha-average
sensor:
  - platform: average
    name: irrigation_unlimited_rain_0
    entities:
      - sensor.wupws_preciptotal_2
    precision: 1
    start: '{{ now().replace(hour=0).replace(minute=30).replace(second=0) }}'
    end: '{{ now() }}'

  - platform: average
    name: irrigation_unlimited_rain_1
    entities:
      - sensor.wupws_preciptotal_2
    precision: 1
    start: '{{ now().replace(hour=0).replace(minute=30).replace(second=0) - timedelta(days=1) }}'
    end: '{{ now().replace(hour=23).replace(minute=59).replace(second=0) - timedelta(days=1) }}'

  - platform: average
    name: irrigation_unlimited_rain_2
    entities:
      - sensor.wupws_preciptotal_2
    precision: 1
    start: '{{ now().replace(hour=0).replace(minute=30).replace(second=0) - timedelta(days=2) }}'
    end: '{{ now().replace(hour=23).replace(minute=59).replace(second=0) - timedelta(days=2) }}'

  - platform: average
    name: irrigation_unlimited_rain_3
    entities:
      - sensor.wupws_preciptotal_2
    precision: 1
    start: '{{ now().replace(hour=0).replace(minute=30).replace(second=0) - timedelta(days=3) }}'
    end: '{{ now().replace(hour=23).replace(minute=59).replace(second=0) - timedelta(days=3) }}'

  - platform: average
    name: irrigation_unlimited_rain_4
    entities:
      - sensor.wupws_preciptotal_2
    precision: 1
    start: '{{ now().replace(hour=0).replace(minute=30).replace(second=0) - timedelta(days=4) }}'
    end: '{{ now().replace(hour=23).replace(minute=59).replace(second=0) - timedelta(days=4) }}'

  - platform: average
    name: irrigation_unlimited_temperature_0
    entities:
      - sensor.wupws_temp_2
    precision: 1
    start: '{{ now().replace(hour=0).replace(minute=30).replace(second=0) }}'
    end: '{{ now() }}'

  - platform: average
    name: irrigation_unlimited_temperature_1
    entities:
      - sensor.wupws_temp_2
    precision: 1
    start: '{{ now().replace(hour=0).replace(minute=30).replace(second=0) - timedelta(days=1) }}'
    end: '{{ now().replace(hour=23).replace(minute=59).replace(second=0) - timedelta(days=1) }}'

  - platform: average
    name: irrigation_unlimited_temperature_2
    entities:
      - sensor.wupws_temp_2
    precision: 1
    start: '{{ now().replace(hour=0).replace(minute=30).replace(second=0) - timedelta(days=2) }}'
    end: '{{ now().replace(hour=23).replace(minute=59).replace(second=0) - timedelta(days=2) }}'

  - platform: average
    name: irrigation_unlimited_temperature_3
    entities:
      - sensor.wupws_temp_2
    precision: 1
    start: '{{ now().replace(hour=0).replace(minute=30).replace(second=0) - timedelta(days=3) }}'
    end: '{{ now().replace(hour=23).replace(minute=59).replace(second=0) - timedelta(days=3) }}'

  - platform: average
    name: irrigation_unlimited_temperature_4
    entities:
      - sensor.wupws_temp_2
    precision: 1
    start: '{{ now().replace(hour=0).replace(minute=30).replace(second=0) - timedelta(days=4) }}'
    end: '{{ now().replace(hour=23).replace(minute=59).replace(second=0) - timedelta(days=4) }}'

  - platform: average
    name: irrigation_unlimited_temperature_5_day_moving_average
    entities:
      - sensor.wupws_temp_2
    precision: 1
    start: '{{ now().replace(hour=0).replace(minute=30).replace(second=0) - timedelta(days=4) }}'
    end: '{{ now() }}'

  # Five day weighted rain total sensor.
  # Adjust the weight values (0.7, 0.3, 0.15, 0.05) to suit your needs (0.0 = ignore that day).
  - platform: template
    sensors:
      irrigation_unlimited_rain_weighted_total:
        friendly_name: "Irrigation Unlimited Rain Weighted Total"
        unit_of_measurement: 'mm'
        icon_template: 'mdi:umbrella'
        value_template: >
          {% set rain_total = state_attr('sensor.irrigation_unlimited_rain_0','max_value') | float %}
          {% set rain_total = rain_total + state_attr('sensor.irrigation_unlimited_rain_1','max_value') | float * 0.7 %}
          {% set rain_total = rain_total + state_attr('sensor.irrigation_unlimited_rain_2','max_value') | float * 0.3 %}
          {% set rain_total = rain_total + state_attr('sensor.irrigation_unlimited_rain_3','max_value') | float * 0.15 %}
          {% set rain_total = rain_total + state_attr('sensor.irrigation_unlimited_rain_4','max_value') | float * 0.05 %}
          {{ rain_total | round(1) }}

# Automation to adjust the run times for Irrigation Unlimited.
# It uses the 5 day weighted rain total and the moving 5 day average temperature sensors
# created above to generate a variation.
# Adjust rain_total_threshold, rain_rate_threshold and temperature_threshold variables to suit you needs.
automation:
  - alias: Irrigation Unlimited Adjustment
    trigger:
      platform: state
      entity_id:
        - sensor.irrigation_unlimited_rain_weighted_total
        - sensor.irrigation_unlimited_temperature_5_day_moving_average
        - sensor.wupws_preciprate_2
    action:
      service: irrigation_unlimited.adjust_time
      data:
        entity_id: binary_sensor.irrigation_unlimited_c1_m
        percentage: >
          {# Threshold variables #}
          {% set rain_total_threshold = 3.5 %}
          {% set rain_rate_threshold = 1.0 %}
          {% set temperature_threshold = 0.0 %}

          {# Sensor data #}
          {% set rain_total = states('sensor.irrigation_unlimited_rain_weighted_total') | float %}
          {% set rain_rate = states('sensor.wupws_preciprate_2') | float %}
          {% set temperature_average = states('sensor.irrigation_unlimited_temperature_5_day_moving_average') | float %}

          {# Threshold variables #}
          {% set rain_multiplier = (1 - (rain_total / rain_total_threshold)) %}
          {% set temperature_multiplier = temperature_average / temperature_threshold %}

          {% set multiplier = 1.0 %}
          {% if rain_rate < rain_rate_threshold and rain_multiplier > 0 and rain_total < rain_total_threshold %}
            {% set multiplier = multiplier * temperature_multiplier %}
            {% set multiplier = multiplier * rain_multiplier %}
          {% else %}
            {% set multiplier = 0.0 %} {# It's raining or enough already #}
          {% endif %}

          {# Return multiplier as a percentage #}
          {{ (multiplier * 100) | round(0) }}

Invalid config after updating to version 2022.1.0

Describe the bug
Errors after update to 2022.1.0

To Reproduce

  1. Update Irrigation_unlimietd with HACS.
  2. Restart HA.

Expected behavior
No errors notification, as usually.

Additional context

The notification:

The following integrations and platforms could not be set up:
irrigation_unlimited
Please check your config and logs.

And the logs gives three errors with this information:

Error adding entities for domain irrigation_unlimited with platform irrigation_unlimited
11:46:09 – (ERROR) Irrigation Unlimited (custom integration)
Logger: custom_components.irrigation_unlimited
Source: custom_components/irrigation_unlimited/entity.py:111
Integration: Irrigation Unlimited (documentation, issues)
First occurred: 11:46:09 (1 occurrences)
Last logged: 11:46:09
Error adding entities for domain irrigation_unlimited with platform irrigation_unlimited
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 382, in async_add_entities
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 613, in _async_add_entity
await entity.add_to_platform_finish()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 747, in add_to_platform_finish
await self.async_added_to_hass()
File "/config/custom_components/irrigation_unlimited/entity.py", line 111, in async_added_to_hass
data = IUAdjustment(zne[ATTR_ADJUSTMENT]).to_dict()
KeyError: 'adjustment'

Error during setup of component irrigation_unlimited
11:46:09 – (ERROR) Irrigation Unlimited (custom integration)
Logger: homeassistant.setup
Source: custom_components/irrigation_unlimited/entity.py:111
Integration: Irrigation Unlimited (documentation, issues)
First occurred: 11:46:09 (1 occurrences)
Last logged: 11:46:09
Error during setup of component irrigation_unlimited
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/setup.py", line 229, in _async_setup_component
result = await task
File "/config/custom_components/irrigation_unlimited/init.py", line 251, in async_setup
await component.async_add_entities([IUComponent(coordinator)])
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 382, in async_add_entities
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 613, in _async_add_entity
await entity.add_to_platform_finish()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 747, in add_to_platform_finish
await self.async_added_to_hass()
File "/config/custom_components/irrigation_unlimited/entity.py", line 111, in async_added_to_hass
data = IUAdjustment(zne[ATTR_ADJUSTMENT]).to_dict()
KeyError: 'adjustment'

Exception in <file.irrigation_unlimited_service_shim.irrigation_unlimited_list_config> line 39: data = json.loads(irrigation_unlimited.coordinator.configuration) ^ AttributeError: 'StateVal' object has no attribute 'configuration'
11:46:51 – (ERROR) Pyscript Python scripting (custom integration) - message first occurred at 11:46:49 and shows up 2 times
Logger: custom_components.pyscript.file.irrigation_unlimited_service_shim.irrigation_unlimited_list_config
Source: custom_components/pyscript/eval.py:480
Integration: Pyscript Python scripting (documentation, issues)
First occurred: 11:46:49 (2 occurrences)
Last logged: 11:46:51
Exception in <file.irrigation_unlimited_service_shim.irrigation_unlimited_list_config> line 39: data = json.loads(irrigation_unlimited.coordinator.configuration) ^ AttributeError: 'StateVal' object has no attribute 'configuration'

Next Schedule

Hi
Thank you for this great integration to HA
Can I ask when does the Next Schedule update
For me it's Wednesday today and my next scheduled day to water is Sunday Im using the Seasonal watering config example.

Screen Shot 2021-07-21 at 2 41 50 pm

Error in readme ? days instead of weekday ? months instead of month

Hey !

You got an error in readme :

# Run 15 min 3 times a week in summer, 10 min once a week in winter and twice a week in spring/autumn
irrigation_unlimited:
  controllers:
    zones:
      - entity_id: 'switch.my_switch_1'
        schedules:
          - time: '05:30'
            duration: '00:15'
            days: [mon, wed, fri]
            months: [dec, jan, feb]
          - time: '05:30'
            duration: '00:10'
            days: [sun]
            months: [jun, jul, aug]
          - time: '05:30'
            duration: '00:12'
            days: [mon, thu]
            months: [mar, apr, may, sep, oct, nov]

Days -> weekday
Months -> month

Cheers !

Strange sequence behaviour

Hello,

I'm having problems with sequences. I'm using version 2021.6.15.

I have the next configuration:

    - name: 'Riego Pinar'
      entity_id: 'switch.sonoff_1000aa7cb2'
      enabled: true
      zones:
       - name: 'Zona 1'
         enabled: true
         minimum: '00:00'
         maximum: '00:19'
         entity_id: 'switch.sonoff_10007802f0'
       - name: 'Zona 2'
         enabled: true
         minimum: '00:00'
         maximum: '00:19'
         entity_id: 'switch.sonoff_1000794f0b'
       - name: 'Zona 3'
         entity_id: 'switch.sonoff_1000049a5e'
         enabled: true
         minimum: '00:00'
         maximum: '00:19'
      sequences:
        - name: 'Secuencia Pinar'
          duration: '00:08'
          delay: '00:01'
          schedules:
            - name: 'Amanecer'
              time:
                sun: 'sunrise'
                after: '00:00'
              month: [mar, apr, may, jun, jul, aug, sep]
            - name: 'Después del anochecer'
              time:
                sun: 'sunset'
                after: '00:30'
              month: [mar, apr, may, jun, jul, aug, sep]
          zones:
            - zone_id: [2,3]
            - zone_id: 1

The result is that sometimes the sequence is not run completely and sometimes it is. The behaviour seems a bit random.

I don't know if you can reproduce it or somehow I can send you some log, so you can debug it.

Thank you and best regards.
Miguel

Visualising changes to adjust_time in dashboard

I think I got a pretty good adjustment workflow going. And I use your average sensor trick to display the rainfall and temps over last few days.

I think it would be nice if the adjustment percentage (or time) could be plotted ontop of that. But the value doesn't seem to be accessible to the UI. (Or at least I don't know how)

The default card accesses that value via some Attribute. But I don't have access to that via the sensor graph..

Any ideas or hints?

Errors reported in HA 2021.12.4 Log about device_state_attributes

Describe the bug
The following errors are seen in the HA log file. This with HA 2021.12.4

Logger: homeassistant.helpers.entity
Source: helpers/entity.py:549
First occurred: 8:12:00 PM (3 occurrences)
Last logged: 8:13:45 PM

Entity binary_sensor.irrigation_unlimited_c1_m (<class 'custom_components.irrigation_unlimited.binary_sensor.IUMasterEntity'>) implements device_state_attributes. Please report it to the custom component author.
Entity binary_sensor.irrigation_unlimited_c1_z1 (<class 'custom_components.irrigation_unlimited.binary_sensor.IUZoneEntity'>) implements device_state_attributes. Please report it to the custom component author.

To Reproduce
Steps to reproduce the behavior:

  1. Take a working 2011.x HA install with Irrigation Unlimited working
  2. Upgrade to HA2021.12.4
  3. Look at log files

Expected behavior
Log files ask for issue to be reported

Desktop (please complete the following information):

  • OS: HASSOS
  • Browser Chrome
  • Version 96.0.4664.110 (Official Build) (64-bit)

Additional context
Add any other context about the problem here.

Not an Issue - Hardware question

Hi,
Thanks for creating this integration!
Just wanted to know what hardware you are using for this?

I too am in Australia and looking to start a smart sprinkler project but not sure on what hardware I need to work with this integration.
I was thinking an ESP8266 with a 4-channel relay board attached to 4 solenoids to give me 4 "zones". Ideally I'd pull this together with MQTT.

Just wanting to see what you were doing hardware wise.

state_changes_during_period was called from irrigation_unlimited, this is a deprecated function

Logger: homeassistant.components.history
Source: helpers/deprecation.py:122
Integration: History (documentation, issues)
First occurred: 7:24:50 (9 occurrences)
Last logged: 7:25:10

state_changes_during_period was called from irrigation_unlimited, this is a deprecated function. Use homeassistant.components.recorder.history.state_changes_during_period instead, please report this to the maintainer of irrigation_unlimited

Log book entries

Hi Robert
Is this normal for the average state to be triggering this often.
Thanks
Nick
Screen Shot 2021-08-28 at 10 55 59 am

Error doing job: Task exception was never retrieved

Hi,

my Irrigation Unlimited suddenly broke - I cannot enable/disable zones or master.

Only following is visible in the logs:

Logger: homeassistant
Source: custom_components/irrigation_unlimited/irrigation_unlimited.py:1771
Integration: Irrigation Unlimited (documentation, issues)
First occurred: 3. září 2021 20:39:16 (317 occurrences)
Last logged: 0:22:01

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/config/custom_components/irrigation_unlimited/irrigation_unlimited.py", line 2535, in _async_timer
    self.timer(time)
  File "/config/custom_components/irrigation_unlimited/irrigation_unlimited.py", line 2525, in timer
    self.poll_main(time)
  File "/config/custom_components/irrigation_unlimited/irrigation_unlimited.py", line 2519, in poll_main
    self.poll(time, force)
  File "/config/custom_components/irrigation_unlimited/irrigation_unlimited.py", line 2508, in poll
    if self.muster(wtime, force) != 0:
  File "/config/custom_components/irrigation_unlimited/irrigation_unlimited.py", line 2473, in muster
    status |= controller.muster(time, force)
  File "/config/custom_components/irrigation_unlimited/irrigation_unlimited.py", line 1795, in muster
    sequence_status = self.muster_sequence(
  File "/config/custom_components/irrigation_unlimited/irrigation_unlimited.py", line 1771, in muster_sequence
    next_run += duration_max
TypeError: unsupported operand type(s) for +=: 'NoneType' and 'datetime.timedelta'

Home Assistant OS 2021.8.8
Raspberry Pi 4B

GUI Configuration

Would it be possible to integrate a visual configuration for this integration?
Right now I can only add it by editing the yaml file.
It would be awesome to add it (and configure it) using the web-gui from HA. Setting up controllers and zones with the GUI would make it also great for noobs like me (however I managed to deal with it and set up something).

Thanks for this awesome integration which I really love using!

How to add soil moisture sensor???

Hello, I want to add a soil moisture sensor, but I don't know how I could integrate it, in the sense that: when it rains and the soil moisture is >40%, the sprinklers don't start. The soil moisture sensor I made an ESP32 and a probe.
Best regards,

manual_stop

I think it could be a good idea if you could make a service to manual stop the current irrigation run, either manual or scheduled.

In my system I have a workaround to do it by calling irrigation_unlimited.disable and irrigation_unlimited.enable in sequence as you can see here: https://github.com/rgc99/irrigation_unlimited/issues/2

With this service it's easy to make a button to switch on/off manual runs, or to stop the actual scheduled run.

More of a question then an issue

Quick rookie question: is there a service call through which I can switch to different schedule for a controller (with 4 lines)?
Or am I thinking in a wrong way :)
Hopefully I don't have to edit config/reboot every time I want to switch schedules, or create separate entities (controllers) for each schedule.
This is my current config. Looking at switching between "3x week" and "every other day "schedules".

https://pastebin.com/4fiPpTM4

Everything else works beautifully. Awesome component. Thanks!

Adjust Time: reset error

Describe the bug
Calling the adjust time service with reset fails with error:
"Must contain one of actual, percentage, increase, decrease"

To Reproduce
Steps to reproduce the behavior:

  1. using developer tools run the following service parameters
  2. service: irrigation_unlimited.adjust_time data: entity_id: binary_sensor.irrigation_unlimited_c1_m reset: ''

Expected behavior
run times for specified entity are reset to the schedule defaults

Additional context
cv.has_at_least_one_key(CONF_ACTUAL, CONF_PERCENTAGE, CONF_INCREASE, CONF_DECREASE)
this should also contain CONF_RESET

Sequencing and zones

Hi i have an irrigation pump that i need enabled during the entire run. I'm not to sure where to insert the entity_id of the pump to have it switch on during the entire sequence

Bug in configuration (testing parameter)

In last version (v2021.06.15) testing object gives an error.

Configuration:

  granularity: 10
  refresh_interval: 30
  testing:
    enabled: false
    speed: 20.0
    times:
      - name: 'Test 1'
        start: '2021-03-01 08:30'
        end: '2021-04-30 07:30'
      - name: 'Test 2'
        start: '2021-01-01 05:00'
        end: '2021-01-01 05:30'

Gives the next error:

Invalid config for [irrigation_unlimited]: expected a list for dictionary value @ data['irrigation_unlimited']['testing']['results']. Got None
required key not provided @ data['irrigation_unlimited']['controllers'][0]['zones']. Got None. (See /config/configuration.yaml, line 19).

How to variate time parameter of the manual_run

Hi!
Sorry for my rookie question!
I would like to dynamically change the Time parameter of the manual_run service. For example via an helper.
Could you send me any suggestions?
Regards: Tamas

Manual_run error in pyscript file

Describe the bug
I am getting the following error in my logs:
Exception in <file.irrigation_unlimited_service_shim.irrigation_unlimited_list_config> line 39: data = json.loads(irrigation_unlimited.coordinator.configuration) ^ AttributeError: 'StateVal' object has no attribute 'configuration'

My coordinator only has a state of ok and friendly_name and icon as attributes.

To Reproduce
Steps to reproduce the behavior:

  1. Install with the minimum configuration
  2. Add the pyscript and helpers
  3. Restart Home Assistant

Expected behavior
Input selects are filled with the correct zones and sequences

Questions about sequences

Hello,

I'm starting my use of sequence and I have a couple of questions/sugestions:

  • Is it possible to enable/disable a sequences in configuration? I don't think so.
  • It would be also a good idea to have the parameteres 'weekday', 'day' and 'month' in the same way as in schedule objects.

If I'm right, it would be a great addition to apply these features to sequences, because at the end of the day, the result of schedules and sequences is the same, irrigation of the garden :)

Thank you for your time and great work!

Thank you for your time!

Wrong duration

i’m in trouble with the duration time, i saw the issue when i use the manual card on my lovelace dashboard.
i'm using the last version download by HACS

this is my configuration

#### IRRIGAZIONE ####
irrigation_unlimited:
  controllers:
    - name: 'Giardino Fronte Casa'
      enabled: true
      zones:
        - name: 'Zona Laghetto'
          entity_id: 
            - switch.sonoff_1000f46e4e_1
            - switch.sonoff_1000f46e4e_2
        - name: 'Zona pozzo'
          entity_id: 
            - switch.sonoff_1000f46e4e_3
            - switch.sonoff_1000f46e4e_4
      sequences:
        - delay: '00:01'
          name: 'Stagionale'
          schedules:
           # - name: 'Sunrise'
           #   time:
           #    sun: 'sunrise'
            - name: 'Inverno'
              time: '05:30'
              weekday: [mon, wed, fri]
              month: [dec, jan, feb]
              duration: '00:03'
            - name: 'Estate'
              time: '05:30'
              weekday: [sun]
              month: [jun, jul, aug]
              duration: '00:05'
            - name: 'Primavera e Autunno'
              time: '05:30'
              weekday: [mon, thu]
              month: [mar, apr, may, sep, oct, nov]    
              duration: '00:03'
          zones:
            - zone_id: 1
            - zone_id: 2
#### IRRIGAZIONE - FINE####

as you can see the duration is 5 or 3 minutes for each zone

The adjusting service mark a percentage of adjusting of %47.0 so the duration sould be 2 minutes and 35 seconds not 40 minutes
what is wrong in my irrigation?
hassio1

hassio2

Thanks in advance

Create entity for schedules

Is your feature request related to a problem? Please describe.
I would like to create an interface focusing on the schedules, like klogg but more and more modern.

Is it possible to expose an entity dedicated to schedules? Reading the json file is a bit frustrating

Describe the solution you'd like
Expose an entity for schedules, with the list of involved zones, the total duration, the percentage..

State count of binary sensors vey high

Hello,

I've checked the state count of my entities and found that irrigation unlimited binary sensors have the highest state count (much higher than the rest of entities).

I record states for the last 14 days:

recorder:
  purge_keep_days: 14 # Keep 14 days in history after purging @ 04:12

My irrigation unlimited configuration has 2 controllers with 3 and 4 zones each. This is my configuration:

granularity: 10
testing:
  enabled: false
  speed: 30.0
  times:
    - name: 'Test 1'
      start: '2021-03-01 08:30'
      end: '2021-04-30 07:30'
    - name: 'Test 2'
      start: '2021-01-01 05:00'
      end: '2021-01-01 05:30'
controllers:
  - name: 'Riego pueblo'
    enabled: true
    zones:
     - name: 'Zona 1'
       enabled: true
       minimum: '00:00'
       maximum: '00:10'
       entity_id: 'switch.sonoff_1000cade2e_1'
       schedules:
         - name: 'Primavera'
           time:
              sun: 'sunrise'
              after: '00:00'
           duration: '00:08'
           month: [mar, apr, may]
     - name: 'Zona 2'
       enabled: true
       minimum: '00:00'
       maximum: '00:10'
       entity_id: 'switch.sonoff_1000cade2e_2'
       schedules:
         - name: 'Primavera'
           time:
              sun: 'sunrise'
              after: '00:10'
           duration: '00:08'
           month: [mar, apr, may]
     - name: 'Zona 3'
       entity_id: 'switch.sonoff_1000cade2e_3'
       enabled: true
       minimum: '00:00'
       maximum: '00:10'
       schedules:
         - name: 'Primavera'
           time:
              sun: 'sunrise'
              after: '00:20'
           duration: '00:08'
           month: [mar, apr, may]
  - name: 'Riego Pinar'
    entity_id: 'switch.sonoff_1000aa7cd2'
    enabled: true
    zones:
     - name: 'Zona 1'
       enabled: true
       minimum: '00:00'
       maximum: '00:20'
       entity_id: 'switch.sonoff_100078d1f0'
       schedules:
         - name: 'Primavera'
           time: '03:00'
           duration: '00:12'
           month: [mar, apr, may]
     - name: 'Zona 2'
       enabled: true
       minimum: '00:00'
       maximum: '00:20'
       entity_id: 'switch.sonoff_100079df0a'
       schedules:
         - name: 'Primavera'
           time: '03:12'
           duration: '00:12'
           month: [mar, apr, may]
     - name: 'Zona 3'
       entity_id: 'switch.sonoff_100004da4e'
       enabled: true
       minimum: '00:00'
       maximum: '00:20'
       schedules:
         - name: 'Primavera'
           time: '03:12'
           duration: '00:12'
           month: [mar, apr, may]
     - name: 'Zona 4'
       entity_id: 'switch.sonoff_100078dfde'
       enabled: true
       minimum: '00:00'
       maximum: '00:20'
       schedules:
         - name: 'Primavera'
           time: '03:24'
           duration: '00:12'
           month: [mar, apr, may]

I get the these state counts:

* binary_sensor.irrigation_unlimited_c2_m: 20946
* binary_sensor.irrigation_unlimited_c1_m: 11418
* binary_sensor.irrigation_unlimited_c2_z1: 7735
* binary_sensor.irrigation_unlimited_c2_z2: 6757
* binary_sensor.irrigation_unlimited_c2_z3: 6757
* binary_sensor.irrigation_unlimited_c2_z4: 5985
* binary_sensor.irrigation_unlimited_c1_z1: 4116
* binary_sensor.irrigation_unlimited_c1_z3: 4000
* binary_sensor.irrigation_unlimited_c1_z2: 3929

Are all of these states necessary for this integration of am I making somethind wrong? Or maybe it's due to the low value of the granularity?

manual_run error in version 2021.3.29

First of all, thank for your work. It is great and I'm enjoying it a lot and find it very useful.

Calling to manual_run doesn't work in last version (2021.3.29) while run smothly in previous ones.

Content of the error in log file (lots of errors exactly like this):

2021-03-31 10:39:24 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/config/custom_components/irrigation_unlimited/irrigation_unlimited.py", line 1620, in _async_timer
    self.poll(time)
  File "/config/custom_components/irrigation_unlimited/irrigation_unlimited.py", line 1556, in poll
    if self.muster(wtime, force) != 0:
  File "/config/custom_components/irrigation_unlimited/irrigation_unlimited.py", line 1532, in muster
    status |= controller.muster(time, force)
  File "/config/custom_components/irrigation_unlimited/irrigation_unlimited.py", line 1327, in muster
    zone_status |= zone.muster(time, zone.schedules, None, None, force)
  File "/config/custom_components/irrigation_unlimited/irrigation_unlimited.py", line 938, in muster
    status |= self._run_queue.merge(
  File "/config/custom_components/irrigation_unlimited/irrigation_unlimited.py", line 695, in merge
    run = self.find_last_by_id(schedule.id)
  File "/config/custom_components/irrigation_unlimited/irrigation_unlimited.py", line 541, in find_last_by_id
    if run.parent.id == id:
AttributeError: 'NoneType' object has no attribute 'id'

I'm runing Home Assistant 2021.3.4 with core-2021.3.4 if that's relevant.

My contiguration is this:

granularity: 10
controllers:
  - name: 'Riego pueblo'
    enabled: true
    zones:
     - name: 'Zona 1'
       enabled: true
       minimum: '00:00'
       maximum: '00:10'
       entity_id: 'switch.sonoff_1000caee3e_1'
       schedules:
         - name: 'Primavera'
           time:
              sun: 'sunrise'
              after: '00:00'
           duration: '00:08'
           month: [mar, apr, may]
     - name: 'Zona 2'
... (similar to previous).

Thank you.

Manual Run Card

Hi there
Great new features in the new update!
Just noticed the timer entry on the Manual Run card as a am/pm option. Has a home assistant update caused this?
I noticed this before the 2021.9.0 update.
Screen Shot 2021-09-11 at 6 56 47 pm

Delay between Zones

Hi Robert,
First of all congratulations and thank you for your great work, I was looking for a replacement system to a great system that I used (https://github.com/kloggy/HA-Irrigation-Version2), but it has been giving some problems and I ended up giving up .
So, I started using your system and I'm really enjoying it, but I was left with a question if it is possible to create a delay of a few seconds between each zone, to prevent several of them from starting to irrigate at the same time.
Thank you very much!

granularity: 10
controllers:
  - name: "Fundos"
    enabled: true
    zones:
      - name: "Gramado"
        entity_id: "switch.irrigacao_grama"
        enabled: true
        minimum: "00:00:10"
        maximum: "00:05:00"
        schedules:
          - name: "Alvorada"
            time:
              sun: "sunrise"
              before: "00:20"
            duration: "00:02"
          - name: "Por do Sol"
            time:
              sun: "sunset"
              after: "00:30"
            duration: "00:02"
      - name: "Lateral"
        entity_id: "switch.irrigacao_lateral"
        enabled: true
        minimum: "00:00:10"
        maximum: "00:05:00"
        schedules:
          - name: "Alvorada"
            time:
              sun: "sunrise"
              before: "00:20"
            duration: "00:02"
          - name: "Por do Sol"
            time:
              sun: "sunset"
              after: "00:30"
            duration: "00:02"
  - name: "Frente"
    enabled: true
    zones:
      - name: "Corredor"
        entity_id: "switch.irrigacao_corredor"
        enabled: true
        minimum: "00:00:10"
        maximum: "00:05:00"
        schedules:
          - name: "Alvorada"
            time:
              sun: "sunrise"
              before: "00:20"
            duration: "00:02"
          - name: "Por do Sol"
            time:
              sun: "sunset"
              after: "00:30"
            duration: "00:02"
      - name: "Horta"
        entity_id: "switch.irrigacao_horta"
        enabled: true
        minimum: "00:00:10"

Template warning

Version of the custom_component

2021.10.0

Configuration

# Filename: irrigation_unlimited_adjustment.yaml
#
# This file is a package and should be located in the config/packages
# folder. If you do not have a packages folder then create it and add
# the following to configuration.yaml
#
# homeassistant:
#  packages: !include_dir_named packages
#
# More information on packages can be found at https://www.home-assistant.io/docs/configuration/packages
#
# Set up some observation sensors.
# This uses the Weather Underground (WUnderground) https://www.home-assistant.io/integrations/wunderground/ integration.
# Rain information (wupws_preciptotal) is a daily accumulation total. So we want to grab the
# data just before midnight to get the daily total. We shouldn't be too eager to look after midnight
# because the reset from WU may take a few minutes to come through, currently 10 min. Increase this
# if data is unreliable.
# Note: Requires the ha-average integration to be installed https://github.com/Limych/ha-average
sensor:
  - platform: average
    name: irrigation_unlimited_rain_0
    entities:
      - sensor.wupws_preciptotal_2
    precision: 1
    start: '{{ now().replace(hour=0).replace(minute=30).replace(second=0) }}'
    end: '{{ now() }}'

  - platform: average
    name: irrigation_unlimited_rain_1
    entities:
      - sensor.wupws_preciptotal_2
    precision: 1
    start: '{{ now().replace(hour=0).replace(minute=30).replace(second=0) - timedelta(days=1) }}'
    end: '{{ now().replace(hour=23).replace(minute=59).replace(second=0) - timedelta(days=1) }}'

  - platform: average
    name: irrigation_unlimited_rain_2
    entities:
      - sensor.wupws_preciptotal_2
    precision: 1
    start: '{{ now().replace(hour=0).replace(minute=30).replace(second=0) - timedelta(days=2) }}'
    end: '{{ now().replace(hour=23).replace(minute=59).replace(second=0) - timedelta(days=2) }}'

  - platform: average
    name: irrigation_unlimited_rain_3
    entities:
      - sensor.wupws_preciptotal_2
    precision: 1
    start: '{{ now().replace(hour=0).replace(minute=30).replace(second=0) - timedelta(days=3) }}'
    end: '{{ now().replace(hour=23).replace(minute=59).replace(second=0) - timedelta(days=3) }}'

  - platform: average
    name: irrigation_unlimited_rain_4
    entities:
      - sensor.wupws_preciptotal_2
    precision: 1
    start: '{{ now().replace(hour=0).replace(minute=30).replace(second=0) - timedelta(days=4) }}'
    end: '{{ now().replace(hour=23).replace(minute=59).replace(second=0) - timedelta(days=4) }}'

  - platform: average
    name: irrigation_unlimited_temperature_0
    entities:
      - sensor.wupws_temp_2
    precision: 1
    start: '{{ now().replace(hour=0).replace(minute=30).replace(second=0) }}'
    end: '{{ now() }}'

  - platform: average
    name: irrigation_unlimited_temperature_1
    entities:
      - sensor.wupws_temp_2
    precision: 1
    start: '{{ now().replace(hour=0).replace(minute=30).replace(second=0) - timedelta(days=1) }}'
    end: '{{ now().replace(hour=23).replace(minute=59).replace(second=0) - timedelta(days=1) }}'

  - platform: average
    name: irrigation_unlimited_temperature_2
    entities:
      - sensor.wupws_temp_2
    precision: 1
    start: '{{ now().replace(hour=0).replace(minute=30).replace(second=0) - timedelta(days=2) }}'
    end: '{{ now().replace(hour=23).replace(minute=59).replace(second=0) - timedelta(days=2) }}'

  - platform: average
    name: irrigation_unlimited_temperature_3
    entities:
      - sensor.wupws_temp_2
    precision: 1
    start: '{{ now().replace(hour=0).replace(minute=30).replace(second=0) - timedelta(days=3) }}'
    end: '{{ now().replace(hour=23).replace(minute=59).replace(second=0) - timedelta(days=3) }}'

  - platform: average
    name: irrigation_unlimited_temperature_4
    entities:
      - sensor.wupws_temp_2
    precision: 1
    start: '{{ now().replace(hour=0).replace(minute=30).replace(second=0) - timedelta(days=4) }}'
    end: '{{ now().replace(hour=23).replace(minute=59).replace(second=0) - timedelta(days=4) }}'

  - platform: average
    name: irrigation_unlimited_temperature_5_day_moving_average
    entities:
      - sensor.wupws_temp_2
    precision: 1
    start: '{{ now().replace(hour=0).replace(minute=30).replace(second=0) - timedelta(days=4) }}'
    end: '{{ now() }}'

  # Five day weighted rain total sensor.
  # Adjust the weight values (0.7, 0.3, 0.15, 0.05) to suit your needs (0.0 = ignore that day).
  - platform: template
    sensors:
      irrigation_unlimited_rain_weighted_total:
        friendly_name: "Irrigation Unlimited Rain Weighted Total"
        unit_of_measurement: 'mm'
        icon_template: 'mdi:umbrella'
        value_template: >
          {% set rain_total = state_attr('sensor.irrigation_unlimited_rain_0','max_value') | float %}
          {% set rain_total = rain_total + state_attr('sensor.irrigation_unlimited_rain_1','max_value') | float * 0.7 %}
          {% set rain_total = rain_total + state_attr('sensor.irrigation_unlimited_rain_2','max_value') | float * 0.3 %}
          {% set rain_total = rain_total + state_attr('sensor.irrigation_unlimited_rain_3','max_value') | float * 0.15 %}
          {% set rain_total = rain_total + state_attr('sensor.irrigation_unlimited_rain_4','max_value') | float * 0.05 %}
          {{ rain_total | round(1) }}

# Automation to adjust the run times for Irrigation Unlimited.
# It uses the 5 day weighted rain total and the moving 5 day average temperature sensors
# created above to generate a variation.
# Adjust rain_total_threshold, rain_rate_threshold and temperature_threshold variables to suit you needs.
automation:
  - alias: Irrigation Unlimited Adjustment
    trigger:
      platform: state
      entity_id:
        - sensor.irrigation_unlimited_rain_weighted_total
        - sensor.irrigation_unlimited_temperature_5_day_moving_average
        - sensor.wupws_preciprate_2
    action:
      service: irrigation_unlimited.adjust_time
      data:
        entity_id: binary_sensor.irrigation_unlimited_c1_m
        percentage: >
          {# Threshold variables #}
          {% set rain_total_threshold = 3.5 %}
          {% set rain_rate_threshold = 1.0 %}
          {% set temperature_threshold = 20.0 %}

          {# Sensor data #}
          {% set rain_total = states('sensor.irrigation_unlimited_rain_weighted_total') | float %}
          {% set rain_rate = states('sensor.wupws_preciprate_2') | float %}
          {% set temperature_average = states('sensor.irrigation_unlimited_temperature_5_day_moving_average') | float %}

          {# Threshold variables #}
          {% set rain_multiplier = (1 - (rain_total / rain_total_threshold)) %}
          {% set temperature_multiplier = temperature_average / temperature_threshold %}

          {% set multiplier = 1.0 %}
          {% if rain_rate < rain_rate_threshold and rain_multiplier > 0 and rain_total < rain_total_threshold %}
            {% set multiplier = multiplier * temperature_multiplier %}
            {% set multiplier = multiplier * rain_multiplier %}
          {% else %}
            {% set multiplier = 0.0 %} {# It's raining or enough already #}
          {% endif %}

          {# Return multiplier as a percentage #}
          {{ (multiplier * 100) | round(0) }}

Describe the bug

Not sure it's a Bug just comes up in the logs

Debug log


Logger: homeassistant.helpers.template
Source: helpers/template.py:1210
First occurred: 15:35:01 (23 occurrences)
Last logged: 15:46:01

Template warning: 'float' got invalid input 'unknown' when rendering template '{# Threshold variables #} {% set rain_total_threshold = 3.5 %} {% set rain_rate_threshold = 1.0 %} {% set temperature_threshold = 20.0 %} {# Sensor data #} {% set rain_total = states('sensor.irrigation_unlimited_rain_weighted_total') | float %} {% set rain_rate = states('sensor.wupws_preciprate_2') | float %} {% set temperature_average = states('sensor.irrigation_unlimited_temperature_5_day_moving_average') | float %} {# Threshold variables #} {% set rain_multiplier = (1 - (rain_total / rain_total_threshold)) %} {% set temperature_multiplier = temperature_average / temperature_threshold %} {% set multiplier = 1.0 %} {% if rain_rate < rain_rate_threshold and rain_multiplier > 0 and rain_total < rain_total_threshold %} {% set multiplier = multiplier * temperature_multiplier %} {% set multiplier = multiplier * rain_multiplier %} {% else %} {% set multiplier = 0.0 %} {# It's raining or enough already #} {% endif %} {# Return multiplier as a percentage #} {{ (multiplier * 100) | round(0) }}' but no default was specified. Currently 'float' will return '0', however this template will fail to render in Home Assistant core 2021.12

State reverts to OFF after HA restart

Describe the bug
If the system has started to water (ON) and HA happens to restart during that time when it comes back the integration reverts to system being OFF. However the relay/switch it had turned on remains ON without the integrations picking that up to continue. This will/can lead to a zone watering 'forever' since system thinks it's off.

Perhaps this is something wrong on my side or just not implement yet?

To Reproduce
Steps to reproduce the behavior:

  • Start a schedule / manual run etc.
  • Restart HA
  • System comes back OFF but relay is ON

Expected behavior
I would expect the integration to realise it's last state was ON (that should be possible based on history of the entity) and pick up from where it left off.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

How to open to valves/zone at the same time

Firstly, great component and thank you for sharing.

I have quite a big garden with multiple lanes/valves in the system. I understand that a zone is equal to a switch. How would I go about opening two valves/switch at the same time, or add two switches to a zone?

Thanks again.

Error in starting component

HA: 2021.4.6
Irrigation Unlimited: 2021.6.15

Having this error and the component is not working. It was working well with previous version:

 Unable to prepare setup for platform irrigation_unlimited.binary_sensor: 
Platform not found (cannot import name 'history' from 'homeassistant.components.recorder'
 (/usr/src/homeassistant/homeassistant/components/recorder/__init__.py)). 

EDIT: IU 2021.6.3 works fine.

Watering graph not working

Hi guys.
I'm having trouble replicating the "Watering last 7 days" graph. My system is working and I updated to the latest version. All the other cards are working, though I'm learning to use HA and I'm a noob with this.

The problem is that when I use the code published for that graph it doesn't plot the data but writes "Not a number". I checked in the entities menu and I verified the attribute "today total" is present and is a number.

This is my code for the graph:

type: 'custom:mini-graph-card'
name: Watering Last 7 Days
icon: 'mdi:sprinkler-variant'
entities:
   -entity: binary_sensor.irrigation_unlimited_c1_z1
    attribute: today_total
show:
  graph: bar
  labels: true
unit: min
aggregate_func: max
hours_to_show: 168
group_by: date
lower_bound: 0

I also checked for the working principles of the mini-graph-card and using the "state_map" function to convert the binary sensor data works well. The graph though is not so good using this function (I think it approximates the "0" and "1" states resulting in a flat zero plot). Obviusly I'm here writing because I would like a bar graph proportional to the timings of watering.

image

Maximum parameter not taken into account

I've set the maximum parameter on the configuration:

irrigation_unlimited:
  granularity: 10
  refresh_interval: 20
  controllers:
    - name: 'Rain Bird'
      zones:
        - name: "Front (zone 1)"
          entity_id: "switch.rain_valve_1"
          maximum: "01:30"
        - name: "Back (zone 2)"
          entity_id: "switch.rain_valve_2"
          maximum: "06:00"

But when the run time is overwritten via adjust_time (coming from HAsmartirrigation), it doesn't respect the maximum run time.

Is this a bug, or is there something wrong in the configuration?

WiFi disruption leaves ESP home in intermediate state, no good for irrigation systems

Version of the custom_component

Configuration

Add your logs here.

Describe the bug

Using ESPHome with a quad relay board to drive sprinkler system seems a great idea. However, WiFi disruptions found ESPHome relays in indeterminant states. When WiFi connection re-established, the ESPHome device had random relays ON and their state was not reflected in the HA end, so you could not detect the error state HA end. Result, waste of water and depending upon the length of time until you found the error condition, an expensive problem.

Debug log


Error logs only reflected the loss of comms and then the re-establishment of comms.   Logs did not reflect the disconnect in states.

Description here

Solution was to drop ESPHome as means to drive relays and use a smarter sprinkler node that had minimum and maximum limits on how long a sprinkler ran for, so if there was a drop in comms, the sprinkler would turn off anyway.

https://github.com/Bazmundi/opensprinklette

Still working on auto node registration (uses a herald message on start up and also lwt to report offline condition). Have dropped hand coded scheduler for hand built HA automations, but may look at how to integrate with either irrigation template or irrigation unlimited now I have "discovered" them - thanks.

Error in documentation under 'Service call access roadmap'

Version of the custom_component

N/A

Configuration

N/A

Describe the bug

The following examples in the main page under "Service call access roadmap" should demonstrate 'adjust_time' but accidentally demonstrate 'enable':

# Example 1.1.1 -> controller 1 -> zone 1 -> duration. This will alter the duration for zone 1.
- service: irrigation_unlimited.enable
  data:
    entity_id: binary_sensor.irrigation_unlimited_c1_z1

# Example 1.2.1 -> controller 1 -> zone 1 -> duration. This will alter the duration for zone 2.
- service: irrigation_unlimited.enable
  data:
    entity_id: binary_sensor.irrigation_unlimited_c1_z2

Debug log


N/A

Watering History Information Card not working

Describe the bug
I'm using the watering history information card but despite using the dev.4 version of the mini-graph-card I do not get any information. The card only shows NaN for the minutes and no graph/bar at all.

To Reproduce
I'm using the following config:

type: 'custom:mini-graph-card'
name: Watering Last 7 Days
icon: 'mdi:sprinkler-variant'
entities:
  - entity: binary_sensor.irrigation_unlimited_c1_z1
    attribute: today_total
  - entity: binary_sensor.irrigation_unlimited_c1_z2
    attribute: today_total
show:
  graph: bar
  labels: true
unit: min
aggregate_func: max
hours_to_show: 168
group_by: date
lower_bound: 0

Expected behavior
A history graph with watering information shows

Screenshots
image

Desktop (please complete the following information):

  • OS: Manjaro Linux
  • Browser: Firefox
  • Version: 88.0

Smartphone (please complete the following information):

  • Device: Pixel5
  • OS: Android 11
  • Browser Firefox
  • Version 88.0

Additional context
I checked for the today_total attribute on both of my zones and they exist and contain a value. I also double-checked the custom cards and required integrations mentioned, all are installed. I did modify the automations and sensors to what I am using however nothing changed and this card does not work. I installed the preview version of the minigraph card (dev.4) so it should work. Also checked with the version mentioned in the docs (dev.3) but it also did not work.

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.