Of course it won’t trigger… You have a condition that contradicts the trigger.
trigger:
entity_id: group.steve
platform: state
to: 'home'
- condition: state
entity_id: group.steve
state : 'not_home'
for:
hours: 2
You want this to trigger when it changes to home. But then you check to see if it’s been not home for 2 hours. It literally just changed to ‘home’, therefore it cannot be ‘not home’ for 2 hours.
I just posted about a similar thing I’m trying to do. I wish there was a way to access state history from templates. How did you implement your binary_sensor.kitchen_door.last_updated sensor?
last updated is an attribute that is on all state objects. I.E. All devices in all domains(outside of automations and scripts) have the last_updated and last_changed attribute
Check out the that doc. It tells you want is inside a state object. State objects are fancy ways of saying “a device in home assistant”
Yeah, I’ve used state objects before… Somehow I just never noticed that they all have last_updated fields.
Well, they all don’t have that field My MQTT-based device tracker doesn’t have this field despite being able to see “1 hour ago” when I click on the pop-up on the dev-state page.
Is there any way you can get this value for entities that don’t have it explicitly in their attributes?
Don’t confuse the last_updated attribute with last_updated on the state object. It’s rather annoying that the 2 fields have the same name, but they are not related in any way.