My Garden Irrigation

Here is a little more info. If I evaluate this template in the automation with the “Ignore Schedule if Raining” option UNCHECKED, it returns “true”.

{% if is_state('input_boolean.irrigation_ignore_schedule_if_raining', 'off') or 
                trigger.entity_id == 'input_boolean.irrigation_cycle3_running' %}
            True
          {% elif states('input_boolean.irrigation_ignore_schedule_if_raining') == 'on' and
                  states(states('input_text.irrigation_external_sensor_raining_now')) == 'off' %}
            True
          {% else %}
            False
          {% endif %}

But…when I enable the option and re-evaluate the template, I get this error:
UndefinedError: ‘trigger’ is undefined

Yes, there is no trigger in the Dev Tools Template page!

Crap:( All this hassle for nothing afterall:(
I somehow automatically assumed it can control a main valve (open it after the irrigation valves & close it before - to avoid water hammer) & also to run multiple zones at the same time - I guess the later would be doable with template switches, but that’s not very elegant…
Thanks anyway.

For now I have changed the template to the following since I never utilize cycle 3:

{% if states('input_boolean.irrigation_ignore_schedule_if_raining') == 'off' %}
            True
          {% elif states('input_boolean.irrigation_ignore_schedule_if_raining') == 'on' and
                  states(states('input_text.irrigation_external_sensor_raining_now')) == 'off' %}
            True
          {% else %}
            False
          {% endif %}

I can now verify it evaluates correctly and gives a True/False answer. This seems to have also fixed the schedule cycle and it starts as it should. Any idea why that line would make the template invalid? The “input_boolean.irrigation_cycle3_running” entity is valid and returns a state of “off”.

Hello, i`m having some problems with the instalation,i have have installed the last version and have Home Assistant 2021.7.4, i used 1 sonoff 4ch pro for 4 zones with tasmota, in manual mode they work perfectely , when used schedule dont work.

Have installed the telegram and work i can send messeges from service, then when i tried to configurat with the irrigation, i follow some publication from where i dont now wich part i have to put on scripts, and on automation, please can someone help me.
I follow this post

 #===================
#=== Input Booleans
#===================
input_boolean:
  irrigation_notify_user1:
    name: Notify Edoardo of events
    icon: mdi:message-text-outline

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

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

  #===================================================
  #=== Notify about irrigation events
  #===================================================
  - alias: Irrigation Notify About Irrigation Events User1
    trigger:
      - platform: state
        entity_id:
        - input_boolean.irrigation_cycle1_running
        - input_boolean.irrigation_cycle2_running

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

    action:
      - service: telegram_bot.send_message
        data_template:
          target: !secret chat_id_edoardo
          title: '*IRRIGATION SYSTEM*'
          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 %}
  
  #===================================================
  #=== Notify about irrigation events
  #===================================================
  - alias: Irrigation Notify About Irrigation Events User2
    trigger:
      - platform: state
        entity_id:
        - input_boolean.irrigation_cycle1_running
        - input_boolean.irrigation_cycle2_running

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

    action:
      - service: telegram_bot.send_message
        data_template:
          target: !secret chat_id_sabrina
          title: '*IRRIGATION SYSTEM*'
          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 %}

this is my telegram config

Why are your Chat ID and API secrets commented out? I would assume that is why the automation is not working. Remove the # from the !secret values and then remove spaces to align properly. I do not use Telegram but looking through some documentation, this appears to be the way it should be configured.

configuration.yaml

# Example configuration.yaml entry for the Telegram Bot
telegram_bot:
  - platform: polling
    api_key: !secret telegram_api_token
    allowed_chat_ids:
      - !secret telegram_chat_id

# Example configuration.yaml entry for the notifier
notify:
  - platform: telegram
    name: Roberto
    chat_id: !secret telegram_chat_id

irrigation_notifications.yaml

action:
      - service: notify.Roberto
        data_template:
          title: '*IRRIGATION SYSTEM*'

Hello jgosnell i have erased my char id and api The ! Secret was in the code that i copy in the fórum.

Hi @klogg!

I got the same error like others with the WiFi signal, but I had changed the code, like you sad before. The error looks like this:

ButtonCardJSTemplateError: TypeError: entity is undefined in 'var statestr = (entity === undefined || entity.state === undefined) ? 'undefined' : entity.state; ...'

tap_action:
  action: fire-dom-event
  browser_mod:
    command: popup
    title: Irrigation Controller
    card:
      type: vertical-stack
      cards:
        - type: markdown
          content: >-
            Enter the name of the sensor for your irrigation controller WiFi
            signal strength.


            Leave blank to reset to default.
          card_mod:
            style: |
              ha-card {
                font-family: {{ states('input_text.irrigation_ui_font_family') }};
                font-size: 16px;
              }
        - type: entities
          entities:
            - entity: input_text.irrigation_external_sensor_controller_wifi
              name: Sensor Name
            - entity: input_number.irrigation_controller_offline_wait
              name: Seconds To Wait When Offline
            - type: section
          card_mod:
            style: |
              ha-card {
                font-family: {{ states('input_text.irrigation_ui_font_family') }};
              }
        - type: markdown
          content: You can disable the switches to prevent irrigation while testing.
          card_mod:
            style: |
              ha-card {
                font-family: {{ states('input_text.irrigation_ui_font_family') }};
                font-size: 16px;
              }
        - type: entities
          entities:
            - entity: input_boolean.irrigation_disable_switches
          card_mod:
            style: |
              ha-card {
                font-family: {{ states('input_text.irrigation_ui_font_family') }};
              }
    style:
      $: |
        .mdc-dialog .mdc-dialog__container .mdc-dialog__surface {
            font-family: {{ states('input_text.irrigation_ui_font_family') }};
          }
type: custom:button-card
group_expand: false
hold_action:
  action: none
double_tap_action:
  action: none
layout: vertical
size: 30%
color_type: icon
show_name: true
show_state: true
show_icon: true
show_units: true
show_label: false
show_entity_picture: false
show_live_stream: false
card_size: 3
entity: sensor.esphome_irrigation_controller_wifi_signal
name: |
  [[[
    var statestr = (entity === undefined || entity.state === undefined) ? 'undefined' : entity.state;
    var unit_om = (statestr != 'undefined' && entity.attributes.unit_of_measurement) ? entity.attributes.unit_of_measurement : '';
    return 'Irrigation Controller' + ' (' + entity.state + ' ' + unit_om + ')'
  ]]]
icon: |
  [[[
    return (entity === undefined || entity.state == 'unavailable') ? 'mdi:wifi-off' : 'mdi:wifi';
  ]]]
state_display: |
  [[[
    var statestr = (entity === undefined || entity.state === undefined) ? 'undefined' : entity.state;
    var unit_om = entity.attributes.unit_of_measurement ? entity.attributes.unit_of_measurement : '';
    return statestr + ' ' + unit_om;
  ]]]
styles:
  grid:
    - grid-template-areas: '"i n s"'
    - grid-template-columns: 15% auto 5%
    - grid-template-rows: 1fr
  card:
    - font-family: |
        [[[
          return states['input_text.irrigation_ui_font_family'].state
        ]]]
    - font-size: 15px
    - padding: 0em 1.5em 0em 0em
    - background: none
    - box-shadow: none
  icon:
    - color: var(--paper-item-icon-color)
  name:
    - justify-self: start
state:
  - value: unavailable
    styles:
      icon:
        - color: var(--accent-color)
        - animation: blink 2s ease infinite
      state:
        - color: var(--accent-color)
        - animation: blink 2s ease infinite
default_color: var(--primary-text-color)
color_off: var(--paper-item-icon-color)
color_on: var(--paper-item-icon-active-color)
lock:
  enabled: false
  duration: 5
  unlock: tap

Can you help me were is the problem?

Hello the firtst parte is done, the second is in the file /config/packages/Garden Irrigation/irrigation_notifications.yaml???

Yes it is. That is the action area of the automation you are trying to edit.

I’m a disgrace on this :pensive::pensive::pensive:, i past this code

      - service: notify.Roberto
        data_template:
          title: '*IRRIGATION SYSTEM*'on```


on /config/packages/Garden Irrigation/irrigation_notifications.yaml and now give one error. 

Package irrigation_notifications setup failed. Component action Integration 'action' not found.

Is it all on one line like that or did your formatting get off during the copy and paste? It cannot all be on the same line. You need to format it properly. Here is an example of my automation but with the service changed to what you would need.

alias: Irrigation Notify When Cycle Starts Or Stops
    trigger:
    - platform: state
      entity_id:
      - input_boolean.irrigation_cycle1_running
      - input_boolean.irrigation_cycle2_running
    condition:
      - condition: state
        entity_id: input_boolean.irrigation_notify_user1
        state: 'on'
    action:
    - service: notify.Roberto
      data_template:
        title: '*IRRIGATION SYSTEM*'
        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' %}
            I thought you'd like to know that the {{ cycle_name }} has just started.
            The total watering time should be about {{ (states('sensor.irrigation_' ~ cycle ~ '_duration_in_seconds') | int / 60) | int }} minutes but I'll let you know when it has finished.
            I hope you're having a lovely holiday!
          {% else %}
            All the {{ cycle_name }} watering is done.
          {% endif %}

I hope that makes a little more sense.

Sorry about this, i gonna put all my questions, and what i have done to try finish this.

1- I put this code with api key and chat id on config.yaml, and was working

#                                                  #
#             Telegram Bot                         #
#                                                  #
####################################################
# Telegram Bot
telegram_bot:
  - platform: polling
    api_key: 
    allowed_chat_ids:
      - 

notify:
  - platform: telegram
    name: Roberto 
    chat_id:   

Next i have completed the file on /config/packages/Garden Irrigation/irrigation_notifications.yaml

#=== 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:

  #========================================================================
  #=== Persistant notification when the Irrigation Controller goes Offline
  #========================================================================
  - alias: Irrigation Notify When Controller Goes Offline
    id: irrigation_notify_when_controller_goes_offline
    mode: queued
    trigger:
      - platform: state
        entity_id: sensor.esphome_irrigation_controller_wifi_signal
        to: unavailable

      - platform: state
        entity_id: sensor.esphome_irrigation_controller_wifi_signal
        from: unavailable

    action:
      - service: script.notify.Roberto
        data_template:
          show: true
          notification_id: >
            notifications_{{ now() | string }}
          title: >
            Irrigation Controller
          message: >
            sensor.esphome_irrigation_controller_wifi_signal
            Signal Strength is {{ states('sensor.esphome_irrigation_controller_wifi_signal') | upper }}


  #=========================================
  #=== Notfy about interrupted cycle due to 
  #=== Irrigation Controller WiFi Signal 
  #=========================================
  - alias: Irrigation About Cycle WiFi Interruption
    id: irrigation_notify_when_on_holiday_cycle_wifi_interruption
    trigger:
      - platform: state
        entity_id: sensor.esphome_irrigation_controller_wifi_signal
        to: unavailable

      - platform: state
        entity_id: sensor.esphome_irrigation_controller_wifi_signal
        from: unavailable

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

      - condition: or
        conditions:
          - condition: state
            entity_id: input_boolean.irrigation_cycle1_running
            state: 'on'
          - condition: state
            entity_id: input_boolean.irrigation_cycle2_running
            state: 'on'
            
    action:
      - service: script.notify.Roberto
        data_template:
          title: '* Sistema de Rega*'
          tell: >
            {% set user1 = states('input_text.notifications_user1_name') | lower %}
            {% set user2 = states('input_text.notifications_user2_name') | lower %}
            {% if is_state('input_boolean.irrigation_notify_user1', 'on') and
                  is_state('input_boolean.irrigation_notify_user2', 'on') %}
              {{ user1 ~ '_and_' ~ user2 }}
            {% elif is_state('input_boolean.irrigation_notify_user1', 'on') %}
              {{ user1 }}
            {% else %}
              {{ user2 }}
            {% endif %}
          type: app_notification
          message: >
            {% if trigger.to_state.state == 'unavailable' %}
              Irrigation Warning:
              
              Controller is OFFLINE ({{now().strftime('%H:%M:%S')}}).
              Waiting for reconnection...
            {% else %}
              Irrigation Information:
              
              Controller is back ONLINE ({{now().strftime('%H:%M:%S')}}).
            {% endif %}


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

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

    action:
      - service: script.notify.Roberto
        data_template:
          title: '* Sistema de Rega*'
          tell: >
            {% set user1 = states('input_text.notifications_user1_name') | lower %}
            {% set user2 = states('input_text.notifications_user2_name') | lower %}
            {% if is_state('input_boolean.irrigation_notify_user1', 'on') and
                  is_state('input_boolean.irrigation_notify_user2', 'on') %}
              {{ user1 ~ '_and_' ~ user2 }}
            {% elif is_state('input_boolean.irrigation_notify_user1', 'on') %}
              {{ user1 }}
            {% else %}
              {{ user2 }}
            {% endif %}
          type: app_notification
          message: >
            {% if trigger.entity_id == 'input_boolean.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' %}
              I thought you'd like to know that the {{ cycle_name }} has just started.


              The total watering time should be about {{ (states('sensor.irrigation_' ~ cycle ~ '_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 %}

The file stay there or have to copy this to automations?

That file stays there. i do not think your “action” should be script.notify.Roberto though. According to the telegram docs I saw, you should only need notify.Roberto as an action.

Hi!

Does anyone know how to delete this completely? I’ve tried to delete all the files & config lines, but still the automations are there & can’t get rid of them. send help plz!:smiley:

Good evening everyone, I tried to replace the new release with the old one but I couldn’t get it to go … so I put the old one back up but it has a problem with the manual start and stop and that is it gives me this error:
Fallita chiamata a servizio script/irrigation_cancel_irrigation . not a valid value for dictionary value @ data[‘entity_id’]

How can I solve it?
Thanks

Can you add a master valve? A switch, opened before every run… That would be perfect :smiley:

Hmm any ideas why i have no history? what do i need to check?

Have you performed the steps related to the “Recorder” settings in the Pre-req file?
Prerequisites.md

That would be my first place to look.

my config:

recorder:
  purge_keep_days: 7
  auto_purge: true
  commit_interval: 1
  include:
    entity_globs:
      - sensor.netatmo_aussensensor_temperature
      - sensor.bodenfeuchtesensor_soil_moisture
      - sensor.netatmo_regenmesser_rain_today
      - irrigation_sensor_zone1_switch
      - irrigation_sensor_zone2_switch
      - irrigation_sensor_zone3_switch
      - irrigation_sensor_zone4_switch
      - irrigation_sensor_zone5_switch
      - irrigation_sensor_zone6_switch
      - irrigation_sensor_zone7_switch
      - irrigation_sensor_zone8_switch
      - switch.rasen1
      - switch.rasen2
      - switch.rasen3
      - switch.rasen4
      - switch.vorgarten
      - switch.terrasse
      - switch.gartenlinks
      - switch.gartenrechts
      - sensor.irrigation_sensor_forecast_high_temp
      - sensor.irrigation_sensor_current_temp
      - sensor.weather_api_forecast_total_rain_today
      - sensor.irrigation_sensor_rainfall_today
      - binary_sensor.above_horizon
  exclude:
    entity_globs:
      input_number.irrigation*

Dang, i think i miss “sensor.” on each switch…