What triggers group.all_switches?

I have been wondering about my computer that I usually keep in sleep mode during nights, but when I wake up, my computer is on. This has happened several times already, also during daytime, at random times. Also, my other switches seem to turn on and off as a group at random times every now and then.

I decided to investigate about this, and found out that it’s Home Assistant that actually wakes up my computer (I have a switch that sends WOL command to my computer when I manually turn it on and it works). So I enabled Logger and wanted to see what actually happens at that exact time when History tab shows that this “wake up computer” -switch has turned on. This morning this has happened at 5:29 apparently. Oh, and before I went to bed, I had all my Sonoff switches on, but they all were switched off from 0:00 onwards (I only have one day visible on History panel so I am not sure at which time they have turned off, but I think the reason is the same why my computer is suddenly turning on. Anyway, these are the lines in home-assistant.log at 5:29:

2018-05-01 05:28:52 INFO (MainThread) [homeassistant.components.http.view] Serving /api/ to 172.30.32.2 (auth: True)
2018-05-01 05:29:01 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.time, old_state=<state sensor.time=05:28; friendly_name=Time, icon=mdi:clock, hidden=True @ 2018-05-01T05:28:01.506269+03:00>, new_state=<state sensor.time=05:29; friendly_name=Time, icon=mdi:clock, hidden=True @ 2018-05-01T05:29:01.506010+03:00>>
2018-05-01 05:29:20 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=switch.computer_wakeup, old_state=<state switch.computer_wakeup=off; friendly_name=Wake The Computer @ 2018-05-01T00:34:10.532845+03:00>, new_state=<state switch.computer_wakeup=on; friendly_name=Wake The Computer @ 2018-05-01T05:29:20.533173+03:00>>
2018-05-01 05:29:20 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=group.all_switches, old_state=<state group.all_switches=off; entity_id=('switch.switch', 'switch.switch_8', 'switch.switch_6', 'switch.switch_9', 'switch.sonoff_pow_cellar', 'switch.sonoff_pow_pump', 'switch.sonoff_th16_cellar', 'switch.sonoff_th16_pump', 'switch.computer_wakeup'), order=3, auto=True, friendly_name=all switches, hidden=True @ 2018-05-01T00:34:10.570000+03:00>, new_state=<state group.all_switches=on; entity_id=('switch.switch', 'switch.switch_8', 'switch.switch_6', 'switch.switch_9', 'switch.sonoff_pow_cellar', 'switch.sonoff_pow_pump', 'switch.sonoff_th16_cellar', 'switch.sonoff_th16_pump', 'switch.computer_wakeup'), order=3, auto=True, friendly_name=all switches, hidden=True @ 2018-05-01T05:29:20.548326+03:00>>

Okay, on 4th line there is this event change for entity “group.all_switches”. And before that on line 3, there is my computer wake-up call. But what exactly triggers those events, how can I find out (I am using hass.io)? And why this group.all_switches is even triggering as I haven’t mentioned it even once in my configuration?

group.all_switches is one of the default groups, and it contains all the switches (as you can probably guess from the name).

Any time any member of the group turns on, then the group also turns on. That’s why you’re seeing it trigger there.

Ah okay. So group.all_switches didn’t actually turned my computer on, and that makes sense as my sonoff switches for example didn’t turn on that time. So that logger message is nothing to worry about. But on the third line I can see that event state change for switch.computer_wakeup, but how can I find out why what exactly triggered that event? Nobody was using Home Assistant at that time.

It’s simply reporting the change of state there. Not saying that anything triggered.

Now, you can check the Logbook to see if there was an automation that fired. If not, then it was an external event (for example, somebody pushed the button on the PC to turn it on).

Yes, that’s what I am interested in: what exactly triggered that state to change. I am 100% sure that no-one pushed button on the PC to turn it on, because I was alone at home and deeply asleep when that happened :slight_smile: And I don’t tend to sleepwalk :slight_smile:

I didn’t have Logbook active, but now I enabled it, so I will check probably tomorrow (because I think this happens again at some point during night) and report back :slight_smile:

If the PC is in sleep mode there’s many things that can cause it to wake, including a timer set by the OS.

This worked all right for a couple of days, but last night my computer woke up by itself again, and only maybe 20 minutes after I put it to sleep. HA Logger does not reveal anything extra, it just states that my computer turned on. Powercfg reveals that my computer woke up last time because of my ethernet card, which implies that it was a magic packet that woke it up, and nothing else sends those but Hass… There is no scheduled tasks either that triggered in my PC at that time. Frustrating!

Check the NIC in device manager only has magic packet enabled and not wake on pattern match. This used to wake my PC during the night too for whatever reason. WOL stick works fine without pattern match.

Thanks for the tip, I had both settings enabled but I disabled wake-on pattern match now. I guess we’ll have to see what happens.

Disabling wake on pattern match on network card settings did not help: my PC had woken up again last night, this time on 3:17 according to Home Assistant. From PC’s end, it again shows that network card woke it up.

I wonder if there is some way to prevent HASS to flipping switched on its own and ONLY react to this button when user turns the switch on by using GUI? At least that way it would be possible to test if the culprit is Hass or not.

Post the relevant parts of your config. Particularly any automations that could be affecting the switches.

If it’s Home Assistant you’ll see the automation that turns on the WOL switch in your Logbook.

If no automation shows up, it isn’t Home Assistant.

I only have two automations so far, and both of them were off last night (and didn’t trigger either). Logbook only shows that the switch that when turned on, sends that WOL command, was turned on. And that’s the only thing that was logged last night, no automations etc either.

I guess there is no way to tell from Windows logs WHAT exactly caused my NIC to wake up my computer…

I’m not sure - I don’t know enough about Windows. I suspect not though, as at the point the wake up signal (packet, keyboard press, power button press) is received Windows itself isn’t running.