
Display Offline, unavailable, or missing sensors in Home Assistant
In this guide, I will show you how to detect any missing or unavailable entities in Home Assistant. This is great for detecting if any of your motion sensors go offline or stop responding. You can also use this as a way to cleanup or delete any unused entities that you may have forgotten about.
Chances are, you will have a bunch of things that show up as unavailable that you don't necessary want to be notified about (for example, a Chromecast that isn't on 24/7). These items can be added to an ignored_entites group, which I'll show you how to do as well.
For this setup, we are doing three things: Adding an "unavailable_entites" sensor to configuration.yaml, creating an ignored_entities group, and then displaying these unavailable or offline sensors to a Lovelace card. Once you have this setup, you can optionally create an automation to notify you if a certain device goes offline.
Step 1: Add Unavailable Entities sensor to Configuration.yaml
Navigate to File Editor. Copy and paste the code exactly as below. If you don't already have a sensors: section added to your configuration.yaml file, be sure to add that to the very beginning.
- 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') |rejectattr('entity_id','in',state_attr('group.ignored_entities','entity_id'))|list|count }} attribute_templates: entities: > {{ states|selectattr('state','in',['unavailable','unknown','none'])|rejectattr('domain','eq','group') |rejectattr('entity_id','in',state_attr('group.ignored_entities','entity_id'))|map(attribute='entity_id')|list }}
Step 2: Create an "Ignored Entities" group
Next, we need to create a list of exclusions, or devices you want to exclude from the list of unavailable entities. You probably won't know exactly what you exclude yet, so for purposes of this demo we are just going to use the binary_sensor.updater entity.
group: ignored_entities: entities: - binary_sensor.updater
After Step 1 and Step 2 is complete, save your configuration and restart Home Assistant from Configuration > Server Controls. Be sure to click the Check Configuration before rebooting to ensure you don't have any errors first.
Step 3: Create Lovelace Card to Display Unavailable Entities
The most basic card you can create to display the total number of unavailable entities is a simple entities card. Step 2 creates a new entity called unavailable_entities
, so you can add a new card and just select the sensor.unavailable_entities
entity.
When you click the card, you'll see exactly which ones are offline (excluding your ignored entities, of course).
I prefer displaying the entities as a dropdown, so I downloaded two integrations via HACS called Fold-Entity-Row and Hui-Element. To add this dropdown card, add a new card, scroll to the bottom and choose Manual, and paste the yaml below.
type: custom:fold-entity-row head: null entity: sensor.unavailable_entities entities: - type: custom:hui-element card_type: markdown content: > {%- if states('sensor.unavailable_entities')|lower not in ['unknown','unavailable','none'] -%} {%- if states('sensor.unavailable_entities')|int == 0 -%} No unavailable entities. {%- else -%} {%- for entity in state_attr('sensor.unavailable_entities','entities') -%} - {{ entity }}{%- if not loop.last -%}{{ '\n' }}{%- endif -%} {%- endfor -%} {%- endif -%} {%- endif -%}
And here's what the dropdown list of entities looks like:
Step 4: Add remaining unavailable entities to ignored list
The last step is to just go through the list of entities in your card and take action on them: either delete them if they aren't in use, or add them to the ignored_entities
group (Step 2). Deleted entities get removed from the card within just a few seconds, but any entities you have excluded will require a Home Assistant reboot.
Once you have your list cleaned up, save your configuration.yaml again and restart Home Assistant. Your card should
Optional: Step 5: Create Automation to Alert When Entity is Unavailable
Add the below code to your configuration.yaml file.
automation unavailable_entities_alert: - 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 action: - choose: conditions: - condition: numeric_state entity_id: sensor.unavailable_entities below: 1 sequence: - service: persistent_notification.dismiss data: notification_id: unavailable_entities default: - service: persistent_notification.create data: title: Unavailable Entities message: "- {{ expand(state_attr('sensor.unavailable_entities','entities'))|map(attribute='entity_id')|join('\n- ') }}" notification_id: unavailable_entities
And here's what it looks like:
Wrapping Up
All in all, this is pretty handy little card and automation. The key thing to remember is that you need to add the automation to your configuration.yaml file instead of the Automations section (it took me far too long to realize that..)
If you enjoyed this guide, and would like to monitor servers, computers, phones, or any device on your network with an IP address in Home Assistant (with working notifications!), then you should check out my Server Monitoring in Home Assistant guide.




