1. Introduction
When automating your smart home with Home Assistant you will create a lot off automations. Monitoring and maintaining these Home Assistant automations can become a challenge. To overcome this it is possible to add cards to dashboards to provide an overview of triggered automations and disabled automations.
At this moment there are no cards available which will provide this functionality out of the box and some manual configuration is required. Luckily this is not complicated. I got the code from the Home Assistant community forum and adapted it a little bit to only show triggered automations from the last 24 hours and list the actual time instead of the hours/minutes past.
2. Requirements
We will make use of the Mark Down card, which is by default available within the Home Assistant Lovelace UI dashboards and the code provided in this article.
3. Implementation
We will implement 2 Home Assistant dashboard cards:
- Triggered automations in the past 24 hours
- Disabled automations
The required steps are provided in the next 2 sections.
3.1 Triggered automations in the last 24 hours
Execute the following steps to setup the card to display the Home Assistant automations triggered in the past 24 hours:
- On the Home Assistant dashboard click on the button “Add card”displayed at the lower left of your screen and search for the Markdown card and select it.
- Enter a title for the card
- Delete the existing code from the content field by putting the cursor in the field, pressing the Ctrl-A (select all) and the Delete key.
- Copy the following code and past it in the content field.
1234567891011|Time||Name||:----😐:--😐:----|{% for state in states.automation|selectattr('attributes.last_triggered', 'defined')|selectattr('attributes.last_triggered')|sort(attribute='attributes.last_triggered', reverse=true) -%}{% if state.attributes.last_triggered and (now() - state.attributes.last_triggered).total_seconds() < 86400 %}{%- set t = (as_timestamp(state.attributes.last_triggered) | timestamp_custom('%H:%M', true)) -%}|{{t}}||{{state.name}}|{% endif -%}{% endfor %} - The theme part is not required. The preview will show the triggered automations.
- Click on the Save button.
The period for which the triggered automations are shown can be changed by updating the 86400 seconds (24 hours x 60 minutes x 60 seconds) in the following line of code:
1 |
{% if state.attributes.last_triggered and (now() - state.attributes.last_triggered).total_seconds() < 86400 %} |
So use 3600 seconds for one hour, 43200 for 12 hours, etc.
3. 2 Triggered automations for an area
Execute the same steps as in section 3.1, but use the following code:
1 2 3 4 5 6 7 8 9 10 11 |
|Time||Name| |:----😐:--😐:----| {% for state in states.automation |selectattr('attributes.last_triggered', 'defined') |selectattr('attributes.last_triggered') |sort(attribute='attributes.last_triggered', reverse=true) -%} {% if state.attributes.last_triggered and (now() - state.attributes.last_triggered).total_seconds() < 86400 and (area_name(state.entity_id)=='<span style="background-color: #ffff00;">Bathroom</span>') %} {%- set t = (as_timestamp(state.attributes.last_triggered) | timestamp_custom('%H:%M', true)) -%} |{{t}}||{{state.name}}|{{area_name(state.entity_id)}} {% endif -%} {% endfor %} |
Change the highlighted Bathroom in the area name you used for the automation. Check the name is exactly the same as used in the Area field for the automation (via information > settings for the specific automation).
3.3 Disabled automations
Execute the same steps as in section 3.1, but use the following code to display all disabled Home Assistant automations:
1 2 |
{{ states.automation | selectattr('state', 'eq', 'off') | map(attribute='name') | list | join ('\n') }} |
The final card will then look like the screen capture below.
0 Comments