Vera and HomeKit: year 2020

Since I don’t have a flood sensor I’m not sure exactly but this is how I get temperature from a temp sensor:

http://[Vera-IP]/port_3480/data_request?id=variableget&DeviceNum=116&serviceId=urn:upnp-org:serviceId:TemperatureSensor1&Variable=CurrentTemperature&output=json

Maybe you can figure it out by changing DeviceNum, serviceId and Variable?

If you go to advanced variables, click edit the variable you want in the url, At the top of the edit dialog is the serviceId and variable name. The device number is top left on the advanced page for the device.

Thanks, was able to create the URL for tripped variable of flood sensor - when the water detects, the URL returns 1, when not detected, it returns 0. It shows correctly in homekit as Leak sensor, but I dont know how to force Homebridge refresh the state of sensor, when it detects water = url result changes to 1. It seems that when it detects water, it is still as “no water” detected in Home app.

Here is the config part for Homebridge HTTP accessory plugin:

{
        "accessory": "HttpAccessory",
        "service": "LeakSensor",
        "name": "ZaplaveniKoupelna",
        "apiBaseUrl": "http://VERA IP/port_3480/data_request?id=variableget&DeviceNum=91&serviceId=urn:micasaverde-com:serviceId:SecuritySensor1&Variable=Tripped&output=json",
        "apiSuffixUrl": "",
        "forceRefreshDelay": 0
    }

Try with ”forceRefreshDelay”: 5 if it never updates.
Some devices don’t update when you have the app open, closing and reopening the app updates all devices but notifications is always working though.

It even does not changed the state in Homebridge accessory view section - still value as “0” of LeakDetected, but when opening URL, there is “1” as leak detected. Changed ”forceRefreshDelay”: 5 and still not registering any change of returned value in URL. It seems that even Homebridge is not registering the status change provided by Vera URL, which seems working, because the value changes 0/1.

I have noticed in Homebridge logs this log:

[10/18/2020, 15:55:03] [ZaplaveniKoupelna] getDispatch:actionName:  getLeakDetected
[10/18/2020, 15:55:03] [ZaplaveniKoupelna] getDispatch:returnedvalue:  undefined

Not sure, if it has some connection regarding not updating the status change of my leak sensor to Homebridge…

Maybe that Htttp-Accessory plugin cant read the value from link to Vera sensor, even though when I paste the URL to Chrome, it shows 0 or 1…

Yes, it fails to parse the response :neutral_face:
Perhaps the fork homebridge-http-advanced-accessory is better?

Was thinking about this plugin, but I dont have enough experience to configure it - it requires more values to be set in config.json. Could you help me please create config for my leak sensor in http-advanced-accessory?

Thanks a lot!

Looks like it should work with the same config apart from:
"urls":{ "getLeakSensorState": { "url" : "http://VeraVariableUrl"}}
If it doesn’t work add ”debug”: true to the config to see what’s being parsed and you could add a static mapper. This should not be necessary because it’s either 1 or 0.

So I used this code:

{
           "accessory": "HttpAdvancedAccessory",
           "service": "LeakSensor",
           "name": "Zaplaveni-Koupelna",
           "forceRefreshDelay": 5,
           "debug" : false,
           "optionCharacteristic" :[],
           "urls":{
              "getLeakSensorState": {
                 "url" : "http://10.0.0.10/port_3480/data_request?id=variableget&DeviceNum=91&serviceId=urn:micasaverde-com:serviceId:SecuritySensor1&Variable=Tripped&output=json"
	    }
}

It started periodically rebooting the Homebridge engine with this errors:

[10/18/2020, 19:54:05] TypeError: Cannot read property 'url' of undefined
    at HttpAdvancedAccessory.<anonymous> (/usr/local/lib/node_modules/homebridge-http-advanced-accessory/index.js:209:68)
    at HttpAdvancedAccessory.<anonymous> (/usr/local/lib/node_modules/homebridge-http-advanced-accessory/index.js:395:8)
    at Timeout._onTimeout (/usr/local/lib/node_modules/homebridge-http-advanced-accessory/node_modules/polling-to-event/index.js:77:5)
    at listOnTimeout (internal/timers.js:554:17)
    at processTimers (internal/timers.js:497:7)

So I had to remove it from config.json, because it caused Homebridge not running.

I think you’re missing closing } after the actual url

Sorry, just did not copy that bracket, actually it was there, so it is not an issue. It seems that it has also some problem with link URL to Vera sensor value :confused:

Ah, ok. Maybe I could install these plugins to figure out how to get it working. I think we need to get a proper json response and not just a value. The output=json is incorrect (by me) should be output_format=json BUT variableget does not seem to have an output format so let me see what I can come up with later this week.

1 Like

Thanks, much appreciated!

By default vera outputs JSON so you can omit output_format if you requre JSON. variableget outputs the variable so no format needed
a blank text file is a valid json, so is a single string, number array and dictionary.

I have tried to omit “output=json” from the URL, but it still reports error with getting value from Veras URL. Lets see with what @Crille comes up.

Ok, this was completely undocumented, but got it working for you.
Your config for http-advanced-accessory should look like this:

    {
       "accessory": "HttpAdvancedAccessory",
       "service": "LeakSensor",
       "name": "Zaplaveni-Koupelna",
       "forceRefreshDelay": 5,
       "urls": {
          "getLeakDetected": {
             "url": "http://10.0.0.10/port_3480/data_request?id=variableget&DeviceNum=91&serviceId=urn:micasaverde-com:serviceId:SecuritySensor1&Variable=Tripped"
             }
        }
    }
1 Like

Thanks!

Works like a charm. So the value GetLeakDetected instead of GetLeakSensorState was the issue, perfect, it was last type of sensor from Vera, which I needed to pass to HomeKit, now all sensors in Vera also works in HomeKit (smoke, CO, contact, leak, motion, humidity, temperature…).

1 Like

Maybe it’s time to evolve this plugin and add all standard sensors. I’m not sure I have spare time, but maybe other will chime in and contribute.

It would be great, for iOS users it is quite good added value to Vera to have all its devices as native HomeKit for use with Siri and also to have all IoT at one place in Home app including cameras and other systems than Vera.

2 Likes