Hi all,
I try to send a command via MQTT to my PC running iotlink.
Goal of this exercise is to switch my Display from the internal (Display 1) to the external (Display 2) via Displayswitch.exe
Using the information from the official IOTlink Gitlab wiki for running an application: https://gitlab.com/iotlink/iotlink/-/wikis/Addons/Commands
My rule looks like this:
rule "R1_Virt_Konsole_On"
when
Item R1_Virt_Konsole_switch received command ON
then
R1_Computer_switch.sendCommand(ON)
R1_Fernseher_switch.sendCommand(ON)
R1_Computer_Boxen_switch.sendCommand(ON)
val actions = getActions("mqtt","mqtt:broker:mosquitto")
actions.publishMQTT("desktop/workgroup/desktop/commands/run","{"command": 'C:\\Windows\\System32\\Displayswitch.exe', "args": '/external', "visible": false, "fallback": true}")
Thread::sleep(5000)
R1_Virt_PC_switch.sendCommand(OFF)
R1_Virt_Computer_switch.sendCommand(OFF)
end
rule "R1_Virt_Computer_TV_enable"
when
Item Desktop_state changed from OFF to ON
then
if (R1_Virt_Konsole_switch==ON)
{
val actions = getActions("mqtt","mqtt:broker:mosquitto")
actions.publishMQTT("desktop/workgroup/desktop/commands/run","{"command": 'C:\\Windows\\System32\\Displayswitch.exe', "args": '/external', "visible": false, "fallback": true}")
}
end
rule "R1_Virt_Konsole_Off"
when
Item R1_Virt_Konsole_switch received command OFF
then
if (R1_Virt_Computer_switch.state==OFF && R1_Virt_PC_switch.state==OFF)
{
logInfo("PC", "Konsole ausgeschaltet")
val actions = getActions("mqtt","mqtt:broker:mosquitto")
actions.publishMQTT("desktop/workgroup/desktop/commands/run","{"command": 'C:\\Windows\\System32\\Displayswitch.exe', "args": '/internal', "visible": false, "fallback": true}")
Thread::sleep(1000)
actions.publishMQTT("desktop/workgroup/desktop/commands/shutdown"," ")
Thread::sleep(500)
}
if (R1_Virt_Computer_switch.state==OFF)
{
R1_Computer_Boxen_switch.sendCommand(OFF)
}
if (R1_Virt_Fernseher_switch.state==OFF)
{
R1_Fernseher_switch.sendCommand(OFF)
}
end
Sneding the payload via mqttfx works perfectly and switches the display.
I get the following erros in openhab.log:
2020-12-14 18:09:15.116 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'R1_Virt_Konsole.rules'
2020-12-14 18:09:15.117 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'R1_Virt_Konsole.rules' is either empty or cannot be parsed correctly!
2020-12-14 18:09:16.138 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'R1_Virt_Konsole.rules' has errors, therefore ignoring it: [10,65]: missing ')' at 'command'
[10,176]: mismatched input ')' expecting 'end'
[24,66]: missing ')' at 'command'
[24,177]: extraneous input ')' expecting '}'
[37,66]: missing ')' at 'command'
[37,177]: mismatched input ')' expecting '}'
[41,3]: mismatched input '}' expecting 'end'
I tried adding â instead of " before and after the payload, which renders this section useless.
Is there anything I can try to just send the payload without openhab checking what is in there?