Please can someone help, i have some basic coding but new to home assistant and yaml .
I have created a auto entity card for my dashboard with only shows sensors that are currently occupied or detecting motion . however ive been trying to do this for weeks and gotten nowhere, i would like it so it also shows any which have been on in last 5 minutes and any which currently show motion, i would really love the help , this is current code, thanks
You need a custom card called Auto Entities. It is very similar to the entities-filter card, just a bit more powerful and flexible. Download and install it from HACS.
Create a legacy group of the sensors you want to track.
Don’t forget to reload your groups from Developer Tools!
Using the Auto Entities card with the following template filter will give you a list all the sensors in your motion_sensors group that are either on, or have changed in the last 5 minutes.
type: custom:auto-entities
title: "Active Motion Sensors"
show_empty: true
filter:
template: >
{% set recent = expand('group.motion_sensors')
| selectattr('last_changed', '>', now() - timedelta(minutes=5))
| map(attribute='entity_id') | list %}
{% set active = expand('group.motion_sensors')
| selectattr('state', 'eq', 'on')
| map(attribute='entity_id') | list %}
{{ recent + active }}
sort:
method: last_changed
reverse: true
ignore_case: true
card:
type: entities
Anybody has a more efficient way to structure that template, lay it on me!