I have a question. I enabled Wake On LAN in HA to turn on my PC remotely. This works like a charm, no problems there.
My HA GUI now has a switch I can use to turn on my PC. However, if I turn on my PC manually, with its own power button, the switch in HA activates as well.
Is there anyway to detect if the switch activated because I switched it on, or because it detected that my PC turned on and decided to activate because of that…? I wasn’t able to find anything about this online. Any help appreciated.
I think I might have found a solution. The Wake on LAN platform uses the host’s IP address (i.e. ping) to check if the computer is on or off. So if I turn on the PC with its own power button, it will be pingable at the moment the switch changes state.
However, if the PC is turned on remotely, the switch will change state but the PC will not be pingable yet. So I think that will allow me to differentiate between a manual turn on and one from HA.
a simpler solution might be to have your HA Switch also turn on/off an input boolean. if the switch is on but the boolean isnt, then the computer was turned on without the HA Switch
Hm. But it’s a ‘platform: wake_on_lan’ switch. Can I make it do other stuff as well? I’m fairly new to HA, so I’m still learning.
ah, i thought it was a template switch with the “wake on lan” as the service it called when turned on.
(with a template switch, you define how the state of the switch is determined, as well as what actions turning it off and on cause. these three aspects can all be totally independent of each other)
The question is - why do you want to do that? If it’s to see if HA turned it on, then HA will only do that via an automation (or you clicking on the switch in Overview).
You could use a template switch to turn both on and off, you could build an automation that turns on the boolean when the switch is on, and so on.