VeraLite Z-Wave and Apple Home Integration

I've been using MiCasaVerde VeraLite Z-Wave Home Automation Controller to manage my Z-Wave devices for years. I initially purchased the VeraLite platform when there was no such thing as Alexa etc. It is now therefore getting old, but it still works fine.

I never has a MiOS account, as I wanted an independant system rather than one which will become obsolete once the provider feels it is no longer viable to keep cloud platforms running. Mine is therefore running its original code, and isn't exposed to the Internet, or even my home network. It is on a dedicated DMZ network protected by my Firewall. I only allow the minimum communications to reach it, and I don't let it talk to the Internet at all. This does mean that the gateway has no idea the time and date as can be seen below. :)

The VeraLite has its own basic web front end as you can see, but I prefer to manage devices using the Apple Home application. There are a few steps involved where devices can be setup and modified.

The first step is to understand that each Z-Wave device defined on the VeraLite platform has its own unique ID. In the screenshow above, you can see that I include the ID in the device description for ease, but it is simple to identify which is which. To do this, simply click on the wrench icon for the device in question, and  look under the advanced tab. So taking the top left device S02, as an example, we can see that it is listed as Device #9 on the top line.

This can be confirmed by simply scrolling down a little we can see it is listed further down as "id" 9.

So now we have that ID, we can use it to make requests directly to the VeraLite Controller to determine its state, and to cause it to change state.

The following URL will report its current status:

http://VERAIP:3480/data_request?id=status&output_format=text&DeviceNum=9

The complete returned data is shown below, but the key piece of information we are looking for is the "Status", "value": "1" or "Status", "value": "0" which represents either on or off.

{ "Device_Num_9": { "states": [ { "id": 197, "service": "urn:upnp-org:serviceId:SwitchPower1", "variable": "Status", "value": "1" }, { "id": 198, "service": "urn:upnp-org:serviceId:SwitchPower1", "variable": "Target", "value": "1" }, { "id": 199, "service": "urn:micasaverde-com:serviceId:HaDevice1", "variable": "Configured", "value": "1" }, { "id": 200, "service": "urn:micasaverde-com:serviceId:HaDevice1", "variable": "LastUpdate", "value": "952216557" }, { "id": 201, "service": "urn:micasaverde-com:serviceId:HaDevice1", "variable": "FirstConfigured", "value": "946685859" }, { "id": 202, "service": "urn:micasaverde-com:serviceId:HaDevice1", "variable": "CommFailure", "value": "1" }, { "id": 203, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "Capabilities", "value": "211,156,0,4,16,1,L,R,B,RS,|37,39,112,114,134," }, { "id": 204, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "ManufacturerInfo", "value": "280,257,259" }, { "id": 205, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "VersionInfo", "value": "6,3,40,1,4" }, { "id": 206, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "NodeInfo", "value": "25,27,70,72,86," }, { "id": 207, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "PollSettings", "value": "60" }, { "id": 208, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "Neighbors", "value": "1,9,10,11,14,15,16,30," }, { "id": 209, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "LastReset", "value": "0" }, { "id": 210, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "AssociationNum", "value": "0" }, { "id": 211, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "PollOk", "value": "81076" }, { "id": 212, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "LastRouteUpdate", "value": "964374587" }, { "id": 213, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "NeighborsInverse", "value": "" }, { "id": 214, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "Health", "value": "" }, { "id": 215, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "MultiChEndpoint", "value": "" }, { "id": 216, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "MultiChCapabilities", "value": "" }, { "id": 217, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "ConfiguredName", "value": "" }, { "id": 218, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "ConfiguredVariable", "value": "" }, { "id": 219, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "ConfiguredAssoc", "value": "" }, { "id": 220, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "MeterType", "value": "" }, { "id": 221, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "MeterScale", "value": "" }, { "id": 222, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "SetPointInfo", "value": "" }, { "id": 223, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "SensorMlType", "value": "" }, { "id": 224, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "SensorMlScale", "value": "" }, { "id": 225, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "PollTxFail", "value": "" }, { "id": 226, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "PollNoReply", "value": "597" }, { "id": 227, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "HealthDate", "value": "946760964" }, { "id": 228, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "AutoRoute", "value": "17-15x,19-19x,27-22x,19.17-25x" }, { "id": 229, "service": "urn:micasaverde-com:serviceId:ZWaveDevice1", "variable": "AllRoutesFailed", "value": "1" } ], "Jobs": [ ], "tooltip": { "display": 0 }, "status": -1 }, "LoadTime": 954192550, "DataVersion": 192550068, "UserData_DataVersion": 192550001, "TimeStamp": 954193219, "ZWaveStatus": 1, "LocalTime": "2000-03-27 22:40:19 N" }

Two further URL's, can be called to modify the newTargetValue in order to request the switch is turned on or off. So for  switing on the following URL would be used.

"http://VERAIP:3480/data_request?id=lu_action&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=1&DeviceNum=9"

And, no suprises, to turn off it would be this URL.

"http://VERAIP:3480/data_request?id=lu_action&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=0&DeviceNum=9"

We now have three URL's to turn a device for a given ID on or off, and request its current status. It is worth noting that Z-Wave can take a few moments to action the request, especially if the Z-Wave network is busy or in a harsh RF environment. The VeraLite Z-Wave platform will continue trying a number of times to issues commands to remote devices.

These direct URL's can be called in a varity of methods, in the past I've used python scripts, bash scripts, my own hosted PHP web pages and Home Assistant. Now though I am using the Apple Home Application, using HomeBridge running in a docker container.

Within HomeBridge, I use the http-switch plugin linked below:

GitHub - Supereg/homebridge-http-switch: Powerful http switch for Homebridge: https://github.com/homebridge/homebridge
Powerful http switch for Homebridge: https://github.com/homebridge/homebridge - GitHub - Supereg/homebridge-http-switch: Powerful http switch for Homebridge: https://github.com/homebridge/homebridge

Armed with the URLs, it is very simple to add these switches to your homebridge config, a snippet of which can be seen below:

"accessories": [
    {
        "accessory": "HTTP-SWITCH",
        "name": "Z-Wave Device 9",
        "switchType": "stateful",
        "onUrl": "http://VERAIP:3480/data_request?id=lu_action&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=1&DeviceNum=9",
        "offUrl": "http://VERAIP:3480/data_request?id=lu_action&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=0&DeviceNum=9",
        "statusUrl": "http://VERAIP:3480/data_request?id=status&output_format=text&DeviceNum=9"
    }
]

Once the device has been defined on HomeBridge, and been restarted, you can add it to the Apple Home Application in the same maner as all other HomeBridge devices.

I'm sure I may have glossed over a lot of information, but this configuration using 3 simple URL's with the respective device ID has allowed me to ignore the VeraLite web interface completely.