After a long long search for a simple way for a bi-directional communication between my PC and Home-Assistant, i decided to develop a small Mqtt client called “Mqtt Control”. this client allows me to send messages to my desktop and display them, lock, shutdown or restart my computer. i can even take a snapshot of my desktop and send it back to Home-Assistant as Mqtt Camera image. more than that i can send telemetry from the computer to Home-Assistant that contains CPU usage and Temperature, Free and Used Memory, HDD info and more.
The client is Dot.Net framework based and can be downloaded from here: https://sourceforge.net/projects/mqtt-control/.
after the installation complete, go to the application path under program files and this is how it looks like:
The sample configuration files folder contains yaml files for the Home-Assistant configuration.
there is another files called MqttControl.exe.config which is the Application Configuration file, this file contains the application configuration of the mqtt server (Broker) Address, Username and password etc.
- mqttserver: The Mqtt broker Address.
- mqttuser: The Mqtt Username (default is homeassistant)
- mqttpass: The Mqtt Password.
- devicename: The name of the pc (used in topic name, like “/homepc/restart”).
- updateinterval: Interval for sending Telemetry to Home-Assistant (in seconds).
- autoSnapshot: Automaticly Include Snapshot in the Telemetry (by interval).
- publishDriveInfo: Include Drive info in the Telemetry.
- debugMode: create file called “debug.json” that contains the published data.
in order to control / send messages to your pc use the following topics:
- Restart: /pc_name_in_config/restart/
- Shutdown: /pc_name_in_config/shutdown/
- Lock: /pc_name_in_config/lock/
- Restart: /pc_name_in_config/restart/
- Send Message to the desktop: /pc_name_in_config/message/ and payload {“message”:”Text to diasplay”}.
- Take snapshot: /pc_name_in_config/snapshot/
*** Important Note: Set the Application to run as administrator, it is needed for getting the cpu data ***
That’s really nice.
Just for information there’s others MQTT clients for Windows :
-EventGhost with the MQTT plugin
– mqttclient
I really like EventGhost because it is really powerfull and once you understand how it works it is very quick to trigger MQTT events or action after receiving a MQTT message.
Some links :
http://www.eventghost.net/forum/viewtopic.php?f=9&t=5728&p=52756#p52756
https://community.home-assistant.io/t/integrating-win10-in-ha-with-mqtt/19563