Launch Netflix Windows App on a windows computer via MQTT

windows
mqtt
netflix
Tags: #<Tag:0x00007f0e8a159628> #<Tag:0x00007f0e8a1594e8> #<Tag:0x00007f0e8a1593a8>

(Alain) #1

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


(Thomas Bail) #2

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


(Alain) #3

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.


(Alain) #4

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

(Matthieu Lauzon) #5

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…