Automate Kasa plugs with PC

I was able to use the Kasa integration to add mt 2 EM plugs to Hubitat.
I briefly used a tplink deco for a router and realized it had a feature to automate the plugs based upon a network device being on or off. I used it to turn on the plug when my pc was on, and off when my pc was off. I would like to do the same using Hubitat.

So when I powered my pc on the plug would turn on powering my wheelbase for my racing simulator rig. It was super convenient because it prevented me from forgetting to power off the wheelbase manually each use.

Is there an easy way to do this based upon wether that device (PC) is online or offline, like the tplink Deco app can do? I see they added some smart functions in the Kasa app but it doesn't work the same with wifi device status.

By PC I assume you mean Windows PC? There are probably a couple of options you could look at.

Perhaps the simplest, though with a small cost involved, would be to use another EM smart plug to monitor the power consumption of the PC, reporting back to HE. You could compare the power consumption when the PC is on and off, then write your rule to detect crossing that boundary, with enough of a fudge factor to avoid unnecessary fails. I use this to remind me I have left the microwave door open to let any smell out from the meal I have just warmed up.

The next thing you could look into would be Power Automate, or whatever they call it nowadays. Basically an old-school scheduled task that could (hopefully) be triggered by the startup or shutdown of the PC. You could write a little Powershell script or whatever flavour takes your fancy, calling a HTTP endpoint setup as the trigger for an RM rule in HE.

The last option, which is probably not ideal for such a simple use case, could be to look at EventGhost. While the setup isn't too difficult, it can be a little cumbersome with a few "moving parts" involved, plus it is no longer supported, I believe. So I would only look at EG if you have no luck with anything else.

2 Likes

Thank you for the reply. Yes, Windows PC. I like the 1st idea option as I already have another EM plug.

Is there a way to detect if a device is online or offline? Maybe write a driver and device to do this?
I assume this could be possible because the device discovery of some apps do this already. I am thinking out loud here.

One other option, which I forgot to mention would be to use some of the custom apps / drivers or Rule Machine to ping the PC periodically. If there is no response then you could power off the smart plug, and vice-versa. I was going to say that this brings some level of complication in that there is polling involved and if the PC is unreachable or there is some other reason the ping request is not being replied to, but each option have elements of these in them, so it would not be any different.

3 Likes