I have installed two Sonoff CH4 Pro devices with Tasmota for my irrigation system. I have integrated them into Home Assistant via MQTT. I can turn the individual relays on and off using the dashboard. However, I want to control the duration of an irrigation sequence using a timer. For this purpose, I have placed a timer on the dashboard. An automation is supposed to automatically switch off the irrigation after the set time. Unfortunately, the automatic shut-off is not working.
My entity in YAML:
- name: "Bewässerung Rasen vorne"
unique_id: sonoff_bewaesserung_1
command_topic: "cmnd/tasmota_E2C7C2/POWER1"
state_topic: "stat/tasmota_E2C7C2/POWER1"
payload_on: "ON"
payload_off: "OFF"
state_on: "ON"
state_off: "OFF"
qos: 1
retain: false
my automation:
- id: '1743298765001'
alias: Bewässerung automatisch ausschalten nach Timer
description: Schaltet das Bewässerungsrelais nach x Minuten aus, basierend auf dem aktuellen Timerwert
mode: parallel
trigger:
- platform: state
entity_id:
- switch.sonoff_bewaesserung_1
- switch.sonoff_bewaesserung_2
- switch.sonoff_bewaesserung_3
- switch.sonoff_bewaesserung_4
- switch.sonoff_bw2_relais_1
- switch.sonoff_bw2_relais_2
- switch.sonoff_bw2_relais_3
- switch.sonoff_bw2_relais_4
to: 'on'
condition:
- condition: template
value_template: >
{{ states('input_number.timer_bewasserung') not in ['unknown', 'unavailable', '' ] }}
action:
- variables:
ziel_relais: '{{ trigger.entity_id }}'
dauer: '{{ states("input_number.timer_bewasserung") | int }}'
- service: system_log.write
data:
message: "Starte Bewässerung an {{ ziel_relais }} für {{ dauer }} Minuten"
level: info
- delay:
minutes: "{{ states('input_number.timer_bewasserung') | int }}"
- service: switch.turn_off
target:
entity_id: '{{ ziel_relais }}'
I can’t figure out why the “unique_id: sonoff_bewaesserung_1” is not switching off automatically. Can you help me?