Remote Control Windows PC through IOTLink with MQTT

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”)
    end

    rule “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!

Home Assistant does not have a PaperUI Inbox. The use the Lovelace interface.

Maybe I didn’t word that well. The openHAB MQTT Binding can discover things which announce themselves with the “HomeAssistant-Style” logic.

You mean JSON or YAML? They are both standards unrelated to Home Assistant.

Have a look here:

The MQTT Convention itself was defined by the HomeAssistant project and is available here:

openHAB MQTT Binding simply makes use of the discovery feature (the device transmits the MQTT convention via MQTT and openHAB MQTT Binding figures out how to use it).

There is also the MQTT Homie convention:


https://homieiot.github.io/

1 Like

Thank you for the post, this worklfow is perfect for controlling a windows tablet used as a control hub. Your description was easy to follow and worked as expected.

I run into only two issues when copying your rules: had to change the " character and remove the .lowerCase part from the Display change rule.

(OH3, Rpi3+, Openhabian, Windows10)