INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Automation Help  (Read 4147 times)

gvanbrunt

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1232
  • MC Nerd
Automation Help
« on: August 14, 2014, 07:49:49 pm »

I'm looking at expanding some of my home automation. What I would like to add is to have the lights dim when in Theater View and a Movie is played. From what I know about MC automation I'm going to have to write a small plug in that will run a command when those conditions are met.

Before I go down that path I was wondering if anyone knows of any other way to run a command when a set of conditions are met in Media Center. Or perhaps there already is a plug in. I don't want to re invent the wheel. :)
Logged

rlebrette

  • Guest
Re: Automation Help
« Reply #1 on: August 17, 2014, 04:28:26 am »

Hello,

I've written a small utility that does what you're asking for. It's not a plugin, it relies on the MC webservices and it polls the status for the player, the type of media, and the changes in the volume. Having it as a separate application allows to run it on another machine that the one which is running the MC instance.
You can get the binaries here: https://github.com/rlebrette/jrmc-vb-status-listener/releases, and sources are also available here: https://github.com/rlebrette/jrmc-vb-status-listener

Hope it helps.
Logged

rlebrette

  • Guest
Re: Automation Help
« Reply #2 on: August 17, 2014, 04:41:46 am »

 ? The text of the urls is strangely rewritten by the forum by replacing J R M C by MC. So please while using them replace MC by J R M C (without spaces).
Logged

gvanbrunt

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1232
  • MC Nerd
Re: Automation Help
« Reply #3 on: August 17, 2014, 08:50:04 am »

Awesome. Thanks. You saved me some work.

The url thing is due to text rewriting. They wanted users to call Media  Center only certain "correct" terms as there were a lot of variations around. So it overwrites certain terms including J M R C. There is a thread somewhere about it with a lot of us joking about it. Shouldn't have re written a URL though...
Logged

raym

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3583
Re: Automation Help
« Reply #4 on: August 18, 2014, 08:38:15 am »

Sounds like you might have this sorted now but I use InControl HA for Z-Wave lighting control in my theater room with MC. I wrote a short tutorial on this a while back in case you're interested:

http://www.rkmsmarthome.com.au/blog/activate-z-wave-scenes-with-your-ir-remote-control

Cheers.  
Logged
RKM Smart Home - www.rkmsmarthome.com.au
Z-Wave Home Automation

gvanbrunt

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1232
  • MC Nerd
Re: Automation Help
« Reply #5 on: August 18, 2014, 09:15:52 am »

Sounds like you might have this sorted now but I use InControl HA for Z-Wave lighting control in my theater room with MC. I wrote a short tutorial on this a while back in case you're interested:

Ya the control part I have working. I'm using a Universal Devices ISY and EventGhost for most things. I can control things via my remote etc. But I want to have the lights dim automatically when I start watching a movie and brighten again when I hit pause. I want to do this from MC as I want keyboard, mouse, remote etc to all have the "same" effect. Hope that makes sense.
Logged

gvanbrunt

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1232
  • MC Nerd
Re: Automation Help
« Reply #6 on: August 18, 2014, 10:03:09 am »

Just read through your tutorial Ryam. Very nice. It's amazing how similar a lot of what you came up with is what I'm going to be doing. I need to use curl as well to to call the REST API on my ISY. I also looked at using MC's remote option but it doesn't quite do what I wanted. I need to be able to tell if I'm in theater view, and if the file is a video or image. Only then do I dim things.  Been trying to figure out a way to do this with just a script, but quite painful... I also would like to have it happen when the files are played in MC no matter the source (mouse, keyboard) which would mean a plug in. However, I would give that up for a script that checks the other 2 requirements before executing curl to actually dim the lights etc.

Trouble is getting that information means a couple of REST calls to MC's API and parsing the xml that is returned - don't know how to do that from a script. Might look at Powershell. Never used it for REST or XML parsing, but I'll bet it's possible.
Logged

thorsten

  • World Citizen
  • ***
  • Posts: 196
Re: Automation Help
« Reply #7 on: August 18, 2014, 01:26:02 pm »

Hi,

very interesting thread! I'd like to jump on the bus as I use a FS20-system to automate some things (e.g. starting the projector, moving down the curtain in front of the window etc.) This is done with a macro-controller.
However, the system also contains a USB-transmitter with which I'm capable to start some actions via eventghost.

Happy to read that there seems to be a way to do it right out of MC! Also, thanks Ryam for your tutorial. As I#m not so deep in programming with als these xml and API stuff, I just tagged this thread  ::)
Logged

rlebrette

  • Guest
Re: Automation Help
« Reply #8 on: August 19, 2014, 01:08:05 am »


Trouble is getting that information means a couple of REST calls to MC's API and parsing the xml that is returned - don't know how to do that from a script. Might look at Powershell. Never used it for REST or XML parsing, but I'll bet it's possible.

