Here's a little script I wrote to track when a PC is being used or not, and change a boolean in HomeAssistant based on that. I use it to enhance room-prescence detection, as bluetooth tracking is not very reliable when it comes to tracking RSSI.
- Remove webcam based face detection
- Use
pdm
for dependencies management
Currently only Windows is supported, Linux support will come some day.
- If you don't have it yet, download Python 3.10 from python.org and install it.
- Install
pdm
from https://pdm.fming.dev/latest/ - Install dependencies with
pdm install
- Open config.yaml and enter your HomeAssistant API URL. Could be an IP or a domain name.
- Go to your HomeAssistant -> Profile -> and generate a long lived token
- Paste it into config after
token:
... Well, if you use HomeAssistant you should know YAML :D - Adjust other parameters to your liking
- In the shell type
pdm run python pc_idle.py
and hit enter.
You can also use Windows Scheduler to schedule it to start on boot or login. (Use pythonw.exe to hide the window)