Hi all,
Hope you’re well!
I’m currently testing a ‘Device Monitoring’ automation that let’s me know when a device drops off my network, which currently works pretty well.
If the device is offline/online I receive a notification.
I also have a template sensor which shows the most recent device that either went offline or came back online.
Here’s my problem though;
If more than one device goes or is offline, the template sensor only displays the most recent offline device and not the other/s
How would one list multiple offline devices in a template sensor or any other method?
I’ve attached the automation, please let know if you need more info…
Device_Monitoring_Notification_Core.yaml (1.3 KB)
Thanks
To get a string containing a comma separated list of the friendly_names of all sensors whose states are ‘Disconnected’:
{{ states.sensor|selectattr('state','eq','Disconnected')
|map(attribute='name')|join(', ') }}
If you didn’t want to include all sensors, then create a group containing the ones you cared about (e.g., group.my_sensors), then:
{{ states.sensor|selectattr('entity_id','in',state_attr('group.my_sensors','entity_id'))
|selectattr('state','eq','Disconnected')
|map(attribute='name')|join(', ') }}
Hi there,
Thanks alot for your feedback!
I’ve implmented your code in a template sensor, but it only seems to update after a HASS reboot.
Do you know how to enforce this dynamically? ie when a device state changes?
Thanks again
Ahoy, came right by using the homeassistant.update_entity service and it works a charm!