Devices/entities randomly turning on/off, how to troubleshoot this?

Hi everyone!
I’m having an issue with some devices… I’ve seen this happen with Hue lights, other lights, a couple of input booleans and also with the Presence Simulation’s switch.

Different situations I’ve seen:

  • I go to sleep, and when I wake up there’s a light on that isn’t supposed to be on, and when I check the logbook I see that it turned on at a random time, like 4am.
  • I have an input_boolean called “sleeping” that turns on when I manually start sleep tracking on my Sleep as Android app, this works through a webhook and an automation that gets the webhook and turns the Sleeping input boolean on. Suddenly today this was turned on at around 6pm and I don’t see what caused it to turn on, the automation wasn’t activated since last night when I actually went to sleep.
  • I have an integration called Presence Simulation (that randomly turns on/off a list of lights), it has an entity that shows up as a switch and you can turn it on/off to enable or disable this simulation. Today this was turned on right after one of the many system restarts.

I don’t see a specific pattern here and I’d like to “listen” to any events that happen related to these devices and log them. I see them in the Logbook but there isn’t enough info on what is triggering these events, it just says “(device) turned off triggered by service switch.turn_off”.

Also, I’d like to know how to listen to events of a specific device through the “listen to events” tool. I usually set it to * and listen to everything and then use ctrl+f to search.

Any recommendations are appreciated! I’ve been searching for this online but I find posts mentioning logs in SQL and I don’t know how to use that. If it’s possible to have a log file with text similar to the Events output that’d be fine.


I have same issue! Super annoying.

I have a button by my bed that turns everything off, but know it activities simulation :rofl:

1 Like

Hi @Jeppe_Lutzhoft , so sad to hear that!

Do you know how I could troubleshoot this?


Does the logbook show this being turned on via an automation or just simply a turn on command ?

Do your lights have startup behaviour set to on ?


Could the power be tripping and causing them to then come on ?

One of the lights, which I found on after waking up, had the start-up behavior set to on and I just changed it to keep the previous state.

The other light, which I saw turning off randomly, was already set to keep the last state.

This doesn’t apply for the input boolean or the Presence Simulator switch, they don’t have this property since they are virtual devices. I’m still interested in creating a log to check all the events that call services for these devices.


Does the logbook meet that requirement ?

Are you using HA with Alexa?


Is there any way of seeing more details in the logbook? I need something similar to the event listener, which shows exactly which autiomation/integration started each service call. But instead of logging the events into the open webpage, I would like it to store the log in a textfile so I can leave it on for hours and then find the issue when I see it happening.

Also I insist, is there any way of filtering the event listener to only listen messages that mention a specific device? I could leave the event listener opened but it’s complicated if I leave it listening to all events for let’s say 48 hours. It’d be really helpful to only listen to events acting on these specific devices.

@petro Nope, I linked it with my Google Home through Nabu Casa, and two of these entities that have been acting randomly are not even exposed to Google Home.

Thanks everyone!

The event listener isn’t going to help. It’s for listening to event. You can use it to listen to state_changed events, but you can’t filter it. You can w/ an automation, but why bother when logbook already has this information.

Your logbook will tell you what triggered the logbook entry.

The log book already does this. If you do not see any context (i.e. what automation, integration, etc) that means the device itself enacted the change. I.e. someone physically turned it on, or something outside HA turned it on.

@petro Thanks for your reply.
I understand it could be an external issue for the lights. But it worries me to see an input_boolean changing randomly. The only thing that has ever controlled this input_boolean.sleeping is one specific node in Node-RED, which is activated by a webhook, and every time it is activated it shows the last hour it was called below the node. Checking the logbook around the two times I saw it turning on randomly, there are no related events that explain why it was turned on (one of the times was right after a system startup, but this doesn’t normally change the status of that input_boolean) and the node in Node-RED doesn’t match with the logbook (node says it was turned on at night when I went to sleep, logbook says it was turned on when I went to sleep, then turned off when I woke up, then turned on again in the afternoon).
So there is something weirder happening here, maybe it’s an issue with Node-RED, which is the only thing that controls this device.

These issues have not been repeating constantly (fortunately!), but as I noticed they happened with different devices at different times I’m intrigued and want to keep watching to see if anything makes sense.

I’ll keep looking at the logbook then, thanks!

Ah, yes, webhooks do not have context. It’s a major drawback of node red. So if you exclusively use node red, you’ll never get any context in HA working.

Input booleans will always have context… unless it’s changed from a webhook, i.e. node-red or something else that’s using webhooks.

What do you mean by “do not have context”? That they are not stored in the logbook?

Anyway, I did oversimplify my explanation of the webhook setup:

I am not using webhooks directly integrated to Node-RED.
I have the Nabu Casa Webhooks, then a HA automation triggered by the webhook that presses an input_button.sleep_tracking_started, then Node-Red captures this button press by a trigger:state node. So any malfunctioning of the webhook would be at least seen in the HA automation last trigger.

  • Automation traces:

  • Node-RED nodes:

Both times I saw the input_boolean randomly turning on were not matching the times shown in the HA automation nor the Node-RED nodes. Also the input_buttons were only pressed at the correct times.


Everything that’s acted on in HA has context. It’s an object that describes what caused the change. This is what populates the logbook with information on what changed a device… e.g.

The logbook entires that have no context i.e. no by ... or no name next to the time, that means they have no context.

That also means it was an outside source that caused the change.

Hello :blush:
Error is reported and replicated by others. So probably fixed soon.

1 Like

I have a similar issue. All of my lights will turn on at what appears to be random time. It started happening for one set of lights automatically, and as I started adding automations (correlation does not mean causation, though), it started happening for more lights and more often.

I disabled almost all of the automations, and kept just a few. The issue still persists, but again, is much rarer. Actually, I don’t think it happened in the last 24hours. One thing I think I noticed is that at the same time a device tracker entity comes online (I have an airthings view device that goes on and off from HA point of view). I’m not sure if this happens always though, I’ll have to do some more monitoring.

1 Like

I also have a similar problem. Mainly it happens with my AV receiver. I got a Denon X4800H and even tho I may have just turned it on to listen to a internet radio station via script, 1 minute later it turns off. It just happend, as I tried to change the volume via the media player card, that it turned off again. In den logs there is no event that triggered it. What can I do to find the reason?

and I do not use node red…

Same issue here, with a Moes MS-104Z. Logbook only states “Turned On” whenever it happens. I can see how I turned it off again, though.

I thought it might have to do with power fluctuations or something, but the “Power-on behavior” is set to turn the device off.

(Sorry for reviving an age-old thread, but it is unresolved and one of the first hits on Google)

1 Like

I also had an odd behavior. I had problems with my internet connection (dsl modem not available) and suddenly Light an Switches turned on and off randomly. After Homeassistant had internet connection again, all runs fine again. So what could be the reason for that? I even had it on devcices with no automation at all, like a plug that i’am only using for power measurment.

I’m in the same boat here. Logbook shows event with no context (switch turning off). I’ve switched the device out and replaced with another, just in case there’s a hardware problem. However, the problem has occurred only for this device at this location. The entity device name is even different. Switch always turns off (never on), and default behavior on power loss is to be on.