|
################################################################ |
|
## 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 |