Hi @klogg, i have see now that you have upload the version2 with some correction. I have rewrite the garden_irrigation.yaml file for receive notifications in telegram.
This is my code:
#===================
#=== 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 %}
I have also fixed many other small errors, including: cycle 3 could not be edited from the interface, the valves turned on but did not turn off (I rewrite the template), I added the pulsetime for each valve and I removed the master valve which I do not have, fixed some settings that were not seen.
I have yet to take a look at the new changes you’ve uploaded and the temperature and rainfall part because I don’t have smartweather sensors in my area.