Launch Netflix Windows App on a windows computer via MQTT

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

2 Likes

Thats great, but why did you build that. I am sitting usually in front of my PC …

I have a small PC connected to my TV with HDMI.
It’s part of my home cinema setup.

Now I have added Kodi on a RPi3, but Sadly Netflix is not supported (or stable) yet.

More over, always convenient to have a PC connected to the big screen.

Edit: I don’t use the keyboard or mouse most of the time. I use Unified Remote.


So the less click is needed the better.

Small Edit: Simulate WIN+SHIFT+ENTER keypress to go fullscreen

        Thread::sleep(5000)
        publish("broker", "winthing/keyboard/commands/press_keys", "[\"LWIN\",\"LSHIFT\",\"ENTER\"]")

And also hide the Winthing console in StartWinthingInBackground.vbs

was

WshShell.Run """" & "C:\Winthing\winthing.bat" & """" & sargs, 1, False

now

WshShell.Run """" & "C:\Winthing\winthing.bat" & """" & sargs, 0, False
1 Like

I am from Homeseer. I tried in the past to make this run. THis time i Followed your instruction and it works!!!

i think moving the -jar from the begining to the end was the key…

Some time ago, but how I get the jar file?
Greetings

Hello I hope you found it by now, but you’ll find it here

Aymeric

Hi. I have just successfully set up WinThings and I thought I would add some further information if anyone else is taking this route.

Firstly, the WinThing version and parameters have changed slightly, so if you are using the code examples above, please check against the updated documentation on GitHub.

Secondly, I tried to get this to run as a service (rather than requiring a Start Menu shortcut) using NSSM. After a lot of playing around, I concluded that it does not work (I could get it to sucessfully start, but any applications that were launched would not be visible, despite setting the “allow to interact with desktop” or changing service account to my own.) If anyone has been successful at this, it would be good to know how.

Thirdly, it seems odd that there isn’t an easier way to trigger automated actions on a PC, given the move towards automation in both home and business. Microsoft have Power Automate, but you have to pay for the development capability. If there is some kind of OpenHab way of doing this, please let me know!

FYI, the scenarios I have are primarily for videconferencing via headless computers (so I can say “Hey Google Skype Mum from Living Room”, but I would have thought there are many many other things that can be done with this kind of automation.

see here also if interested.
Not tested

I use AssistantComputerControl. The upside is that it’s easy to get it going. The downside is that it requires IFTTT. I haven’t been able to get it to work locally.

Thanks both. IFTTT is a non-starter for me, so I will check out IOTlink.