janbenes
(Jan Benes)
October 24, 2023, 2:28pm
1
Hello. Let’s have automation with multiple triggers, which is triggered when either of device A, B or C becomes unavailable. The automation triggers sending message, like "Device is not available.
How to compose message so it sends name of device that triggered the automation please?
Thanks, Jan
tom_l
October 24, 2023, 2:40pm
2
massage: "{{ trigger.entity_id }} is {{ trigger.to_state.state }}"
See here for more:
1 Like
I don’t think there’s a way to do it with a single message (I’m sure somebody will correct me ).
The simplest way is probably to assign an id to each trigger, then have a “choose” action with a separate message assigned to each id. For example:
alias: "[Alarm] [SMS] Smoke detected"
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.nest_protect_bedroom_smoke_status
to: "on"
id: bedroom
- platform: state
entity_id:
- binary_sensor.nest_protect_living_room_smoke_status
to: "on"
id: living_room
- platform: state
entity_id:
- binary_sensor.nest_protect_den_smoke_status
to: "on"
id: study
condition: []
action:
- choose:
- conditions:
- condition: trigger
id:
- bedroom
sequence:
- service: notify.tablet
data:
message: >-
{{ as_timestamp(now()) | timestamp_custom('%I:%M%p', true) }}:
Smoke detected in bedroom
data:
priority: normal
device: SAMSUNG SM-T505
- conditions:
- condition: trigger
id:
- living_room
sequence:
- service: notify.tablet
data:
message: >-
{{ as_timestamp(now()) | timestamp_custom('%I:%M%p', true) }}:
Smoke detected in living room
data:
priority: normal
device: SAMSUNG SM-T505
- conditions:
- condition: trigger
id:
- study
sequence:
- service: notify.tablet
data:
message: >-
{{ as_timestamp(now()) | timestamp_custom('%I:%M%p', true) }}:
Smoke detected in study
data:
priority: normal
device: SAMSUNG SM-T505
default:
- service: script.do_nothing
data: {}
- service: script.all_on
data: {}
mode: single