Page 1 of 1

Vera UI7 humidity data to Domoticz

Posted: Sunday 31 January 2021 22:44
by GreenGuy
I am trying to transfer humidity data from Vera UI7 to Domoticz using the command "os.execute('curl "http://192.168.1.95:3480/data_request?i ... rrentLevel"')" in ~/domoticz/scripts/lua_parsers under Linux Debian 18.04. The command "http://192.168.1.95:3480/data_request?i ... rrentLevel" when put into a web programme gives the correct result. I've looked at examples but am struggling.
How do I programme LUA to put the humidity data into a Virtual Sensor?

HTTP Poller settings
ContentType: application/xmp

The lua script below
os.execute('curl "http://192.168.1.95:3480/data_request?i ... rrentLevel"')
local deviceId = 281
s = request['content'];
local id = domoticz_applyXPath(s,'//id/text()')
local s = domoticz_applyXPath(s,'//value/text()')
domoticz_updateDevice(id,'',s)

Re: Vera UI7 humidity data to Domoticz

Posted: Monday 01 February 2021 9:41
by waltervl
What is coming out of this URL from Vera? A json, a xml?
If you copy an example here, so we can help you.
It is perhaps also better to use DzVents (based on Lua) for easier coding and better support.

Edit: from the DzVents wiki below example that you could modify based on your situation (change url, json parameters, devices etc)

Asynchronous HTTP Request and handling
Suppose you have some external web service that will tell you what the current energy consumption is and you want that information in Domoticz:

Code: Select all

return {
    on = {
        timer = { 'every 5 minutes' },
        httpResponses = { 'energyRetrieved' }
    },
    execute = function(domoticz, item)
        if (item.isTimer) then
            domoticz.openURL({
            url = 'http://url/to/service',
            method = 'GET',
            callback = 'energyRetrieved'
            })
        elseif (item.isHTTPResponse) then
            if (item.ok) then -- statusCode == 2xx
                local current = item.json.consumption
                domoticz.devices('myCurrentUsage').updateEnergy(current)
            end
        end
    end
}