Microsoft Media Center Plugin (WMC or MCE) for Vera Control

0.1 Alpha build of a Microsoft Windows Media Center that has been tested with a few buttons in scenes.

  1. Install VMC Controller on your WMC PC
    x32 - http://vmccontroller.codeplex.com/releases/view/23251
    x64 - http://vmccontroller.codeplex.com/releases/view/45909

  2. Test from ANOTHER MACHINE THAN YOUR WMC, that you can telnet to port 40500 to ensure your firewall settings are correct.
    This CMD: “telnet yourWMCip 40500”
    Should get something like this: “204 Connected (Clients: 2 Version: 0.1.0 Build Date: 5/25/2010)”

  3. Since PLEG now supports LUUP in the actions, I will not be continuing this plugin. You can paste this Luup code below in a normal Scene (in Luup tab) or in PLEG actions (need 6.0+).

Send a WMC command from this list (replace “goto start” variable of wmcCmd): http://vmccontroller.codeplex.com/wikipage?title=Commands

local wmcCmd = "goto start"
local socket = require("socket")
wmchost = "192.168.0.100"
tcp = assert(socket.connect(wmchost, 40500))
tcp:send(wmcCmd .. "\r")
tcp:close()

Message Box (msgbox “caption” “message” ):

local wmcMsg = "This is a Test"
local socket = require("socket")
wmchost = "192.168.0.100"
tcp = assert(socket.connect(wmchost, 40500))
tcp:send("msgbox \"Test\" \"" .. wmcMsg .. "\" 15")
tcp:close()

Update 192.168.0.100 to the IP address you have WMC with VMC Controller

Hope this helps you WMC’ers out there :smiley:

PS - Attachments kept for reference only. They are not needed with the LUUP commands above.

Glad to hear that someone is developing a media center plugin ;D

Ok, a working Alpha Build 0.1 has been uploaded.

ToDo:

Variables:
I need some additional research on how to provide the following variables to the actions. For example, a scene controller has 2 variables for the setlight.
1 Variable (URL): PlayVideo, PlayAudio, Goto ExtensibilityURL
3 Variables (“Title” “Message Here” “TimeoutSec”): MsgBox

Speed:
Currently takes about 6 seconds to fire first command. VMC Controller can keep socket open, so I will investigate how to speed this up by not closing the connection.

Logging:
Ideally, I would log the result of the command from the WMC server (success/fail).

OK, I am in. Not ready to test on main Media Center DVR, but I have a secondary I can use for testing…

Since PLEG now supports LUUP in the actions, I will not be continuing this plugin. I entered working Luup code for WMC commands (play, pause, etc.) and a message box samples in step #3 to copy and paste.

Cheers!

PS - I’m using this streamlined code to use with VoxCommando and WMC Message box on the same PC:

--TTS and WMC Server
ttsHost = "192.168.0.100"

--TTS Funtions
function ttsAlert(ttsAlertName)
     local socket = require("socket")
     local udp = socket.try(socket.udp())
     socket.try(udp:sendto("VC.TriggerEvent&&" .. ttsAlertName, ttsHost, 33000))
end
function ttsMsg(ttsMsg)
     local socket = require("socket")
     local udp = socket.try(socket.udp())
     socket.try(udp:sendto("tts.speak&&" .. ttsMsg, ttsHost, 33000))
end
function tvMsgBox(wmcTitle,wmcMsg)
     local socket = require("socket")
     tcp = assert(socket.connect(ttsHost, 40500))
     tcp:send("msgbox \"" .. wmcTitle .. "\" \"" .. wmcMsg .. "\" 8")
     tcp:close()
end
--General
function HTTPGet(URL)
     local status, result = luup.inet.wget(URL, 3)
end

You can than call the functions:

ttsAlert("Motion") ttsMsg("Outdoor Sensor Warning,, Motion Detected in the Downstairs Patio Lawn") tvMsgBox("Outside_Motion","Motion Detected in the Downstairs Patio Lawn")

Example of how to call a camera webpage when motion is detected in WMC, and then return to the playing media (which was a small PIP window) after 15 seconds to full screen.

