Entity Status Report Notification - Request

Does any body know of how to create an automation or have a template they can point me to that can do an entity status report notification? IE I provide a list of entities, and the automation sends a general notification that lists the status of each entity.
I’ve done single notifications where various triggers set it off, but I want to make a list of entities and just have the notification report the status on each. My ultimate goal is to have a security report once a night saying x door is open, y door is closed, x lock is unlocked, y lock is locked; that way I know I have to secure various items afterwards.
Originally I just had an automation lock all the doors each night. But one night I found a door open and the lock “locked” but of course not while closed. If I could see that the door contact was open, I could have avoided that. So if I could get a report nightly just before lockup I can see what has to be corrected.
I figured there has to a generic template or automation where you pick entities, and it sends a notification of each status. But I do not think I’m hitting the correct keywords in my searches. (I have found blueprints that maybe I can pull apart where it reports on all battery status’s… thats close… but I need to be able to pick any entities)
Any help or pointers to similar projects would be appreciated.

something like this? if this isn’t what you mean, please clarify.

trigger:
  - platform: time
    at: "21:00:00"
condition: []
action:
  - service: notify.notify
    data:
      title: status of each entity in test_label
      message: |
        {% for entity in label_entities('test_label') %}
        {{ state_attr(entity, 'friendly_name')  }}  :  {{ states(entity) }}
        {% endfor %}

That worked perfectly. Exactly what I was looking for. I just had to tag all the entities I wanted in nightly report with the “test_label” and they got included.

1 Like

great! obviously you can pick a more appropriate name than my lame ‘test_label’ name :slight_smile:

I did. I labeled the entities I wanted with “Security Check”. Then used your code with minor edits for my use in the actions sections for call service.

service: notify.mobile_app_my_iphone
data:
message: >
{% for entity in label_entities(‘Security Check’) %}

{{ state_attr(entity, 'friendly_name')  }}  :  {{ state_translated(entity)
}}

{% endfor %}

title: Security Check at {{now().strftime(“%H:%M %d-%m-%y”)}}
(sorry not sure how to format the code section properly… but it looks like below.)

I also found using state_translated gave me the friendly state of the entity instead of the generic state. IE door contacts show as open/closed instead of on/off.
Your example got me going in the right direction. Thank you.

1 Like