PC Idle Monitor

Hello everyone!

This is my first project for Home Assistant integrations. Over the past few days, I’ve been working on a lightweight way to monitor if your PC is idle. Currently, I don’t have any plans to add more sensors or commands to the project, but if I see a reason to beef it up a little, I might consider it.

I created this because I’ve seen a few projects out there that do something similar, but they’re often not what I would consider “light”. I borrowed some of the code from another project (Win10As) to make this. I gave the repository a try, but on an i7-8600K and it was using between 10-12% of the CPU when it was somewhat idle.

I have plans to create an installation wizard in the future, but I figured I would get some feedback to see if it was useful to people before getting too involved… Please let me know what you think! If you run into issues, please read the instructions on the readme - there is a section on how to contact me if the project is failing to run.

May I ask, what is the use case? Read your post and read guthub but can’t think of any :upside_down_face:

Same use case as this - https://github.com/KjetilSv/Win10As

I created it to monitor whether I’m in the office or not. I have 3 computers in here, I don’t move very often, and I’d prefer to have the lights turn on automatically when I’m working and it gets dark. Judging by the other repository and the amount of people commenting on his thread in this community, several other people have already found a use case for monitoring their PC in home assistant. Not sure why you can’t think of any :upside_down_face:

1 Like

Ok, thanks, that sounds ok. I have a motion sensor in my office.

— I don’t know what I don’t know —

1 Like

Unfortunately, motion sensors don’t work for me in my office :slightly_frowning_face: I’ve tried and I’m too still, even when the motion sensor is right in front of me :laughing: I literally had it sitting 3 feet away from me at one point and the lights would turn off while I was gaming or working with a 30 minute timer.

1 Like

I’ll be watching this - similar problem with motion sensors. :slight_smile: If you are taking suggestions can you make it so you can put the PC to sleep?

1 Like

I’m up for suggestions, but I’m not planning on giving home assistant control of my computer. It’s not that I don’t trust home assistant, but I don’t feel like that is something I want to do with this project. Partially because I’m trying to avoid creating an MQTT subscriber for this project, but also, there is a really good solution for this use case. I don’t recall the name of the project off the top of my head, but I’ll send a link as soon as I can find it.

understood and appreciated :slight_smile:

1 Like

@tachikoma1373 so one tool that is already baked into Home Assistant is RPC Shutdown. From what I can tell, this is probably one of the more secure ways of remotely shutting down a PC, but it also appears to be slightly difficult to set up. However, it’s also something that Windows supports directly and would probably be the “lightest” solution for your PC.

The other, slightly easier way, to control your computer would be TriggerCMD. I’m pretty sure I’ve set up an integration with TriggerCMD and Home Assistant in the past, but I eventually decided I didn’t want it… I think mainly because I didn’t want a remote computer automatically making decisions about my main computer’s power state, but I’m not sure.

There are other tools out there as well. I also feel like it wouldn’t be overly difficult to set up an MQTT subscriber service to send your computer a command to run shutdown /r /t 30, which would shut your computer down in 30 seconds, but I also feel like that would be less secure than the ways I mentioned above… Someone might prove me wrong though; I’m not a security expert :laughing:

1 Like

its sleep I’m after and I’m trying to avoid the cloud except for google and ikea. I’m no coder but learning all the time. I’m just about to styart experimenting with SleeponLan but curently battling with getting my head round zigbee2mqtt and the joy that is getting zigbee devices to pair :slight_smile:

Did you also try IOT link? Would be interested to know if it also uses a lot of resources. Maybe I’ll test myself, but haven’t found a usecase for it yet.

1 Like

I haven’t heard of IoT link, I’ll definitely have to take a look. I’ve been trying to find a good solution for a very long time, so I’m surprised I missed it :rofl:

Just discovered this: Integrating Win10 In HA with MQTT - which on reading seems to be an older version of IOT link

@Burningstone To answer your question, it runs much lighter than the Win10As project listed above. I’m not a massive fan of the fact that you can’t completely customize what sensors are running on it, but it seems like a solidly made project (I glanced through the code as well). I turned off the “Commands”, kept the rest. It uses between 0.4% - 1.2% of my i7-8700K and uses around 60-150 MB of ram. Again, not sure how I missed this project… Was definitely what I was looking for. Thanks for the suggestion.

@tachikoma1373 you should check this project out: https://iotlink.gitlab.io/downloads.html. It includes everything you mentioned you were looking for above and it runs as a background service… much less distracting (to me anyway, lol).

1 Like

Got IOTlink installed and configured (ish) Not got round to doing the switches yet but it looks good. Thanks for the heads up.

@adga2012 I’ve been trying to use your monitor, but the sensor only returns true. I’ve tried leaving the PC alone for more than 10 minutes, but still. After how long will it report that the PC is idle? Thanks

Hey @lumberjakk_89, sorry I haven’t replied… I haven’t even checked up on this thread in over a year, nor the project… I ended up trying iotlink.gitlab.io and that was working better for me than my project. Sorry for the confusion.