My Garden Irrigation

This is something you’ve added on to the package so the question really doesn’t belong here, and in any case there is not nearly enough information to be sure.

But first, try…

  - !include
     - pump.yaml
     - entity: automation.outside_pump_master_control_switch

And second, why use an !include at all? The included yaml is longer than the yaml to do the include.

Notification… since the last breaking change for the life of me i cant get this to work, tried a few variations with the service: notify.etc to no avail, if anyone got a simple working code they are willing to share would be great, also here is where i am so far.

PS: Nearly growing season :slight_smile:


#===================
#=== Input Booleans
#===================
input_boolean:

  irrigation_notify_user1:
    name: Notify User1 of events
    icon: mdi:message-text-outline

  irrigation_notify_user2:
    name: Notify User2 of events
    icon: mdi:message-text-outline



#================
#=== Automations
#================
automation:

#========================================
  #=== Notify when a cycle starts or stops
  #========================================
  - alias: Irrigation Notify When Cycle Starts Or Stops
    id: irrigation_notify_when_cycle_starts_or_stops
    trigger:
      - platform: state
        entity_id: input_boolean.irrigation_cycle1_running
        id: cycle1

      - platform: state
        entity_id: input_boolean.irrigation_cycle2_running
        id: cycle2

    condition:
      - or:
          - condition: state
            entity_id: input_boolean.irrigation_notify_user1
            state: 'on'
          - condition: state
            entity_id: input_boolean.irrigation_notify_user2
            state: 'on'         

    variables:
      message: >
        {% set cycle_name = states('input_text.irrigation_' ~ trigger.id ~ '_name') %}
        {% if trigger.to_state.state == 'on' %}
          I thought you'd like to know that the {{ cycle_name }} has just started.
          The total watering time should be about {{ (states('sensor.irrigation_' ~ trogger.id ~ '_duration_in_seconds') | int / 60) | int }} minutes but I'll let you know when it has finished.
        {% else %}
          All the {{ cycle_name }} watering is done.
        {% endif %}
    action:
      - if:
          condition: state
          entity_id: input_boolean.irrigation_notify_user1
          state: 'on'
        then:
          - service: notify.persistent_notification
            data_template:
              tell: >
                {{ states('input_text.notifications_user1_name') | lower }}
              type: app_notification
              title: 🌼 Irrigation 🌼
              message: >
                {{ message }}
      - if:
          condition: state
          entity_id: input_boolean.irrigation_notify_user2
          state: 'on'
        then:
          - service: notify.persistent_notification
            data_template:
              tell: >
                {{ states('input_text.notifications_user2_name') | lower }}
              type: app_notification
              title: 🌼 Irrigation 🌼
              message: >
                {{ message }}


You seem to be mixing things up…

You are using notify.persistent_notification while appearing to want to send an app notification.

Apart form that it looks ok.

Something like:-

      - service: >
          notify.mobile_app_{{ states('input_text.notifications_user1_name') | lower }}_phone
        data:
          title: 🌼 Irrigation 🌼
          message: >
            {{ message }}

Should work. I think…

(Did I give you my notification code? Because tell and type come from that :wink: )

I tried this but no joy, does it look correct ? and yes it came from your gitup which i tried to modify.

  #========================================
  #=== Notify when a cycle starts or stops
  #========================================
  - alias: Irrigation Notify When Cycle Starts Or Stops
    id: irrigation_notify_when_cycle_starts_or_stops
    trigger:
      - platform: state
        entity_id: input_boolean.irrigation_cycle1_running
        id: cycle1

      - platform: state
        entity_id: input_boolean.irrigation_cycle2_running
        id: cycle2

    condition:
      - or:
          - condition: state
            entity_id: input_boolean.irrigation_notify_user1
            state: 'on'
          - condition: state
            entity_id: input_boolean.irrigation_notify_user2
            state: 'on'         

    variables:
      message: >
        {% set cycle_name = states('input_text.irrigation_' ~ trigger.id ~ '_name') %}
        {% if trigger.to_state.state == 'on' %}
          I thought you'd like to know that the {{ cycle_name }} has just started.
          The total watering time should be about {{ (states('sensor.irrigation_' ~ trogger.id ~ '_duration_in_seconds') | int / 60) | int }} minutes but I'll let you know when it has finished.
        {% else %}
          All the {{ cycle_name }} watering is done.
        {% endif %}
    action:
      - if:
          condition: state
          entity_id: input_boolean.irrigation_notify_user1
          state: 'on'
        then:
          - service: >
              notify.mobile_app_{{ states('input_text.notifications_user1_name') | lower }}_phone_7
            data:
              title: 🌼 Irrigation 🌼
              message: >
                {{ message }}      
      - if:
          condition: state
          entity_id: input_boolean.irrigation_notify_user2
          state: 'on'
        then:
          - service: >
              notify.mobile_app_{{ states('input_text.notifications_user1_name') | lower }}iphone_7
            data:
              title: 🌼 Irrigation 🌼
              message: >
                {{ message }} 

