This is not an easy feat when you want to treat every device tracker as a separate trigger. Your best option would be to create a template trigger for each device tracker:
You can use the template designer to write it for you, and shrink it down to 3 lines by changing your for.
trigger:
{%- set trackers = [
'device_tracker.plug_dishwasher',
'device_tracker.plug_washing',
'... add more trackers here in quotes followed by comma, like this row ...',
] %}
{%- for tracker in trackers %}
- platform: template
value_template: "{% raw %}{{ not is_state('{% endraw %}{{ tracker }}{% raw %}', 'home') }}{% endraw %}"
for: "00:60:00"
{%- endfor %}
- alias: Always-on devices dead 2
initial_state: 'on'
trigger:
{%- set trackers = [
'device_tracker.plug_dishwasher',
'device_tracker.plug_washing',
] %}
{%- for tracker in trackers %}
platform: template
value_template: "{% raw %}{{ not is_state('{% endraw %}{{ tracker }}{% raw %}', 'home') }}{% endraw %}"
for: "00:60:00"
action:
service: notify.ha_telegram
data_template:
message: "{{ trigger.to_state.attributes.friendly_name }} is now {{ trigger.to_state.state }} since {{ trigger.for }} minutes - 2"
{%- endfor %}
but I get
Failed config
General Errors:
- Error loading /config/configuration.yaml: while scanning for the next token
found character '%' that cannot start any token
in "/config/automation.yaml", line 109, column 2
Line 109 being {%- set trackers = [
Is there a documentation about for loops against arrays in HA ?