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.0
          max: 100.0
          step: 1.0
          mode: slider
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
