Entity Attribute stating if state was last changed by UI or by Code/Automation

I have a lot of automations I would write if I could put a condition in NOT to run them if the entity was last changed by a human being (or changed by a human being within a time frame). Something like "turn the kitchen lights off at 10pm, but if someone just turned them on intentionally 10 minutes ago don’t change them. Maybe this is already a feature and I am missing it - just always wanted something like this to get rid of nuisance automation side effects.

Its not a feature - and you’re also missing a BIG use case. (Which is where your monkey wrench is)

Change state at the device.

(Because in my setup I RARELY use the UI to do anything and it should be reserved for special cases and detecting the difference between UI and automation is meaningless for me…) …And to add insult to injury many device manufacturers don’t differentiate in the report so - you just don’t (and can’t) know.

That said - if you feel strongly don’t forget to vote for your own suggestion.

1 Like

Wouldn’t Home Assistant know the difference between pushing new state info to a device or polling and/or receiving a different state from said device? I agree that would be another extremely useful value for the attribute I mentioned - I totally forgot about manually changing the devices which is a huge use case for the lights.

So pseudo mock up of the concept:

Attribute:
“last_changed_by”

Possible Values:
“lovelace”,
“device”,
“automation”,
“pyscript”,
“scene”,
“script”

And now that I write that out I see that the multiple pragmatic cases ( automation, scene, script ) could be convoluted as well. Hmmm.

Context can determine if the change was made by the ui, an automation or the physical device:

2 Likes

Thanks a ton! This will be extremely handy.

Are the context ids the entity name or some kind of unique id number of which particular device/entity/automation/user has triggered the state change?

It’s a unique identifier. See: Home Assistant Context | Home Assistant