rgc99 / irrigation_unlimited

â™’Irrigation controller for Home Assistant
MIT License
328 stars 49 forks source link

Can you add rain sensor? #26

Open norbertjoni opened 3 years ago

norbertjoni commented 3 years ago

I have this diy rain sensor : https://community.home-assistant.io/t/commercial-2-wires-rain-sensor-converted-to-smart-sensor-with-shelly-d-w/194169

Can you add to your project please?

timnell commented 2 years ago

My Watering system also has a sensor to indicate if it has rained or is raining. If there could be a link to a sensor to dissable the shedule or similar would be great.

rgc99 commented 2 years ago

You control the schedule via an adjust_time service call which can be on/off or some other value to alter the duration. Here is an example taken from the documentation. It shows how to take any sensor in HA and make changes to watering time. Use this as a starting point to create an automation.

Cheers

automation:
  - alias: ESPHome soil moisture adjustment
    trigger:
      platform: state
      entity_id:
        - sensor.yard1_humidity
    action:
      service: irrigation_unlimited.adjust_time
      data:
        # Change the following to the entity/zone you wish to adjust
        entity_id: binary_sensor.irrigation_unlimited_c1_m
        percentage: >
          {# Threshold variable 0-100 percent #}
          {% set threshold = 40 %}

          {# Sensor data #}
          {% set humidity = states('sensor.yard1_humidity') | float %}

          {% if humidity < threshold %}
            {# Option 1 - A linear sliding scale #}
            {% set multiplier = 1 - (humidity / threshold) %}
            {# Option 2 - On or Off #}
            {% set multiplier = 1.0 %}
          {% else %}
            {% set multiplier = 0.0 %} {# It's too wet, turn off #}
          {% endif %}

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