Detect source of state change

I am curious if it is possible to detect the source of a state change, specifically when it comes from Google Assistant.

I have a condition set in an automation to only turn on/off lights from a sensor when a helper called ‘Motion’ is turned on. The advantage of this is for a few reasons, like troubleshooting, playing with colors, or taking a nap on the couch.

When a light is requested to be turned off from Google Assistant, I want to also turn that ‘Motion’ helper off. It would of course turn back on automatically after a few hours.

The reason for this is, if a command is sent through Google Assistant I want any automations that could conflict with that command to temporarily be turned off.

I don’t think so. These are the only context variables I know of:

06283b2a5eaebf0b308f62c6b2b764cbb14fb723

I’m nor sure which of the three options (Physical /HA UI / Automation) Google assistant would fall under either.

You could create a virtual light (eg MQTT light) and expose that to Google Assistant rather than your real light. Then in the handler for the virtual light, turn the real one on or off, and adjust the motion helper as required.

1 Like

@michaelblight I think that is a good approach. I am considering that with a minor difference of using HAs built in “helper” toggle and leaving lights exposed.

When in a room and asking Google Assistant to turn on/off lights have HA simply detect a state change in the helper and disable motion automations for a few hours.

The only disadvantage I can think of in this approach is exposing lights AND the helper looks a little odd and if Google Assistant mentioned the number of lights, it will add one extra device, i.e. 5 lights when you really have 4. The extra is the helper. I think I can work with this. :+1:

The advantage of leaving lights exposed is so you can ask Google Assistant to change brightness, color, etc. It seems to simplify the setup and if I no longer like this feature, just remove it and the automation around it and everything else will work.

I hope this explains the idea and answers any questions. :slight_smile: