Determine trigger of an action

Hey guys -

what is the best way to determine what triggered an event? So right now, I have a variety of ways an event can happen:

  • Triggered by a REST call / appdaemon
  • Homekit
  • HASS automation rule
  • Through web ui

What I want to know is: Is there a way to know which method was used to trigger an event, such as, turning on a light. I’ve tried using the ‘info’ level of the logger component and I dont see it. I also tried debug, but I couldnt spot it.

Thanks

You can use trigger data (see here) to see what triggered the event.

That only works for automations though…

Actually, maybe I misunderstood… Are you saying use ‘trigger data’ with an automation that triggers on any event? Would that work? I would have thought that the trigger would be the event…

I thought you meant triggered an automation. Events just happen based on what is happening, so “trigger an event” does not make sense. For example, you cannot trigger a sunset.

Fair enough, I was talking in more general terms, not HASS specific… What I want to know if what trigger a state change for a device such as a light. Was it an automation rule, a rest call, someone using the UI, etc.

you ever find an answer to this?