Have you been successful in using my little utility? I use it exactly in the same kind of context, using Girder instead of EventGhost, and running REST query to interact with home automation devices (the http.vb script is an example). I've several users that are directly using it with their home automation box.
If there's some missing information/feature, don't hesitate ask it, I will add it.
Logged

gvanbrunt

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1232
  • MC Nerd
Re: Automation Help
« Reply #9 on: August 19, 2014, 09:12:57 pm »

Have you been successful in using my little utility?

Thanks for the util, but not quite what I want. I need MC to "send" the status. I could use "polling" from Eventghost but that would hammer the webservice in order to have it dim the lights in a timely fashion. If i'm to have it work no matter how "play" is called (MC's Menu, Keyboard, Mouse etc) then I'm going to need to do a plug in.

Or I could just let it work only from my remote and have Eventghost check when play is pressed etc. However Eventghost only seems to be able to do "If/Then" type of scenarios if you use Python Scripts. Was looking at Girder too, but it doesn't have an plug in for my ISY meaning I have to do everything there with scripts.

No easy solutions yet, but still doing lots of research.
Logged

rlebrette

  • Guest
Re: Automation Help
« Reply #10 on: August 19, 2014, 11:51:29 pm »

Thanks for the util, but not quite what I want. I need MC to "send" the status. I could use "polling" from Eventghost but that would hammer the webservice in order to have it dim the lights in a timely fashion. If i'm to have it work no matter how "play" is called (MC's Menu, Keyboard, Mouse etc) then I'm going to need to do a plug in.

Or I could just let it work only from my remote and have Eventghost check when play is pressed etc. However Eventghost only seems to be able to do "If/Then" type of scenarios if you use Python Scripts. Was looking at Girder too, but it doesn't have an plug in for my ISY meaning I have to do everything there with scripts.

No easy solutions yet, but still doing lots of research.

Did you tested it? It's polling MC and just notifying you of changes, the basic example shows the behavior, as soon as the status change, i.e. you press play/pause/stop or a new track is played, you get a message that you can forward to eventghost. The whole status change is managed by the program.
Logged

gvanbrunt

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1232
  • MC Nerd
Re: Automation Help
« Reply #11 on: August 20, 2014, 10:32:56 am »

My issue is with using polling. I'm a programmer too, so I'd rather not go that route. Less load on the server.

I do appreciate your efforts though. Interesting program. I once did some on the fly compilation as well. That was way back in the .Net 1.0 days. Worked quite well, but documentation was scarce back then..

Oh, I should also say that I still may use it. Would do what I want for sure, just seeing what my other options are.
Logged

rlebrette

  • Guest
Re: Automation Help
« Reply #12 on: August 20, 2014, 10:58:00 am »

My issue is with using polling. I'm a programmer too, so I'd rather not go that route. Less load on the server.

I do appreciate your efforts though. Interesting program. I once did some on the fly compilation as well. That was way back in the .Net 1.0 days. Worked quite well, but documentation was scarce back then..

Oh, I should also say that I still may use it. Would do what I want for sure, just seeing what my other options are.

Ok, now I see your point, but I was also worried about that. I've done several tests on my local network, I've run around 20 different instances (yes I'm very involved in scalability issues in my own job :)) devided on three boxes targeting the same player and I've noticed no slowdown.
Logged

gvanbrunt

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1232
  • MC Nerd
Re: Automation Help
« Reply #13 on: August 20, 2014, 05:40:16 pm »

Ok, now I see your point, but I was also worried about that. I've done several tests on my local network, I've run around 20 different instances (yes I'm very involved in scalability issues in my own job :)) devided on three boxes targeting the same player and I've noticed no slowdown.


You are probably correct that it would work just fine in my environment as well. I'm just looking at all possibilities before deciding what to do. Easiest way from me to do plug in is with .Net. However, that has a pile of overhead that will likely impact MC startup performance as well. Possibly it's run time performance as well... So the polling may well have less of an impact than a plug in anyway...
Logged

gvanbrunt

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1232
  • MC Nerd
Re: Automation Help
« Reply #14 on: October 02, 2014, 10:44:49 pm »

I decided to do a polling EventGhost plugin in Python in the end. Mostly because I wanted to learn python. The fact that EventGhost uses python 2.6 makes writing code like riding a bike with one wheel. :) Really helps you to think creative since the xml handling sucks etc.

Also I noticed that you wrote a webserver that plugs into MC's SOAP Web Service to capture events and republish them as WebSocket calls. In Node.js no less and more than 2 years ago. That is way ahead of the curve for sure. :) I may use that at some point. How stable is it?
Logged

gvanbrunt

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1232
  • MC Nerd
Re: Automation Help
« Reply #15 on: October 05, 2014, 12:40:17 pm »

I finished the plugin and made it available to anyone that wants it:

http://yabb.jriver.com/interact/index.php?topic=92375.0
Logged
Pages: [1]   Go Up