I haven’t tried it - but I would expect that you then create an empty list, and then loop through the group that you have, comparing the last_changed attribute to
Any entry in the group was changed < timenow has been on for 3 hours and can then be added to the list. which you use in the light.turn_off service call for entity_id.
The list should ONLY be a list of entity_id’s and nothing else.
Thanks, I knew there had to be a better way of doing it. Oddly {{ state_attr('entity_id','last_changed') }} tells me the return value is None and I could only get access using {{ states.entity_id.last_changed }} which is weird.
EDIT: Can you use that as is in a service call, or do you need to change the join filter to list ?
If you look at the properties of an entity’s State Object you’ll see that last_changed is a property of the entity’s State Object. It’s not within the State Object’s attributes property. That’s why you can’t use state_attr to access last_changed.