How to tell what caused an action

So, I am trying to find out what is causing specific actions.
Every now and then my bathroom light turns on for example… I don’t remember any automation or node-red trigger I used to cause it to turn on except for the motion sensor.
I can trade back the light turning on to the always helpful “turned on triggered by service light.turn_on” but what caused home assistant to turn it on? I need to track it down to the automation or the node-red flow that did it. There has to be a way, but I can’t find it.
Thanks in advance.

I am having the same issue, random lights turn on randomly but there is not enough detail in the logbook to see what automation turned them on?? It seems that all the lights are tied back to the localtuya integration and triggered by the service light.turn_on. Anyone lend some tips?? I am newly learning this HA thing.

Welcome to the forum, Anj-0110 :wave:t3:

Its not a HA error but this is mostly caused by the switches themselves. According to my experiences this happens with some (but not all) cheap “no neutral line, no capacitor needed” Tuya smart switches. With some switches it helps to simply add a capacitor.

I added automations to switch off those switches after a certain time but eventually replaced them with better ones (preferably Zigbee based switches).

Thanks for the reply Tamsy.

I don’t have tuya switches, the lights are wired into a normal (non-smart) on/off switch that stays on all the time. The light fixtures themselves are tuya devices.

How do I track down what automation turned them on? I have noticed in the log that I have localtyua warnings, something else might be taking place just not sure how to troubleshoot it. Looking through all the forums and posts to see what I can learn.