@Taras thank you for your response and all of the help you have given me in the past.
This is good to hear.
I am still very new at all of this, what exactly is a “Trigger- based Template Sensor”, could you give me an example of this? Is the below possibly a “Trigger- based Template Sensor”? (This is the package and automation)
###################################################################################################
## 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 = 3600 %}
{% 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','keymaster')
|rejectattr('entity_id','search','weatherbit_')
|rejectattr('entity_id','search','media_player')
|rejectattr('last_changed','ge',ignore_ts)
|rejectattr('entity_id','search','search4text')
|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
- sensor.gym_active_app
- sensor.gym_active_app_id
- sensor.living_room_active_app
- sensor.living_room_active_app_id
- sensor.master_bedroom_active_app
- sensor.master_bedroom_active_app_id
- select.living_room_channel
- select.gym_channel
- select.master_bedroom_channel
- sensor.activewindowsensor
- binary_sensor.namedwindowsensorretrobat
- sensor.holiday
- sensor.weatheralerts_alert_3_last_changed
- sensor.weatheralerts_alert_4_last_changed
- sensor.weatheralerts_alert_5_last_changed
- sensor.weatheralerts_alert_3_most_recent_active_alert
- sensor.weatheralerts_alert_4_most_recent_active_alert
- sensor.weatheralerts_alert_5_most_recent_active_alert
- sensor.washer_last_complete
- sensor.pirateweather_precip
- sensor.front_door_motion_away_count
- sensor.lightning_near_home_lightning_azimuth
- sensor.lightning_near_home_lightning_distance
# 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
alias: (ACTION- AUTOMATIC- SECURITY- NOTIFICATION) Unavailable Entities Notification
description: >-
Create persistent notification if there are unavailable entities, dismiss if
none.
trigger:
- platform: state
entity_id: sensor.unavailable_entities
to: null
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='name')|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='name')|join('\n')
}}
So for these mqtt sensors, do I need a line to tell it to retain whatever is in these sensor? Especially the
“Washer Status” one. It seems like I wouldn’t want these to reset after a restart because I imagine they would go back to an “unknown” status almost as if they have never been instantiated. I believe these are first loaded with data after the first run of an automation related to each the sensors.
Ahh, exactly what I was thinking, sorry, I should’ve read your reply fully before I typed the above.
How do I go about making the topic value “retain”
sensor:
# MQTT Sensor for Washing Machine Status.
- platform: mqtt
name: "Washer Status"
state_topic: "house/washer/status"
- platform: mqtt
name: "Washer Last Complete"
state_topic: "house/washer/time_complete"
- platform: mqtt
name: "Washer Last Emptied"
state_topic: "house/washer/time_emptied"
As a side question, why do my time sensors show these crazy numbers rather than a date and time? (YYYY/MM/DD, 12:53 PM)
Nice, I understand this.
Thank you for clarifying this detailed point and thank you for being so helpful, one day I will know what I am doing, at least at a level that is sufficient for the simple stuff.
Also, one last random question about home assistant in general, do you feel like they are trying to make it more “main stream”, in terms of useable for new adoptees? I feel like compared to a few years ago when I gave up on it to be honest, things have changed immensely for the better, expecially, all of the UI improvements, are “they” trying to make home assistant mostly UI dependent now to increase adoption amongst the more incapable with code as myself?
Thank you again @123, and sorry this got so long.