Remote Windows / Linux shutdown / standby via MQTT

Hi all,

I’ve wrote a small integration that exposes Windows or Linux machine to HASS via the MQTT. The reasoning to have it, is to enable a lighweight capability to shutdown / hibernate or put the remote machine to standby without bothering with hostnames or IP addressess. After the app is started it just announces itself to the MQTT integration and exposes a switch which is ON when machine is online and sends the immidiate shutdown command when toggled to OFF.

The code and precompiled binaries are available in the repo. Feedback and ideas are welcome.

2 Likes

Hey there @beerhead Are you still interested in feedback for your pc2mqtt?

I thought this looked interesting and simple, so I’ve played around with it. I finally got things working on my windows servers, the device shows up in HA but the switch shows “Unavailable”. I 've restarted HA as well.

image

This is running on a Windows Server 2016 VM

Also, after the first round of building the executable and attempting to run it (albeit I had the host argument wrong) I was getting the following error

C:\Utility\pc2mqtt\pc2mqtt-main\pc2mqtt-main\dist>pc2mqtt-0.1.0.exe --192.168.71.4
Traceback (most recent call last):
  File "pc2mqtt\app.py", line 3, in <module>
  File "PyInstaller\loader\pyimod02_importers.py", line 378, in exec_module
  File "pc2mqtt\__init__.py", line 8, in <module>
ModuleNotFoundError: No module named 'paho'
[PYI-14164:ERROR] Failed to execute script 'app' due to unhandled exception!

I had to run the following

pip install paho-mqtt

And then realized after I install paho-mqtt, that I had to re-build pc2mqtt-0.1.0.exe. Might be nice to include some notes about this particular error and the steps required to fix it. Just my .02.

Anyway, If I can get this switch to work in HA, this will be a fantastic simple way to gracefully shutdown my UPS’ed Windows PCs during a power outage.