I have managed to interface Indigo with MiCasaVerde's Vera 2 Z-wave controller/server. This posts my efforts to date in case anyone is interested.
Background:My X10 gear is slowly failing and needs to be replaced. Insteon is not available in Australia, and I have been anxiously watching Z-wave for some time now. I thought if I start getting Z-wave devices I could use the Vera server as an interface to Indigo while I hope for someone to write an Indigo Z-wave plug-in. I may have jumped a little early, but it is working for me.
Some thoughts about Vera: I now realize how much I love Indigo. We don’t praise Matt and Jay enough. Thank you Gentlemen. In comparison Vera is very limited (e.g., no variables, not user friendly - and that’s putting it mildly, no customization like control pages, etc). Additionally, while Z-wave may be trying to make device identification and installation simple, it is surprisingly convoluted (although that may just be a Vera issue). I get that Z-wave is very powerful, and beautifully fast, and will be a wonderful platform, however with Vera it is not for the feint-hearted.
Some thoughts about Z-wave:I cannot wait for full implementation and wide-spread user adoption. This is an amazing technology. It appears (to myself as a beginner) to be incredibly powerful, super fast and the products available already show great promise. For example, I have motion sensors that also send variable light readings and current temperature settings. I couldn’t have done that easily with one device using X-10 (at least not what was available in Aus.). The only downside is that right now I think it is quite expensive (but I’m sure that has more to do with Australia being such a small market). Given the incredibly detailed attributes of a Z-wave device I now understand why this may take Matt and Jay considerable time to implement (which I hope/presume they may do one day).
I’m sure that this could be put into a plug-in or automated more elegantly, but I have a small system and am still learning. Essentially I am using URL and RESTful calls between both parties. I have teased this apart over some time, my technical language may not always be correct, and I do not profess to be an expert so comment gently. I am willing to learn. I’ve tried to be thorough, so this is long. It is very early days, but here is what I've done so far:
I haven’t explained all the conventions of Vera (e.g. Luup, etc) because I’m assuming that if you have Vera, you are at least familiar with the concepts, if not how to use them. Besides, I'm not that familiar with them yet either.
Initial Vera setup:1. Setup as per instructions.
2. Set your network DCHP to reserve an address for Vera. We will need to reference the same IP address every time (that is, hard code it in scripts below) We could probably use Bonjour names but I haven’t investigated that yet.
Setting up a device in Indigo:Keep your existing X-10 device descriptions in Indigo. It is essentially just a dummy device so I have only used the most basic of model types (e.g. Lamp module, etc). This is really just a place to keep the status of devices and sensors so that Indigo can send commands to Vera. Give or keep its X-10 address (usual rules apply, i.e. unique). I also add the Z-wave ID in the description (e.g. Z-wave ID 22). More on IDs later.
Indigo sending commands to Z-wave devices1. Create a trigger for each state and for each device. That is, a light will have On, Off and Brightness, an appliance will have On and Off triggers.
2. For convenience I have put mine into their own “Vera devices” triggers folder.
On trigger example -
Trigger pane: Type: Device State Changed,
Device: “Office lights”, On/Off State, Becomes On
Condition pane: Always
Actions: Type: Execute script (embedded AppleScript):
- Code: Select all
do shell script "curl \"http://192.168.0.6:3480/data_request?id=lu_action&output_format=xml&DeviceNum=13&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=1\""
Note: IP address is Vera, the DeviceNum is the Z-wave device ID (I’ll tell you where to look later), and the newTargetValue=1 means On, newTargetValue=0 is Off. Note the serviceId is ‘SwitchPower1’
Off trigger example -
Trigger pane: Type: Device State Changed,
Device: “Office lights”, On/Off State, Becomes Off
Condition pane: Always
Actions: Type: Execute script (embedded AppleScript):
- Code: Select all
do shell script "curl \"http://192.168.0.6:3480/data_request?id=lu_action&output_format=xml&DeviceNum=13&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=0\""
Brightness example -
Trigger pane: Type: Device State Changed,
Device: “Office lights”, Brightness level, Has Any Change
Condition pane: Always
Actions: Type: Execute script (embedded AppleScript):
- Code: Select all
do shell script "curl \"http://192.168.0.6:3480/data_request?id=lu_action&output_format=xml&DeviceNum=13&serviceId=urn:upnp-org:serviceId:Dimming1&action=SetLoadLevelTarget&newLoadlevelTarget=" & brightness of device "Office lights" & "\""
Note: the DeviceNum is the Z-wave device ID. Also the serviceId is different here i.e. ‘Dimming1’.
Additionally, I have Z-wave motion sensors that do light and temperature so I have created a variable for each child device/sensor reading (e.g. Office_light_levels).
That’s all you need for Indigo (I think).
For Vera:Create the Vera device:
1. Create all your devices and sensors as required by Vera.
2. Open the Advanced tab for the device and look for the id. It should be directly below the ‘device_file’ entry. Don’t be confused by id_parent or altid.
Create Vera ‘On’ trigger for motion sensors:Commands tab: Make sure all ‘Commands’ are not ticked. We want Indigo to control these, not Vera.
Events tab: Add an event. Device is your sensor (note the ID code)
Type: A sensor is tripped
Name for the event: Whatever is useful for you
Tripped?: Yes
Timers: Not applicable
Luup:
- Code: Select all
os.execute('curl -X PUT --digest -u username:password -d isOn=1 "http://192.168.0.3:8176/devices/Office%20motion%20sensor"')
Note: IP here is IndigoServer.
This command sends an On event to Indigo using RESTful commands. Note the username and password is the IndigoServer user and password. I don’t like hard-coding passwords, but I don’t know that I have much choice in this situation. Besides, I’m comfortable with my network security.
I also added the Luup line below to update the variables I’ve created to store light levels in Indigo. Z-wave is supposed to poll the device for updates regularly, this just helps it along.
- Code: Select all
local lul_lightLevel = luup.variable_get("urn:micasaverde-com:serviceId:LightSensor1","CurrentLevel", 19)
os.execute('curl -X PUT --digest -u username:password -d value=' .. lul_lightLevel .. ' "http://192.168.0.3:8176/variables/Office_light_level"')
IP address is IndigoServer.
’19’ is the Z-wave device id for the light sensor (which is different to the parent motion sensor)
Create Vera ‘Off’ trigger for motion sensors:Identical to On but changed ‘Tripped?’ to No (not gramatically logical but hey?) and change the RESTful isOn=1 to isOn=0.
Remember that every time you make changes to Vera devices, LUUP code etc you have to ‘SAVE’ the database (top right button between search and help - below the time)
You will have to force Vera to update Indigo on a regular basis for sensor information like light level and temperature. I assume you could poll each device for it’s status and other items, but I haven’t bothered yet, I’m trusting Indigo will remain accurate as my main server.
Create timed scene to poll sensors:Commands tab: Make sure all ‘Commands’ are not ticked. They don’t apply here.
Events tab: Not applicable here.
Timers: Add timer. Interval based, every X minutes.
Luup: this code for light sensors
- Code: Select all
local lul_lightLevel = luup.variable_get("urn:micasaverde-com:serviceId:LightSensor1","CurrentLevel", 10)
os.execute('curl -X PUT --digest -u username:password -d value=' .. lul_lightLevel .. ' "http://192.168.0.3:8176/variables/Office_light_sensor"')
and repeat for each sensor you have. In this example ’10’ is the Z-wave device ID of the specific sensor (remember, it’s not the parents ID, being the motion sensor. Light and temperatures are child devices that belong to the motion sensor parent).
I hope I haven’t left anything out and this may be of some use to someone. It’s definitely a PITA at the moment, but I have to admit that it’s worth it for the speed gains I’m getting over X-10.
If anyone can improve this or has more relevant experiences please let me know.
(edit: formatting)