In this example, it also tells my ISpy camera server to start recording.

--TTS and WMC Server
ttsHost = "192.168.0.100"

--TTS Funtions
function ttsAlert(ttsAlertName)
     local socket = require("socket")
     local udp = socket.try(socket.udp())
     socket.try(udp:sendto("VC.TriggerEvent&&" .. ttsAlertName, ttsHost, 33000))
end
function ttsMsg(ttsMsg)
     local socket = require("socket")
     local udp = socket.try(socket.udp())
     socket.try(udp:sendto("tts.speak&&" .. ttsMsg, ttsHost, 33000))
end
function tvMsgBox(wmcTitle,wmcMsg)
     local socket = require("socket")
     tcp = assert(socket.connect(ttsHost, 40500))
     tcp:send("msgbox \"" .. wmcTitle .. "\" \"" .. wmcMsg .. "\" 8")
     tcp:close()
end
--General
function HTTPGet(URL)
     local status, result = luup.inet.wget(URL, 3)
end
--iSpy Result
function iSpyStartRecord(Camera)
     local status, result = luup.inet.wget("http://192.168.0.100:8080/record?ot=2&oid=" .. Camera, 2)
end

function iSpyStopRecord(Camera)
     local status, result = luup.inet.wget("http://192.168.0.100:8080/recordstop?ot=2&oid=" .. Camera, 2)
end
--WMC Functions
function GoToUrl(GoToUrl)
     local socket = require("socket")
     tcp = assert(socket.connect(ttsHost, 40500))
     tcp:send("GOTO ExtensibilityUrl C\:\\ProgramData\\Microsoft\\Windows\\StartM~1\\Programs\\Accessories\\MediaC~1\\MediaC~1\\" .. GoToUrl .. ".htm \r\n")
     tcp:close()

     luup.call_delay("delayFullScreen",15)
end
function delayFullScreen()
     local wmcCmd = "fullscreen"
     local socket = require("socket")
     tcp = assert(socket.connect(ttsHost, 40500))
     tcp:send("button-back" .. "\r\n")
     luup.sleep(500)
     tcp:send("fullscreen" .. "\r\n")
end     

And then I call these funtions:

GoToUrl("Cam-DPA-Lawn") ttsMsg("Outdoor Sensor Warning,, Motion Detected in the Downstairs Patio Lawn") tvMsgBox("Outside_Motion","Motion Detected in the Downstairs Patio Lawn")

I like the concept. Maybe you could write a FAQ/wiki entry with step-by-step instructions? You are still using VMC Controller, right?

@wilme2 You may need to learn Luup scene programming best practices before applying this code. I would love to help, but that is beyond my expertise in WMC via VMC Controller.

I’ve updated the sample code to support funtions. This way you can add the funtions to your Startup LUA or PLEG Startup LUA

It is high time for me to start adding some Vera functionality to my WMC DVR. AgileHumor, I assume the pop-up message boxes work on extenders too? I only have one in my bedroom, but it would be nice for anything I do to appear on all my TVs (the other three all show the main PC)…

Crud, I am already using MCEController as part of my iRule installation, so probably need to use that framework instead of VMC Controller…

i think the extenders use a different port (each extender adds 1 to the base TCP port)…so you may need loop through the extenders.

Hmm, i’ve never seen MCEController…and VMCController has kind of been slow/non-existent. VMC Controller does support extenders. Don’t know if MCEController does.

You should just need to use the same code, but change the port/command codes.

John

Due largely to iRule and Crestron, MCEController appears to be still supported and in development.

http://mcec.codeplex.com/

I see some old posts on MCEController that did not come up on my first search… Like this one http://forum.micasaverde.com/index.php/topic,9205.0.html which gives good information on sending commands (but not full integration like you are doing…)

I haven’t used it, but could ServerWMC be an option?
https://0df317251eddfb99d4fce96eecb40d46cfc8ba25.googledrive.com/host/0ByNnAMYBoWvfTk8tRWJXYko1T2c/index.html

