Any way to know what triggered a state change?

I’m trying to debug lights turning on randomly (like, twice a month a light will come on when it shouldn’t) and I’m stumped. I already have debug log level on but it doesn’t say what triggered the state change just that the state changed from off -> on. Is there a way to accomplish this?

There is currently no way to see what changed the state of an entity, might be added in the future.
I would add a different log message to each automation that use this light to find out what triggers the light.

Nope, but a “triggered by” would be really nice to have.

1 Like

There is already a feature request here:

And someone in there mentioned that is already in the To-Do list of home assistant.

The way I would look at it would be to list the automations that turn the light on, then keep an eye on when the light does turn on and then see which automation ran.
If it’s not an automation, then it would be something either outside HA (if your light can be controlled directly, without HA) or an issue with the integration?

With debug enabled I can see the service calls coming in for my automations, I use NodeRed for all automations so when something triggers a service call is fired off. What’s strange about this is there is no service call for these certain lights but they sometimes come on. Looking over the logs I see the correct service calls and the state changes for the lights it should turn on and a little later (seconds/minute) there is a state change for the random lights but no service calls so I’m pretty sure it’s not my automations; that and it only happens very randomly. If I could peek into why the state changed in HA it might give me a clue why it happened.