I have created a sensor that warns me when an entity becomes unavailable.
It shows the count of the missing entities, as well as the list of the names.
It’s useful when you have a fairly sized network, with some unreliable devices (Aquara!).
The config panel informs me that:
Manually configured MQTT sensor(s) found under platform key
sensor
.
Please move the configuration to themqtt
integration key and restart Home Assistant to fix this issue. See the documentation, for more information.
Of course i tried to port the sensor to the new MQTT sensor syntax, however they’re not 1-to-1 compatible. Specifically, there’s no attribute_templates
. Is this replaced by json_attribute_topic
?
Also, what should I use as state_topic
?
Here’s how it’s configured:
sensor:
- platform: template
sensors:
unavailable_entities:
friendly_name: Unavailable Entities
unit_of_measurement: entities
icon_template: "{{ 'mdi:check-circle' if is_state('sensor.unavailable_entities','0') else 'mdi:alert-circle' }}"
value_template: >
{{ states|selectattr('state','in',['unavailable','unknown','none'])
|rejectattr('domain','eq','group')
|map(attribute='entity_id')
|select('match','^sensor')
|reject('match','.*charger_type$')
|reject('match','.*zigbee2mqtt_networkmap$')
|reject('match','.*sht_w')
|list|count }}
attribute_templates:
entities: >
{{ states|selectattr('state','in',['unavailable','unknown','none'])
|rejectattr('domain','eq','group')
|map(attribute='entity_id')
|select('match','^sensor')
|reject('match','.*charger_type$')
|reject('match','.*zigbee2mqtt_networkmap$')
|reject('match','.*sht_w')
|list }}
Thanks in advance for any help.