Is there any way with minimal or no YAML to display all switches that are unavailable. I can do this one by one for each device with the code below, but I was hoping for a simpler way to do all switches at once. These is some YAML at Blueprint Link but I could not get it to import to see if it would do what I wanted.
Any suggestions?
type: entity
entity: switch.athom_smart_plug_v2_ec747b_smart_plug_v2
visibility:
- condition: or
conditions:
- condition: state
entity: switch.athom_smart_plug_v2_ec747b_smart_plug_v2
state: unavailable
- condition: state
entity: switch.athom_smart_plug_v2_ec747b_smart_plug_v2
state: unknown
grid_options:
columns: 9
rows: 2
Thanks, after messing around for an hour, (I did not even know what a template was or that it existed) I realised that the integration name must be lower case ‘esphome’ not ‘ESPHome’. Do you have an example of how to use this in a card? Unfortunately the ‘Templates’ docs don’t mention cards, and the ‘Cards’ docs don’t seem to have a generic type that does not need an entity or similar, so I am having troubles combining them.
I tried a conditional card but just got errors. Note that I only have a basic understanding of the syntax, but anything you have might help.
I’d probably use the above approach now, but when I first setup my ‘devices offline page’, I simply enabled the LQI entity on all my zigbee devices and use an auto entities card to list all LQI’s in an unavailable state, works fine:-
I anyone needs it this will list all unavailable states from all devices - as far as I can tell.
{# List all offline states #}
Offline:
{%- for entity in states -%}
{% if entity.state == "unavailable" %}
{{ entity.entity_id -}}
{%- endif -%}
{%- endfor -%}
I suggest you use the device name as I did in my template.
Using only entities like this will list all entities of the same device.
So a ESP device with lots of entities will clutter the list with all entities.
Using device_name() means you can reduce it to unique devices.
I did it that way which I keep on an error page as I wanted an itemised list as well as just the devices. You code works for a specific integration so I wrote the following to find devices across all integrations.
Note that the exclude id found in device url (I have a couple that I know are unavailable that I did not want notification)
### Offline:
{%- set exclude = [
'f7b3ace4cca80ff364d43a63855fa4b4',
'2778683f71793a0a90ae49a8e50b97e7'
] -%}
{%- set ns = namespace(seen=[]) %}
{%- for entity in states if entity.state == 'unavailable' %}
{%- set dev_id = device_id(entity.entity_id) %}
{%- if dev_id and dev_id not in exclude %}
{%- set dev_name = device_attr(dev_id, 'name') %}
{%- if dev_name not in ns.seen %}
{{ dev_name }}
{%- set ns.seen = ns.seen + [dev_name] %}
{%- endif %}
{%- endif %}
{%- endfor %}