INTERACT FORUM

Please login or register.

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

Author Topic: Tip: How to control Vera Lights (or any Z-Wave device) in Media Center  (Read 40 times)

Manni

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 607

I have a home cinema and my lights are controlled by a Vera Lights controller (Z-Wave).

I can control them manually of course, with a keyfob or with an iOS app (I use Roomie Remote) and vocally with Alexa, but it's quite cool to have the lights switched off automatically when playback starts, and back on (I prefer dimmed) when playback stops.

I have this working in CMC (my current front end) but I wanted to implement this in MC, so I did a bit of research, and although what I came up with is more limited than an internal implementation, it's still quite cool.

A lot of this comes from this post, which has been super useful: https://windowsmediacenter.blogspot.com/2012/10/how-to-control-vera-z-wave-devices-and.html. Use it for reference or to get more details if any of the below is unclear.

In order to do this with MC, I take advantage of the new ShellRun expression (introduced in MC33) that can be used to start an external  command (.exe or .bat) when playback starts and when playback ends. So the only thing needed is to create the batch files controlling the lights.

Vera allows to create scenes, which is useful to control more than one device. For example, I have the following scenes defined with my Very Ligths, that control both my ceiling lights and my desk light in the cinema room (my loft):

1) Lights On
2) Lights Off
3) Dim Lights

In order to execute a specific scene, if you don't know the scene ID, simply go to the following address and locate it (replace [IP Address] by the actual IP address for your Vera Lights controller):
http://[IP Address]/port_3480/data_request?id=lu_sdata&output_format=xml

Once you have your ID for your scene(e), the next thing to do is to create a batch file for each scene and use WGET to send the actual command. I downloaded WGET here: https://gnuwin32.sourceforge.net/packages/wget.htm.

Once WGET for Windows is installed, you need to add the path to WGET so that MC can run the command there. Right click on the start button, select system, click on Advanced System Settings, Environment variables, edit the path and add the following path (if you installed WGET with the default settings): C:\Program Files (x86)\GnuWin32\bin.

Then create a batch file with this single command for each of the command you want to send, changing the ID number at the end so that it corresponds with the ID# of the scene you want to excecute.

For example, to execute scene ID#2 (Lights off), the command is:
Code: [Select]
wget --delete-after "http://[IP Address]:3480/data_request?id=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunScene&SceneNum=2"

I put this into a "Lights_Off_Loft.bat" file, and the same command with "3" instead of "2" to dim the lights, in a batch file called "Lights_Dim_Loft.bat".

Once you've tested the batch files and have confirmed that they do what you want them to do, the final step is to tell MC which file to run when playback starts, and which to run when playback stops.

This is done in Tools/Options/Library & Folders (I attach a screenshot below).

First click on "Before playback expression", click on the little arrow, select "Insert function", select "ShellRun" in the list, then type the full path to your bach file  and add ,,2 at the end (so that the command window doesn't show).

In my case, I want to switch the lights off when playback starts, so my command is:
ShellRun(D:\Users\Em\Dropbox\Documents\Batch_Files\Lights_Off_Loft.bat,,2)

Then do the same for the expression after playback. Mine is:
ShellRun(D:\Users\Em\Dropbox\Documents\Batch_Files\Lights_Dim_Loft.bat,,2)

That's it :) When I start playback, all my lights are switched off. When I stop playback, my lights are dimmed. This is fully automatic, and much nicer than having to do it with manual commands, even using Alexa or Roomie Remote.

I don't know how many people will find this useful, but hopefully it will help someone.

If the team wanted to add Z-Wave support for JRiver, the above could be used as a guide, it's pretty straightforward.
Logged
Pages: [1]   Go Up