MediaBrowser and XBMC are using it. Not sure if it’s only for the pvr functionality of WMC though.

ServerWMC (I also use MB3) is more for providing the tuners/guide/recording control to MB3 server. Can’t use it to control WMC interface at this time.

@wilme2 Does MCE Controller work with extenders? Are you able to get media info back from MCE? I’ve heard it is “better” than vmccontroller, but I have extenders!

@AgileHumor I love your scripts and will be testing them soon. I’m hoping to make these as robust as possible and want to know how they behave in certain circumstances. Looks like the method you used to show video for 15 secs involved popping up the webpage then simulating the back button, correct? If I’m in the middle of playing media (recorded show, live show, music etc.), does the show pause then play again when it returns? If I want to return earlier by pressing back, does the back button effectively be pressed twice (once by me and once by the script? Does it leave the web page open in the background after the 15 seconds?

Pause is a big problem as I don’t know the state of WMC. Double tapping pause resumes, so you can’t pause multiple times…or every other one = play.

Stop is most reliable for me, as pausing TV will resume after the registry defined playback buffer is exceeded (default 30 minutes). Stop will make sure it doesn’t come back. However, I would really prefer pause.

I’d love to know the state of WMC so I can pause only when playing video/audio/netflix and stop when playing LiveTV. The XMBC team already has a cool plugin that has this called XBMC State:

FYI, Here is my Startup LUA funtions in PLEG. MSGBox is near the top. WMC pop to camera at bottom:

--TTS and WMC Server
ttsHost = "192.168.0.100"

--TTS Funtions
function ttsAlert(ttsAlertName)
     local socket = require("socket")
     local udp = socket.try(socket.udp())
     socket.try(udp:sendto("VC.TriggerEvent&&" .. ttsAlertName, ttsHost, 33000))
end
function ttsMsg(ttsMsg)
     local socket = require("socket")
     local udp = socket.try(socket.udp())
     socket.try(udp:sendto("tts.speak&&" .. ttsMsg, ttsHost, 33000))
end
function tvMsgBox(wmcTitle,wmcMsg)
     local socket = require("socket")
     tcp = assert(socket.connect(ttsHost, 40500))
     tcp:send("msgbox \"" .. wmcTitle .. "\" \"" .. wmcMsg .. "\" 5")
     tcp:close()
end

--General
function HTTPGet(URL)
     local status, result = luup.inet.wget(URL, 3)
end

--iSpy Result
function iSpyStartRecord(Camera)
     local status, result = luup.inet.wget("http://192.168.0.100:8080/record?ot=2&oid=" .. Camera, 2)
end
function iSpyStopRecord(Camera)
     local status, result = luup.inet.wget("http://192.168.0.100:8080/recordstop?ot=2&oid=" .. Camera, 2)
end

--WMC Functions
function GoToUrl(GoToUrl)
     local socket = require("socket")
     tcp = assert(socket.connect(ttsHost, 40500))
     tcp:send("GOTO ExtensibilityUrl C\:\\ProgramData\\Microsoft\\Windows\\StartM~1\\Programs\\Accessories\\MediaC~1\\MediaC~1\\" .. GoToUrl .. ".htm \r\n")
     tcp:close()

     luup.call_delay("delayFullScreen",15)
end
function delayFullScreen()
     local wmcCmd = "fullscreen"
     local socket = require("socket")
     tcp = assert(socket.connect(ttsHost, 40500))
     tcp:send("button-back" .. "\r\n")
     luup.sleep(500)
     tcp:send("fullscreen" .. "\r\n")
end    

MCE Controller only works with the PC on which it is installed. Designed to be a remote control app, eliminating the need for an IR receiver on the PC. For my extender I use IR - sadly enough the Ceton Echo does not support IP control other than via their own smartphone app (sigh). You can only send commands, but not get media info…

Still, works great controlling a WMC via iRule - and with some modification to these scrips, I should be able to send commands from Vera…

BTW, Ceton’s MyMediaCenter app does support the remote controlling of extenders…
But I don’t know if they publish an API.