Get trigger location in Automation

Hello Everyone,
I would like to setup an automation that sends me an alert when one of my room thermostat is disconnected but with the name of the room, can you help me?

trigger:
  - type: not_connected
    platform: device
    device_id: 47cb711
    entity_id: binary_sensor.va0286_connection_state
    domain: binary_sensor
    for:
      hours: 0
      minutes: 10
      seconds: 0
      milliseconds: 0
- type: not_connected
    platform: device
    device_id: a6b41d1e
    entity_id: binary_sensor.va11445_connection_state
    domain: binary_sensor
    for:
      hours: 0
      minutes: 10
      seconds: 0
      milliseconds: 0
....
action:
  - service: notify.mobile_app_...
    data:
      title: Vanne déconnectée {{ trigger.entity_id }}
      message: VĂ©rifier les piles des vannes {{ trigger.entity_id }}

I’m sure there is a solution about it

This works but the state “unavailable” has a light delay to HA:

alias: 'Test: unavailable'
description: ''
trigger:
  - platform: state
    entity_id: sensor.YOURSENSOR
    to: unavailable
    for:
      hours: 0
      minutes: 0
      seconds: 10
condition: []
action:
  - service: notify.mobile_YOUR_PHONE
    data:
      message: YOUR_MESSAGE
mode: single

Try out this:


action:
  - service: notify
.
    data:
      title: >-
        Vanne déconnectée {{ trigger.entity_id }} ({{
        area_name(trigger.entity_id) }})
      message: >-
        VĂ©rifier les piles des vannes {{ trigger.entity_id }} ({{
        area_name(trigger.entity_id) }})

I’ve used persistant notification service for testing purposes)

P.S.: KĂŒche = kitchen

3 Likes

That’s working perfectly, thank you very much.
Is there any webpage i can find these kind of function ? (area_name in this case) ?

Have fun :wink:

If you scroll down to ‘Topics’ and then ‘Automation’, you will find a bunch more.

1 Like