Skip to content

Instantly share code, notes, and snippets.

@sagilo
Last active November 17, 2021 11:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sagilo/9c5f85794fa8ee3427e7cdab27f573f5 to your computer and use it in GitHub Desktop.
Save sagilo/9c5f85794fa8ee3427e7cdab27f573f5 to your computer and use it in GitHub Desktop.
HomeAssistant blueprint for notifying when an entity becomes unavailable
blueprint:
name: Notify when an entity becomes unavailable
description: Notify via a selected service when an entity becomes unavailable (version 1.0)
source_url: https://gist.github.com/sagilo/9c5f85794fa8ee3427e7cdab27f573f5
domain: automation
input:
entities_filter_regex:
name: Entities filter
description: Optional, whitelist filter entities by regex, leave empty to include all entities. Can be a domain, an entity name or both, for example 'sensor.' for sensors or for example 'sensor|light.main_light' for all sensors and 'main_light' entity
default: ''
actions:
name: Actions
description: Notifications or similar to execute, {{ trigger.event.data.entity_id }} is replaced with
the unavailable entitiy name.
selector:
action: {}
max_queued:
name: Maximum queued notifications
description: A number, in case of multiple events, what should be the queue max depth, defaults to 10
default: 10
selector:
number:
min: 1
max: 100
variables:
filter: !input entities_filter_regex
alias: Notify if an entity becomes unavailable
description: ''
trigger:
- platform: event
event_type: state_changed
event_data: {}
condition:
- condition: template
value_template: >-
{{ trigger.event.data.entity_id |regex_search(filter, ignorecase=False) and
trigger.event.data.new_state.state == 'unavailable' and
trigger.event.data.old_state.state != 'unknown' }}
action:
- choose: []
default: !input 'actions'
mode: queued
max: !input max_queued
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment