Variable_watch problem

I’m trying to use variable_watch to log some temperature data but I’m not having any success. The watch function is not being called. Here’s my code:

– Watch Upper duct temp
luup.variable_watch( logVariableChange, “urn:upnp-org:serviceId:TemperatureSensor1”, “CurrentTemperature”, 2670)

Here is what I see in the luaupnp.log

luup_variable_watch interface 0x142f850 no CurrentTemperature/urn:upnp-org:serviceId:TemperatureSensor1

The temperature sensor works properly. The CurrentTemperature variable is updated whenever the sensor sends an update. The error in the log seems to hint that the service ID or variable name are incorrect but I don’t think they are. And the device number is correct as well. I tried using the local_udn instead of the device number but the error was the same.

The first parameter hss to be the name of the global handler function as a string in quotes. You cannot pass a function reference as you are doing. That would make more sense, but it’s not how it works.

…the key word here being global.

Hence you cannot write:

local function logVariableChange (lul_device, lul_service, lul_variable, lul_value_old, lul_value_new)
    -- whatever
end

It has to be:

function logVariableChange (lul_device, lul_service, lul_variable, lul_value_old, lul_value_new)
    -- whatever
end
1 Like

Thanks rigpapa - that was the problem.

Best Home Automation shopping experience. Shop at getvera!

© 2020 Vera Control Ltd., All Rights Reserved. Terms of Use | Privacy Policy | Forum Rules