Ok Jason. I’ve had a little breather and I hope you have had a bit of one also. Can you or someone here help me get the below to display friendly names in the notifications? I’m still learning this stuff and afraid I’m going to mess up the progress we’ve already made.
###################################################################################################
## Package - Unavailable Entities Sensor
## Count and list entities with a state of unavailable, unknown, or none (null)
## See README for customization options.
## https://github.com/jazzyisj/unavailable-entities-sensor/blob/main/README.md
###################################################################################################
# NOTE: Home Assistant v2021.12 required. For older versions please see README
# REQUIRED - This is the template sensor
template:
- sensor:
- name: "Unavailable Entities"
unique_id: unavailable_entities
icon: "{{ 'mdi:alert-circle' if states('sensor.unavailable_entities')|int(0) > 0 else 'mdi:check-circle' }}"
unit_of_measurement: entities
state: >
{% if state_attr('sensor.unavailable_entities','entity_id') != none %}
{{ state_attr('sensor.unavailable_entities','entity_id')|count }}
{% endif %}
attributes:
entity_id: >
{% if state_attr('group.ignored_unavailable_entities','entity_id') != none %}
{% set ignore_seconds = 300 %}
{% set ignore_ts = (now().timestamp() - ignore_seconds)|as_datetime %}
{% set entities = states|rejectattr('domain','in',['group','button','automation','scene'])|selectattr('state','in',['unavailable','unknown','none'])|list %}
{% set buttons = states.button|selectattr('state','eq','unavailable')|list %}
{{ (entities + buttons)
|rejectattr('entity_id','in',state_attr('group.ignored_unavailable_entities','entity_id'))
|rejectattr('entity_id','search','sensor.weatherbit')
|rejectattr('entity_id','search','keymaster')
|rejectattr('entity_id','search','media_player')
|rejectattr('last_changed','ge',ignore_ts)
|map(attribute='entity id')|list }}
{% endif %}
# REQUIRED - Add any entities you do not wish to monitor in this group.
# IMPORTANT - This group MUST exist even if empty for sensor template to render.
group:
ignored_unavailable_entities:
entities:
- sensor.unavailable_entities # prevent template loop warnings?
- binary_sensor.back_porch_outlet_heat_alarm_overheat_detected
- binary_sensor.garage_door_access_control_barrier_sensor_low_battery_warning
- binary_sensor.garage_door_access_control_barrier_sensor_not_detected_supervisory_error
- binary_sensor.garage_door_access_control_barrier_unattended_operation_has_been_disabled_per_ul_requirements
- binary_sensor.garage_door_home_security_tampering_product_cover_removed
- binary_sensor.garage_door_low_battery_level
- light.desk_lamp
- sensor.clarice_charger_type
# OPTIONAL - filter template loop warnings from the Home Assistant log.
logger:
filters:
homeassistant.components.template.template_entity:
- "Template loop detected while processing event"
# OPTIONAL Example automation to demonstrate how you can utilize this sensor
# SEE Automation.yaml
Automation:
automation:
- id: unavailable_entities_notification
alias: 'Unavailable Entities Notification'
description: 'Create persistent notification if there are unavailable entities, dismiss if none.'
mode: restart
trigger:
- platform: state
entity_id: sensor.unavailable_entities
to: ~
condition:
- condition: template
value_template: >
{{ is_number(trigger.from_state.state)
and is_number(trigger.to_state.state) }}
action:
- if:
- condition: numeric_state
entity_id: sensor.unavailable_entities
below: 1
then:
- service: persistent_notification.dismiss
data:
notification_id: unavailable_entities
else:
- service: persistent_notification.create
data:
title: Unavailable Devices
message: |-
- {{ expand(state_attr('sensor.unavailable_entities','entity_id'))
|map(attribute='entity_id')|join('\n- ') }}
notification_id: unavailable_entities
- service: notify.mobile_app_weston
data:
title: Unavailable Devices
message: |-
- {{ expand(state_attr('sensor.unavailable_entities','entity_id'))
|map(attribute='entity_id')|join('\n- ') }}
EDITED: Automation Code