How to detect if service call is made from automation

I’d like to create an automation trigger that checks if the event call_service for the domain light.turn_on or light.turn_off was called by an automation.

At this point, I can check if this event has been fired, but not whether it has been fired by automation or something else, e.g. a button in the app or a physical remote.


HI , I am interested in doing the same so might be we can collaborate .

I have an automation that triggers every 30 minutes , I can see under
the logbook that it has been triggered by time pattern .

What do you see in your logbook .

If you are seeing it then might be we can script it

you can see the specific automation being triggered and trigger off that
you can assume light.turn_on/off will occur immediately after the automation that calls it and just trigger if the service call happen xx seconds after automation triggers.

both events appear on the event bus
I also notice that the ID and Parent ID of the event appear to be the same so you can use that as well likely

Agreed. Or, just execute that action after the service call in the automation. You know that’s where you’re turning it on. You can event emit your own event at that point and consume it with another automation, if you want separate automations.

@Shadowtm what is your use case?

I think this makes scene and for sure better then scripting

I am also curious about the use case because I dnt have any real use case and all my actions are in the same automation .

Thank you both for the help

Thanks for the Ideas, my use case is the following:
I have automation for lighting, but want to be able to detect when someone operates the light by a switch or the app, to set a virtual switch so that automation doesn’t mess with the “manual override”.

So in essence, I just want to differentiate if it has been set via Automation, or anything else.
On the other hand, I just realized that my Switch is also set up using an automation, so I gotta think about something else :joy:

1 Like

You can check whether there is a user context when the automation gets triggered.