Get CPR certified in 30 minutes at CPR Test Center.
Echo & Alexa Forums

Echo can control windows media center

0 Members and 1 Guest are viewing this topic.

Beckyricha

Echo can control windows media center
« on: December 22, 2015, 03:13:30 pm »
Tedious and advanced but I've wasted time on less. Also probably not very secure so might be best for a dedicated media machine. If anyone knows an easier way please advise.  I've got everything working except actually using echo as i am still waiting for it to arrive, but if it understands my voice and triggers ifttt as others say is fine, then the rest works and is tested. I don't know yet how bad the lag is but not terrible using other ifttt triggers.
1) install mce controller (google it -there's only one) and think about which commands to link to voice (had to do this one by one so functionality goes with available time on your hands).
2) mce controller won't take http commands so I wrote a script for each command to connect to mce controlller via telnet, send the command then disconnect. Those scripts are hosted on a web server. I set up the scripts and web server on a raspberry pi. I'm a relative noob to linux but found instructions and got it working in apache in about an hour.  You could host the server anywhere, maybe faster if on your wmc machine, but i find linux scripting easiest. My scripts are things like starting media center, going to live tv, going to a favorite channel. Just a small set for my elderly mom in law so far but easy to expand as time allows.
3) set up an ifttt recipe for each command to take input from alexa ("alexa, trigger the food network") and run the script on your web server via the maker channel. That last is the biggest headache because there is no good documentation. I got it working using the http post command. I put the whole link in as the address (http://[my ip address]:[my port]/cgi-bin/[my script] and left everything else blank.

Enjoy...

Beckyricha

Re: Echo can control windows media center
« Reply #1 on: January 01, 2016, 11:18:45 am »
Update - finally received my echo and this works like a charm. Alexa understand all the channels i tell it, including even pronouncing instead of spelling out "masn.". If weird popups come up that my mother in law can't decipher she can now just say "Alexa, trigger fix the TV." This calls a recipe on iftt that uses the maker channel to call a cgi script on my web server.   That is just a bash script containing several "alt-f4" commands followed by a wmc start command, sent via telnet to the listening port on the windows machine. Similarly she can trigger "live tv" or any of her favorite channels, or turn the volume up or down several notches, etc.  The initial setup is a little tricky but once it works, adding commands is just cut and paste and goes quickly. There is a couple seconds lag, but still faster than typing numbers into the remote for channel changes. Also unlike the remote, if my mother in law does something wrong, this generally won't do anything at all, so she won't get confused.  If anyone is interested enough to try, reply and I can put the details in an instructable or something.

agf1583

Re: Echo can control windows media center
« Reply #2 on: February 26, 2016, 12:26:33 am »
This is exactly what I've been looking for. I would really appreciate detailed instructions. I have a raspberry pi as well so I can probably use the exact same setup.

Thanks!

smarty

Re: Echo can control windows media center
« Reply #3 on: February 28, 2016, 12:30:43 pm »
I would also like to see/hear more about this, especially concerning the use of the IFTT Maker Channel.

I am looking for more info concerning your comments about security (i.e. having the RasPi computer reside in the DMZ); authentication (or not?) of the RasPi, as well as how you get commands/scripts from the DMZ RasPi to your MCE machine (that is inside your network? Yes/No?) is of interest.

I am trying to figure out something similar, in that I have an outward facing webserver that can accept CGI Iif your login into it), but, I don't know how I can get my Echo to authenticate via IFTT Maker to my webserver (so the cgi will be acted upon as I want it to be).

bcc243

Re: Echo can control windows media center
« Reply #4 on: March 10, 2016, 11:20:09 am »
Hi, I am interested in doing this exact thing. Can  you provide a copy of your scripts that change channels? Or do you have detailed instructions posted anywhere? You can reach me at bcc243@hotmail.com

Thanks

mrbongo

Re: Echo can control windows media center
« Reply #5 on: May 10, 2016, 06:28:41 pm »
Here's what should be a simpler way:

  • Install and run MCE Controller from https://mcec.codeplex.com/
  • Download latest Python (3.5 or above) from https://www.python.org/downloads/
  • Install it, choosing the option to have python added to the PATH
  • Create C:\webserver and C:\webserver\cgi-bin directories
  • In C:\webserver put the batch file webserver.bat with this content:
Code: [Select]
cd \webserver
python -m http.server --cgi 5050
  • In C:\webserver\cgi-bin put the file runCmd.py with this content:
Code: [Select]
#!/usr/bin/env python
import cgi
import socket

LOCALHOST_IP = '127.0.0.1'
MCE_PORT = 5150

arguments = cgi.FieldStorage()
cmd = arguments.getvalue("cmd") + "\n"

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((LOCALHOST_IP, MCE_PORT))
sock.send(bytes(cmd, 'utf-8'))
sock.close()

print("Content-Type: text/plain\n")
print("Sent " + cmd + "OK!")

That, in theory, should start Windows Media Center.  All that's left:
  • Open up the port 5050 in your firewall and all the way through from the internet (see http://portforward.com for help here)
  • Create recipes in http://ifttt.com that trigger via Alexa and call your webserver with the command of your choosing
  • For a bit of safety the runCmd.py needs to be updated to a) require a "secret" key to be passed in the URL for the command to work plus b) the code should only allow whitelisted commands go through as it would be unwise to allow access to all the dangerous abilities of MCE Controller from the internet to your HTPC
  • Make sure C:\webserver\webserver.bat runs on Windows startup by placing a shortcut to it in the Programs -> Startup folder

Beckyricha

Re: Echo can control windows media center
« Reply #6 on: July 13, 2016, 08:39:46 am »
Sorry all. This site has not been notifying me of replies so i had no idea. I have done a lot d differently now and will share those soon when i have time. I am still using the pi to host the web piece only because i don't want to figure out apache for windows but you could do it either way if you don't have a pi out other web server already running. I am using smart things instead of ifttt so i don't need to say trigger and it is much faster (doesn't Twitter a hub). I will try to get the details on github soon and repost here with a link.

Alfred

Re: Echo can control windows media center
« Reply #7 on: September 16, 2016, 05:19:53 pm »
If anyone is interested enough to try, reply and I can put the details in an instructable or something.
I'm interested in a copy of the details. Thanks