[RELEASE] PC Motion Sensor

Actually I think I get now what you meant about turning on your lights, i.e. you were worried about it happening while you are not in the room / house. That will come down to how you use the virtual motion sensor device within rules on your HE hub. I have mine setup to keep a motion lighting "rule" active, rather than being the trigger, the trigger to turn the lights on is still my physical Hue motion sensor.

It should be pretty easy to also check for my presense = true, before turning/keeping lights on.

1 Like

Thanks, I've got it working.

  1. Instructions were easy to follow until I got to an issue, which is easily rectified. The file PC_VirtualMotionSensor.vbs contains a reference to your subdirectory. My setup didnt work until I pointed it to my subdirectory. It would be good to fix that, if possible.
  2. Is there a way to create a task that sends inactive upon shutdown? Thinking about this, if the computer shutsdown, it wont send an inactive. Lights will remain on. This may be helped by 3 & 4.
  3. There is also a need to turn off "auto inactive" on the device page. It's a pity that we can have auto inactive set at 5 minutes. Someone on these forums was asking recently for the ability to set it at 5 minutes. Was that you?
  4. It could be possible to ping the IP of the computer, and if it's not present, then set the device as inactive.
2 Likes

Glad you got it working.

1 - Good pickup, I'll update the instructions or code, I should be able to leave out the directory I would expect.

2 - I'd been thinking the same thing for a couple of different things like shutdowns, screen saver, putting the pc into sleep, etc. Certainly on my list.

3 - Again good pickup, I did that on my setup but forgot to include it in the instructions. I plan to setup a rule to do it, and had the same thought as you about how it was a shame there was no 5 minute auto-inactive. I don't think it was me requesting the change...

4 - Good idea, not sure whether web pinger could be useful here or something similar...

Thanks again for testing it out and giving the feedback.

Simon

1 Like

I updated the VB Script to remove the full path to the Powershell script, but needed to update the Task Scheduler Action setup and instructions to include setting the Start-in folder for the action.

I also did various updates to the Readme, but nothing that you would need to change, just wording used and some steps to validate the install and setup.

I created an enhancement ticket on my GitHub repository to look at the inactive update when the PC shuts down. I might setup a few more at some point to look at some of the other scenarios I was interested in like when the PC is locked or the screen saver is activated.

I took a look at web pinger and it wants a web URL, so not something I could use to check for the PC being available, but I'm sure there's something else that does that. I'll keep looking.

Simon

what about using something like this, and while your computer is successfully pingable, it'll keep the lights on

1 Like

That's what I had in mind, however, I've gone with auto off in Hubitat after 1 minute, and getting the powershell script to check every minute, so that means it's going to auto off 1 minute after the last "active". It's been working well in my office, which doubles as my gaming station in the evenings.

It's already added into my Node Red logic, and working very well. Thanks @sburke781

1 Like

Great to hear it's working for you @mike. I'd be worried about the auto-off switching it off when it shouldn't, but sometimes you need to just try these things and if they work just run with it.

@dadarkgtprince - I'm not sure whether the http presence app/ driver would work if you don't have an endpoint (web server) running on the PC? I didn't read too much of the description, so will keep reading...

you can alter it a bit to fit your needs. i use it to ping my phone, which i'm not hosting a web server on. i think code 408 is if it can't be reached, and code 200 is if it can reach it but no active web server to ping. i forgot the exact codes, but it's something like that. updating the driver to look for those codes without hosting a web server has worked great for me

1 Like

I have installed both the HTTP Presence and iPhone Presence drivers, but infortunately I get a connection timeout for my laptop. The iPhone one works with my mobile phone (Pixel 2XL) and the HTTP one works with checking my Grafana install on my rpi is up, so they will come in handy, just not for checking my laptop is online.

I might just write a little script to run on my laptop as a heartbeat, essentially just updating a presence device on the hub every X minutes, rather than the HE hub calling out to the laptop.

Thanks for the tip on the drivers though, like I said, they'll come in handy for other things I'd like to setup.

Anyone actively using this project, or have a diff project to recommend? I'm looking to accomplish the same objective (keep lights on despite PIR sensor going inactive while at computer). I installed this project from github, seems to all be firing and talking ok, but the PC only reports back inactive to the virtual sensor.

Log for the scripts shows:
2021/11/26 12:14:02 INFO inactive, Last Activity 1218116.156 seconds ago

So it seems like it isn't successfully getting the status from my PC. I'm running windows 11. I see no errors or anything interesting in the windows event viewer. Ideas?

I still have it running on my Windows 10 PC. Haven't really kept an eye on how well it is still working. Let me take a look.

Mine still appears to be detecting my mouse and keyboard actions as activity. It does rely on some Windows-related calls from memory, so maybe those are different in Windows 11...

As an alternative, I also setup rules for an old Samsung button sitting on my desk that puts my Study into "work mode", which turns on my TV that I use as a monitor (via my Harmony Hub), sends a WOL command to my PC, turns the lights on and disables my motion lighting rule. May not work for everyone, but you may get something out of it.

I’m beyond my depth on this one, so I’ll probably take a diff approach like you did with the button. Thanks!

1 Like

bah...

image

Hmmm.... Have you just tried installing this now, or has this just started happening on an existing install?

Are you running Windows 10 or 11? Or another version?

It's also weird because there are only 3 lines in the vbs script.... Perhaps check the path to your PowerShell install?

new install.

I scewed up a file extension. oops :stuck_out_tongue:

but struggling to understand instructions here:

From here.....

...what do I put into here...

image

?

Looks like you got it right... Is it not working, or you were just unsure about the settings?

Can't get it working..

Did you add the motion sensor to the device list in Maker API?