Skip to content

Instantly share code, notes, and snippets.

@Geek-MD
Last active January 30, 2026 02:33
Show Gist options
  • Select an option

  • Save Geek-MD/bfe782e055772ac08e8204220c48cbc9 to your computer and use it in GitHub Desktop.

Select an option

Save Geek-MD/bfe782e055772ac08e8204220c48cbc9 to your computer and use it in GitHub Desktop.
blueprint:
name: Unavailable Device Notificator
description: Detect devices becoming unavailable, exclude specific devices, and execute custom actions.
domain: automation
author: Edison Montes @_GeekMD_
homeassistant:
min_version: 2024.6.0
input:
excluded_devices:
name: Excluded devices
description: Devices that are going to be excluded from detection.
selector:
device:
multiple: true
default: []
start_time:
name: Start Time
description: The start time when the actions are allowed.
selector:
time:
default: "08:00:00"
end_time:
name: End Time
description: The end time when the actions are allowed.
selector:
time:
default: "22:00:00"
action:
name: Actions
description: >
Actions which are performed when a device becomes unavailable.
You can use the variable {{ unavailable_devices }} in your actions.
selector:
action: {}
mode: single
trigger:
- platform: event
event_type: state_changed
event_data:
new_state:
state: unavailable
- platform: event
event_type: state_changed
event_data:
new_state:
state: unknown
variables:
excluded_devices: !input excluded_devices
unavailable_devices_list: >
{% set result = [] %}
{% for s in states
| selectattr('state', 'in', ['unavailable', 'unknown'])
| selectattr('attributes.device_id', 'defined') %}
{% if s.attributes.device_id not in excluded_devices %}
{% set name = s.attributes.friendly_name | default(s.name) %}
{% if name not in result %}
{% set result = result + [name] %}
{% endif %}
{% endif %}
{% endfor %}
{{ result }}
unavailable_devices: >
{{ unavailable_devices_list | join('\n') }}
condition:
- condition: time
after: !input start_time
before: !input end_time
- condition: template
value_template: "{{ unavailable_devices_list | length > 0 }}"
action: !input action
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment