Use two triggers in your automation and assign each a different trigger ID. In the action part you can use a choose or if condition that checks which trigger ID was fired and execute your actions accordingly.
alias: Tado device connection
trigger:
- platform: state
entity_id:
- binary_sensor.bathroom_trv_connection_state
- binary_sensor.bedroom_trv_master_connection_state
- binary_sensor.bedroom_trv_slave_connection_state
- binary_sensor.front_room_thermostat_connection_state
- binary_sensor.front_room_trv_connection_state
- binary_sensor.2_bedroom_trv_connection_state
- binary_sensor.hall_trv_connection_state
- binary_sensor.kitchen_trv_connection_state
- binary_sensor.spare_room_trv_connection_state
- binary_sensor.tado_boiler_control_connection_state
- binary_sensor.toilet_trv_connection_state
id: lost device link
from: "on"
to: "off"
for:
hours: 0
minutes: 40
seconds: 0
- platform: state
entity_id:
- binary_sensor.bathroom_trv_connection_state
- binary_sensor.bedroom_trv_master_connection_state
- binary_sensor.bedroom_trv_slave_connection_state
- binary_sensor.front_room_thermostat_connection_state
- binary_sensor.front_room_trv_connection_state
- binary_sensor.2_bedroom_trv_connection_state
- binary_sensor.hall_trv_connection_state
- binary_sensor.kitchen_trv_connection_state
- binary_sensor.spare_room_trv_connection_state
- binary_sensor.tado_boiler_control_connection_state
- binary_sensor.toilet_trv_connection_state
id: device link back
from: "off"
to: "on"
for:
hours: 0
minutes: 10
seconds: 0
condition:
- condition: state
entity_id: input_boolean.dnd_person1
state: "off"
action:
- choose:
- conditions:
- condition: trigger
id: lost device link
- condition: state
entity_id: input_boolean.do_not_disturb_on_off
state: "off"
sequence:
- if:
- condition: state
entity_id: input_boolean.telegram_notifications
state: "on"
then:
- service: notify.telegram_person1
data_template:
message: >-
WARNING {{ trigger.to_state.attributes.friendly_name }}
shows a disconnection problem.
- conditions:
- condition: trigger
id: device link back
sequence:
- if:
- condition: state
entity_id: input_boolean.telegram_notifications
state: "on"
then:
- service: notify.telegram_person1
data_template:
message: >-
NOTICE - {{ trigger.to_state.attributes.friendly_name }}
shows to be back on the network.
default: []
trace:
stored_traces: 10
mode: single
This is part of a much bigger automation that reboots network devices etc, so I have stripped out only the parts that I think would be relevant to your scenario. Hope it helps in some way.
2023-02-03 11:20:54.373 ERROR (MainThread) [homeassistant.components.automation] Automation with alias 'Velux regen detectie' could not be validated and has been disabled: extra keys not allowed @ data['condition'][0]['id']. Got 'on'
I think that depends on your view point and more importantly you technical ability.
I personally don’t find using trigger ID’s and/or choose options to be cumbersome.
I find them to be a very useful tool for anyone that relies on the Ui for creating automations and scripts.
You can ofcourse minimise most of your automations and/or scripts with templates but I always (maybe wrongly) assume that when people ask questions about if or how to combine multiple automations they are most likely using the Ui and even more likely to have limited yaml and/or template knowledge.
Also from a new or novice user point of view I cant help but think so many of the answers given in yaml / templates are simply cut and pasted by the OP’s and this can lead to limited knowledge improvement therefore leading to them having to ask next time they want to achieve similar results.
Maybe I am over thinking this as with all things HA there are always multiple ways to achieve the same end results, but I always try to pitch any solutions to the somewhat assumed level of knowledge shown by the OP.
Having said all that, your solution is of course elegant
can you also apply the same trick for my xiaomi automation? because there i have a condition and a state change from on/off or off/on … its a mixed setup
With random id and “better” indentation. Uses a template in the message. The from and to lists are to stop triggers if/when it goes unknown or unavailable.