An agent that let's you control and query a computer (also Windows PC) via MQTT

Hey,

I wrote a nodejs based agent that you can install on a machine (also on Windows as a windows service) and then send it MQTT messages to execute certain predefined commands. It can also run certain commands regularly and post the result back to MQTT.

You can execute anything you can run on a command line. For example: check processes, restart services, shutdown, check status of updates, etc.

On Unix based systems you can probably SSH from HA to do this but for Windows I needed a different solution.

More information at: https://github.com/ayavilevich/mqtt-win-exec

Happy to get your feedback.

1 Like

It’s a great job, but what are the advantages over IOT Link? IOT Link looks a bit easier to set up and offers at least the same features, right?

https://iotlink.gitlab.io/

But no matter what, cool project and good work. :+1: Maybe you and the developer of IOT Link could also join forces :wink:

Great question :grinning:

The short answer is that I am using this together with IOTLink. mqtt-win-exec compliments IOTLink for me.

The long answer is that IOTLink has unresolved bugs and it seems maintenance is not as good as it used to be. Sometimes it stops monitoring after waking from sleep (Disconnecting from MQTT server after sleep/wake. Not reconnecting. Having "MQTTClientManager::OnMQTTDisconnectedHandler() - DUPLICATED Disconnected Event" (#118) · Issues · IOT Link / IOT Link Service · GitLab), sometimes is gets stuck so hard you need to kill the process, you can’t even restart the service. With mqtt-win-exec I keep an eye on IOTLink, can kill and restart it from remote if needed.

IOTLink gives me certain fixed sensors and screen grab features.
mqtt-win-exec adds the ability to run commands from a set of pre-defined commands. I have disabled the “run any command you want” functionality in IOTLink due to security concerns (Suggestion: Remote execution security issue (#89) · Issues · IOT Link / IOT Link Service · GitLab).
Also, mqtt-win-exec can run a command periodically and return the output as a topic. I don’t think IOTLink does that. So you could define your own custom sensors using data you pull from the PC.

My C# is not strong enough to actually participate in the development. Helping as much as I can by submitting issues, troubleshooting, etc.

How do you use IOTLink? Does it work better for you than for me?

Arik.

1 Like

Hi Arik, thanks for your answer and clarification.
That sounds logical and interesting. I will definitely have a look at your program.

To be honest, I’m using very few features of IOT Link so far. Most of it I have deactivated. From the sensors I only use the CPU and ram consumption, and the network status. Apart from that I have a switch in HA which I can use to switch off my PC via IOT Link and switch it on via WOL.
So far everything has always worked perfectly.

So you have invented cron?

1 Like

Makes sense. I have a feeling that the bugs in IOTLink are related to laptops that sleep/wake and that have more than one network interface. Possibly it listens on the wrong interface or something like that.