Skip to content

Instantly share code, notes, and snippets.

@techwithjake
Last active September 4, 2022 16:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save techwithjake/4c7d9403278c3f61c7bfb270a15df215 to your computer and use it in GitHub Desktop.
Save techwithjake/4c7d9403278c3f61c7bfb270a15df215 to your computer and use it in GitHub Desktop.
################################################################
## Packages / Offline devices alert
################################################################
################################################
## Customize
################################################
homeassistant:
customize:
################################################
## Node Anchors
################################################
package.node_anchors:
customize: &customize
package: 'offline_alert'
expose: &expose
<<: *customize
haaska_hidden: false
homebridge_hidden: false
################################################
## Group
################################################
group.offline_alert:
<<: *customize
friendly_name: "Offline Devices Alert"
icon: mdi:steam
################################################
## Automation
################################################
automation.offline_alert:
<<: *customize
friendly_name: "Offline Devices Alert"
automation.offline_alert_clear:
<<: *customize
friendly_name: "Offline Devices Alert Clear"
################################################
## Group
################################################
group:
offline_alert:
control: hidden
entities:
- automation.offline_alert
- automation.offline_alert_clear
################################################
## Automation
################################################
automation:
- alias: offline_alert
trigger:
- platform: time
at: '10:00:00'
- platform: time
at: '18:00:00'
action:
- condition: template
value_template: >
{% macro offline_state() %}
{%- set threshold = 40 -%}
{% set domains = ['light', 'switch', 'sensor', 'binary_sensor', 'zwave', 'zha', 'lock'] %}
{% for domain in domains -%}
{% for item in states[domain] if ((item.state | lower == "unavailable")) -%}
{{ item.domain }} {{ item.name }} {%- if not loop.last %}, {% endif -%}
{% endfor %}
{%- endfor %}
{% endmacro %}
{{ offline_state() |trim != "" }}
- service: persistent_notification.create
data_template:
title: "Offline Devices"
notification_id: offline-devices-alert
message: >
{% macro offline_state() %}
{% set domains = ['light', 'switch', 'sensor', 'binary_sensor', 'zwave', 'zha', 'lock'] %}
{% for domain in domains -%}
{% for item in states[domain] if ((item.state | lower == "unavailable")) -%}
{{ item.domain }} {{ item.name }} {%- if not loop.last %}, {% endif -%}
{% endfor %}
{%- endfor %}
{% endmacro %}
{{ offline_state() }}
- service: notify.pushover
data_template:
title: "These devices are offline"
message: >
{% macro offline_state() %}
{% set domains = ['light', 'switch', 'sensor', 'binary_sensor', 'zwave', 'zha', 'lock'] %}
{% for domain in domains -%}
{% for item in states[domain] if ((item.state | lower == "unavailable")) -%}
{{ item.domain }} {{ item.name }} {%- if not loop.last %}, {% endif -%}
{% endfor %}
{%- endfor %}
{% endmacro %}
{{ offline_state() }}
- alias: offline_alert_clear
trigger:
- platform: time_pattern
minutes: '/30'
seconds: 00
action:
- condition: template
value_template: >
{% macro offline_state() %}
{%- set threshold = 40 -%}
{% set domains = ['light', 'switch', 'sensor', 'zwave', 'zha', 'lock'] %}
{% for domain in domains -%}
{% for item in states[domain] if ((item.state | lower == "unavailable")) -%}
{{ item.domain }} {{ item.name }} {%- if not loop.last %}, {% endif -%}
{% endfor %}
{%- endfor %}
{% endmacro %}
{{ offline_state() |trim != "" }}
- service: persistent_notification.dismiss
data:
notification_id: offline-devices-alert
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment