Notify when a device goes offline

Hi Burningstove,

Thx for the great automation, I love to use this aswel
However I end up whit an error in the action side i cant complain

‘Error rendering data template: UndefinedError: ‘trigger’ is undefined’

I just copied yours, i suppoce :roll_eyes:


alias: Systeem - offline devices
description: ""
trigger:
  - platform: state
    entity_id:
      - switch.th16_bk1_badkamer_verwarming
      - switch.basic_bk2_badkamer_afzuiging
      - switch.hottub_4ch_tasmota
      - switch.4ch_t1_houthok_water
      - switch.mini_t2_buitenlamp_wasbak
      - switch.thr316d_ht1_bypass_klep
      - switch.thr316d_ht2_kachel_pomp
      - switch.thr316d_ht3_solarkoepel_pomp
      - sensor.thr316d_ht4_ds18b20_temperature
      - sensor.thr316d_ht5_ds18b20_temperature
      - sensor.thr316_ht6_ds18b20_temperature
      - sensor.th16_ht7_ds18b20_temperature
      - switch.4ch_ht8_pomp_hottub_ww_warmtepomp
      - switch.tasmota
      - sensor.tasmota_basic_ds18b20_ds18b20_temperature
    to: unavailable
    for:
      minutes: 5
action:
  - service: notify.mobile_app_iphone_van_henk
    data:
      title: Device offline!
      message: >
        📵 {{ statet_attr(trigger.to_state.entity_id, 'friendly_name') }} is
        offline more than 5 minutes!
      data:
        channel: Notfall
        priority: high
        ttl: 0
        color: red
mode: parallel

I must be honest with you, i dont understand what is happening in the action part, its not just a notifyer

Thx in advance

I cannot take credit for this but someone on this forum showed me how to do it. I have this in my configuration.yaml - something similar may be of use to you -

template:
#
# This binary sensor not only specifies if any entities in the integration are unavailable, but also if
# there are any unavailable, it will contain an attribute that is a list of the entities that are unavailable.
#
  - binary_sensor:
      - name: "Any Shelly Unavailable"
        state: "{{ integration_entities('shelly') | select('is_state', 'unavailable') | list | count > 0 }}"
        attributes:
          entity_id: "{{ integration_entities('shelly') | select('is_state', 'unavailable') | list }}"
        unique_id: any_shelly_unavailable

#
# This binary sensor not only specifies if any entities in the integration are known, but also if
# there are any unknown, it will contain an attribute that is a list of the entities that are unknown.
#
  - binary_sensor:
      - name: "Any Shelly Unknown"
        state: "{{ integration_entities('shelly') | select('is_state', 'unknown') | list | count > 0 }}"
        attributes:
          entity_id: "{{ integration_entities('shelly') | select('is_state', 'unknown') | list }}"
        unique_id: any_shelly_unknown
        
3 Likes

Thx i trie it

Have a good weekend!