Hello Community,
I found this nice way to control a Windows PC through MQTT called IOTLink: https://gitlab.com/iotlink/iotlink
Expects the MQTT Binding and a MQTT Broker to be installed on your openHAB2!
Download the latest release: https://gitlab.com/iotlink/iotlink/-/releases
and install it. Make sure to install both Add-Ons!
Now open the folder “C:\ProgramData\IOTLink\Configs” and edit the “configuration.yaml”.
- Put in your MQTT connection
- Make sure addons are enabled
- HomeAssistant discovery is now supported by MQTT2 binding, make sure it is enabled and you can add the things on the PaperUI inbox
In C:\ProgramData\IOTLink\Addons\ you find the add-on configuration.
- Open each addon.yaml and make sure the addon is enabled
- In the WindowsMonitor folder open the config.yaml and change the settings to what data you would like to see and in what frequency (10s will spam your logs)
Open your windows task manger and under services make sure the IOTLink service is running.
Now open PaperUI and in your Inbox should show the automatically discovered things. Add them here. Now you can make items and see your PC Status.
In order to control the PC, you have to manually configure the things and items and rules, see my example below
-
Replace YOURBROKER and YOURPC (e.g. yourname-desktop). It is the same as in the automatically discovered items. Or use a MQTT tool like MQTT.fx to find the mqtt channels.
-
The rules take the state name of the IOTLink_Windows item and send a command to the endpoint to hibernate/shutdown etc. the PC. Similar for the Display. It is a strange implementation of MQTT but it works!
-
It is possible to implement more commands through items and rules, see here: https://gitlab.com/iotlink/iotlink/-/wikis/Addons/Commands
// IOTLink THINGS
Thing mqtt:topic:IOTLink “IOT Link MQTT” (mqtt:broker:YOURBROKER) {
Channels:
Type switch : mute “Mute” [ commandTopic=“iotlink/workgroup/YOURPC/commands/volume/mute”, on=“true”, off=“false”]
Type dimmer : volume “Volume” [ commandTopic=“iotlink/workgroup/YOURPC/commands/volume/set”, min=0,max=100,step=1 ]
}// IOT Link ITEMS
Group gIOTLink “IOT Link” (gAll)
Switch IOTLink_Mute “Mute” (gIOTLink) {channel=“mqtt:topic:IOTLink:mute”}
Dimmer IOTLink_Volume “Volume [%.0f]” (gIOTLink) {channel=“mqtt:topic:IOTLink:volume”}
String IOTLink_Windows “Computer [%s]” (gIOTLink)
Switch IOTLink_Display “Display” (gIOTLink)// IOTLINK SITEMAP
Text label=“IOTLINK SITEMAP” {
Default item=IOTLink_Mute
Default item=IOTLink_Volume
Selection item=IOTLink_Windows mappings=[“hibernate”=“Hibernate”,“shutdown”=“Shutdown”,“reboot”=“Reboot”,“suspend”=“Suspend”,“lock”=“Lock”,"
Default item=IOTLink_Display
Default item=IOTLink_CPU_Usage
}// IOTLink Rules
rule “IOTLink Windows Control”
when
Item IOTLink_Windows changed
then
Thread::sleep(500)
val mqttActions = getActions(“mqtt”,“mqtt:broker:YOURBROKER”)
val String topic = “iotlink/workgroup/YOURPC/commands/” + IOTLink_Windows.state
mqttActions.publishMQTT(topic,"")
Thread::sleep(500)
IOTLink_Windows.postUpdate(“none”)
endrule “IOTLink Windows Display”
when
Item IOTLink_Display changed
then
Thread::sleep(500)
val mqttActions = getActions(“mqtt”,“mqtt:broker:YOURBROKER”)
val String topic = “iotlink/workgroup/YOURPC/commands/displays/” + IOTLink_Display.state.toString.lowerCase
mqttActions.publishMQTT(topic,"")
end
Have fun!