Yes but are your notify services correct?

1 Like

Ok im getting there i can recieve a message with this config below with out a message imbedded in the text, it’s when i uncomment the section with variables it stops working, so i guess its the way its formatted / worded in that section maybe, but as stated i’m getting there.

Thanks Klogg for taking time out to help with this :slight_smile:

  - alias: Irrigation Notify When Cycle Starts Or Stops 
    id: irrigation_notify_when_cycle_starts_or_stops
    trigger:
      - platform: state
        entity_id: input_boolean.irrigation_cycle1_running
        id: cycle1

      - platform: state
        entity_id: input_boolean.irrigation_cycle2_running
        id: cycle2

    condition:
      - or:
          - condition: state
            entity_id: input_boolean.irrigation_notify_user1
            state: 'on'
          - condition: state
            entity_id: input_boolean.irrigation_notify_user2
            state: 'on'         

    # variables:
    #   message: >
    #     {% set cycle_name = states('input_text.irrigation_' ~ trigger.id ~ '_name') %}
    #     {% if trigger.to_state.state == 'on' %}
    #       I thought you'd like to know that the {{ cycle_name }} has just started.
    #       The total watering time should be about {{ (states('sensor.irrigation_' ~ trogger.id ~ '_duration_in_seconds') | int / 60) | int }} minutes but I'll let you know when it has finished.
    #     {% else %}
    #       All the {{ cycle_name }} watering is done.
    #     {% endif %}
    action:
      - if:
          condition: state
          entity_id: input_boolean.irrigation_notify_user1
          state: 'on'
        then:
          - service: notify.mobile_app_iphone_7
            data_template:
              title: 🌼 Irrigation 🌼
              message: >
                {{ message }}  

Try something like:

I thought you'd like to know that the {{ states('input_text.irrigation_cycle' ~ trigger.id ~ '_name' }}

You caught me on a good day :slight_smile:

1 Like

No go with that change it throws a wobbly in the config, ill keep on trying as i know i’m near to getting this working, but now for some lunch.

Try I thought you'd like to know that {{ trigger.id }} has finished

If that works, take it from there

Okay here we go for anyone else, i have now got this working in one automation, i just trolled around and put pieces of the code together, at first i was using two automations for user 1 and 2 then breaking the code down from there, not without help firstly from Klogg thanks once again.

And to be honest i’m not sure what it all means in the messages section or how it works, as i’m a copy and paste type of person :slight_smile: but it works fine on my Iphone getting the start and ending notifications (you will need to set up your services the way you receive notifications if not using a iphone), but as stated it works for me.

