This project integrates into automagically using MQTT Discovery to provide an entity to show whether your computer (Windows only) is Offline, Online or Active.
You can add a MQTT Camera entity by updating your configuration.yaml file, so the currently active window is displayed in your Lovelace UI.
Commands can be published via MQTT to retrieve a current snapshot of the active window or to send a notification that will pop up using the Windows Notification system.
The simplest method to get started is to copy computerassistant.exe from releases to any folder.
Suggestion: add a shortcut to computerassistant.exe in the startup folder.
Alternatively, clone or download the source code, preferably into a virtual environment and run
$ pip install -r requirements.txt
Ensure you have the MQTT Integration added in Home Assistant.
Launch computerassistant.exe or if running from source code enter:
$ python ca.py
The program will appear in the notification area
Select the menu item from the context menu and enter your MQTT server details and credentials in the form.
The broker address must be a valid ip address, the text input control's background will be green when valid else red if invalid.
The broker port defaults to 1883, change this to the port your MQTT broker uses (valid values 1024 to 65535).
Enter the username and password to connect to your broker.
NOTE: The project has only been tested using port 1883 and with a username and password.
When Computer Assistant connects to the MQTT broker it will publish a config message on topic homeassistant/sensor/computer-assistant/{your-computer-name}/config, this will create the device automagically in Home Assistant.
Add the device to Lovelace.
Follow the MQTT Camera instructions to configure the virtual camera in your configuration.yaml.
Example
camera:
- platform: mqtt
topic: computer-assistant/sensor/Workstation/screenshot
name: Workstation Active Window
unique_id: Workstation
NOTE: Replace Workstation with your computer's name.
This will create a camera entity that you can then add to Lovelace.
In Lovelace UI select the Computer Assistant Sensor.
This will show the sensor details.
You can see the history of when the computer was offline, online and active.
The last active time is displayed and the currently active window if applicable.
Selecting the camera is just like any other camera feed, it will display a larger image in its own window.
There are only 2 commands, screenshot and notify, to use these publish a message via MQTT.
The screenshot command will instruct Computer Assistant to send an updated image of the active window.
topic:
computer-assistant/sensor/{your-computer-name}/cmd/screenshot
The notify command will create a notification in the Windows Notification
topic:
computer-assistant/sensor/{your-computer-name}/cmd/notify
payload:
{ "title": "Test", "message": "A test" }
To adjust the various timings in Computer Assistant, select the Timings tab in the Settings dialog.
Update Frequency
Controls the interval time the program will check for activity and publish MQTT messages. Default 15 seconds.
Active Status Timeout
Controls how long before the program determines that the computer is no longer active if no mouse or keyboard events are detected. Default 120 seconds.
MQTT Connection Timeout
Controls how long before the program determines that a connection attempt to a MQTT broker has timed out. Default 30 seconds.
This project was initiated mainly as a programming exercise to test my recently gained knowledge of Python, to learn Qt and to send notifications to my computer from Home Assistant automations in Node-Red.
This is my first public repository on Github, the code is far from perfect but works!
I don't have any particular plans for developing other features other than automating the MQTT Camera configuration, but I'd like to have it work on Linux too. However, if there's a particular killer feature you'd like then complete a feature request.
I will try to help anyone having issues installing, configuring and using Computer Assistant where possible. To obtain support please complete a bug report.