#What is this string called, and is there a way to test/see it's output?

1 messages · Page 1 of 1 (latest)

swift shard
#

Hello,

I'm trying to get the time that an entities has had one of it's attributes last changed to basically use it as a condition for turning off lights. I.E it's 10:30 and if the lights haven't been messed with in the past 10 minutes then go ahead and shut them off.

Right now I have it as an automation with this as the template.

condition: template
value_template: " {{ (as_timestamp(now()) - as_timestamp(states.light.living_room_short_lamp.last_updated)) < 600 }}"

    1. What is this string even called just for reference later?
    1. Is there a way to see what the value of the equation equals? Like if it's true or false, or if I get rid of the "<" could I see the value of the math?
    1. I got this from chatgpt, but how can I find the different options that go AFTER the states.light.living_room_short_lamp? I know there's a lot of info that exists within the states and entities.
    1. This info is helps because I want to be able to do things like this in other automations. LIke I want a trigger that says one hour after sunrise turn all the lights off mon-friday
unique hatch
#

I'm not sure what else it's called besides a Template. I'm still getting my bearings myself. But to see what it evaluates to you can use the Developer tools and then the Template section to put the code in. It'll tell you the result true or false.

swift shard
#

oh sick

swift shard
#

any way to figure out the other options or parameters like "last_updated"?

unique hatch
swift shard
#

yeah I found the state.last_updated in the link you sent

crystal flicker
#

If you want to see what the state or any of the attributes are for an entity, go to developer tools > states and search for the entity

#

Is also generally a better idea to work with datetime objects directly instead of converting them to timestamps.
{{ now() - states.light.living_room_short_lamp.last_updated > timedelta(minutes=10) }}

swift shard