Here’s the setup I use to launch the Netflix windows 10 application via mqtt.
(you need java on the PC and an MQTT server)
I used Winthing to handle MQTT request in windows
I won’t go in the details, but here’s the process
- Download winthing jar to c:\Winthing
- Create a Winthing.bat file to launch Winthing with the correct parameters (MQTT Server IP,username and Password)
- We need to create a shortcut to the Netflix App and put it in c:\Winthing
- Create a StartWinthingInBackground.vbs file to lauch Winthing at each startup
- Create a Item PCControl in Openhab to receive the command we will send to the PC
- Create a rule that will sent the MQTT request (Need the MQTT Action installed in openhab)
- Create a Sitemap to test if it’s working
On the Windows PC
Here’s the batch to launch Winthing change the IP, username and password to your MQTT server
c:\Winthing\Winthing.bat
cd C:\Winthing\
java -Dwinthing.brokerUrl=tcp://192.168.1.101:1883 -Dwinthing.brokerUsername=openhabian -Dwinthing.brokerPassword=mypassword -jar winthing-1.1.0.jar
To create the Netflix.lnk shortcut paste this in windows explorer, right-click create shortcut and move it to C:\Winthing\Netflix.lnk
`%windir%\explorer.exe shell:::{4234d49b-0245-4df3-b780-3893943456e1}`
Here’s StartWinthingInBackground.vbs tu be created in %appdata%\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
StartWinthingInBackground.vbs
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run """" & "C:\Winthing\winthing.bat" & """" & sargs, 0, False
Set WshShell = Nothing
Now for Openhab
PControl.items
String PCControl "PC Action" <switch> { autoupdate="false" }
PCControl.rules
rule "rPCControl"
when
Item PCControl received command
then
logInfo("rule rPCControl", "command "+receivedCommand)
switch (receivedCommand) {
case "reboot" :
publish("broker", "winthing/system/commands/reboot", "")
case "shutdown" :
publish("broker", "winthing/system/commands/shutdown", "")
case "netflix" : {
publish("broker", "winthing/system/commands/run", "[\"Netflix.lnk\",\"\",\"\"]")
// Wait 5 seconds and send WIN+SHIFT+ENTER to go Fullscreen
Thread::sleep(5000)
publish("broker", "winthing/keyboard/commands/press_keys", "[\"LWIN\",\"LSHIFT\",\"ENTER\"]")
}
}
end
And finally the sitemap
PCControl.sitemap
sitemap PCControl label="PCControl" {
Switch item=PCControl mappings=[reboot="Reboot PC", shutdown="Shutdown PC", netflix="Launch Netflix"]
}
Hope this help and I didn’t make to many typos … Aymeric
Edit:
Simulate WIN+SHIFT+ENTER keypress to go fullscreen
Change 1 to 0 to hide the console in StartWinthingInBackground.vbs