#========================================
  #=== Notify when a cycle starts or stops
  #========================================
  - alias: Irrigation Notify When Cycle Starts and stops
    id: irrigation_notify_when_cycle_starts
    trigger:
      - platform: state
        entity_id: input_boolean.irrigation_cycle1_running
        id: cycle1

      - platform: state
        entity_id: input_boolean.irrigation_cycle2_running
        id: cycle2

    condition:
      - or:
          - condition: state
            entity_id: input_boolean.irrigation_notify_user1
            state: 'on'
          - condition: state
            entity_id: input_boolean.irrigation_notify_user2
            state: 'on'  
    variables:
      message: >
        {% if trigger.entity_id == 'input_boolean.irrigation_cycle1_running' %}
          {% set cycle = 'cycle1' %}
        {% else %}
          {% set cycle = 'cycle2' %}
        {% endif %}

        {% set cycle_name = states('input_text.irrigation_' ~ cycle ~ '_name') %}

        {% if trigger.to_state.state == 'on' %}
          {% set ns = namespace(total_time = 0) %}
          {% for zone in states.input_number if zone.entity_id.startswith('input_number.irrigation_' ~ cycle ~ '_zone') and
                                                zone.entity_id.endswith('_duration') %}
            {% if is_state('input_boolean.irrigation_' ~ cycle ~ '_zone' ~ loop.index ~ '_skip', 'off') %}
                {# Adjust for rainfall #}
                {% if is_state('input_boolean.irrigation_' ~ cycle ~ '_adjust_for_rainfall', 'on') %}
                  {% set ns.total_time = ns.total_time * states('input_number.irrigation_rainfall_multiplier') | float %}
                {% elif is_state('input_boolean.irrigation_' ~ cycle ~ '_adjust_for_temperature', 'on') %}
                  {% set ns.total_time = ns.total_time * states('input_number.irrigation_temp_multiplier') | float %}
                  {% else %}
                  {% set ns.total_time = ns.total_time + states(zone.entity_id) | float %}
                {% endif %}
              {% endif %} 
          {% endfor %}
          
          I thought you'd like to know that the {{ cycle_name }} cycle has just started.


        The total watering time should be about {{ (ns.total_time * 60) | timestamp_custom('%H:%M', false) }} but I'll let you know when it has finished.
        {% else %}
          All the {{ cycle_name }} cycle watering is done.
        {% endif %}


    action:
      - if:
          condition: state
          entity_id: input_boolean.irrigation_notify_user1
          state: 'on'
        then:
          - service: notify.mobile_app_iphone_7
            data_template:
              title: 🌼 Irrigation 🌼
              message: >
                {{ message }}
      - if:
          condition: state
          entity_id: input_boolean.irrigation_notify_user2
          state: 'on'
        then:
          - service: notify.mobile_app_iphone_7
            data_template:
              title: 🌼 Irrigation 🌼
              message: >
                {{ message }}

Hi everyone, unfortunately I can’t get the automatic irrigation programming to work.
Nothing happens at the scheduled time, while if I activate the sprinklers manually everything works as it should.
Could someone help me understand why the automatic programming isn’t working?
Thank you very much!

Alessandro

At the right of every zone, you have to check the option “Every Day” if you want to irrigate every day, otherwise you have to check the day under the name of the zone when you want to irrigate.
Like in “Retro Zona A”.
Let me know if it works.

Hi @shakin89,
i wanted to irrigate only Retro Zona A that’s why I selected “Sat”. When it arrives at the set time, it does nothing. But is there a project log file to understand where the error is?

Do you have a sensor for rain? if yes, then if it’s raining, the irrigation won’t start.
You can look in the system logs. It should logs all the events there.
Other reason for not watering, doesn’t come in mind.
If it works in manual mode, then it should even work in scheduled mode.

Yes, I have that sensor but disabling the “adjust with rain” option should still make it work. This situation is incredible. Everything works if I launch the manual mode. Nothing works if I launch the schedule function.
I also tried deleting and reinstalling everything but without success.
Same problems.
Thank you anyway for your support.
Regards,

Alessandro

@klogg

Finally, I have found my problem.
I hadn’t created the binary_sensor related to my rain sensor.

The issue is that the file uses the off/on condition to start watering but this related file (input_text.irrigation_external_sensor_raining_now) shows as the image below:

and not on or off.

The question is:
How should i do to make the result on or off?

Thanks in advance.
Regards,

Alessandro

The option adjust for rainfall only adjust the quantity of water if will rain or has rained.
If you don’t have a physical rain sensor, then leave the field blank. The binary_sensor.raining_now should have no effect if it doesn’t exist.
Or from the helpers menu, create a binary_sensor.raining_now that you adjust manually.

I’ve a weather station on my roof and i’ve also rain sensor.
I’ve already created a binary sensor for it but the result isn’t on or off but the name of the sensor …and watering doesn’t start!
Look the image above.

Regards,

Alessandro

The image above reports the results of the input_text.irrigation_external_sensor_raining_now, which should be exactly the name of your binary sensor.
You have to create a binary_sensor from the weather station, if you still don’t have it. A binary sensor can have only two values, on, or off.
in the text box, you have to put the name of the sensor you created, mine is called binary_sensor.stazione_meteo_raining
Check from the developer tools if the binary sensor has a value of on or off and then try to irrigate.

I’ve already done it:

and its results is correct: OFF.

but if i put the name of binary sensor in own field like this image:

the results of related input_text file is not “off” but the name of sensor.

This results blocked watering because the condition below is not “off”, “unknow” or “unavailable” but the name of sensor :slight_smile:

I hope I have explained myself well.
Regards,

Alessandro