Code: Select all
Error: dzVents: Error: (3.1.8) ...scripts/Thermostaat studeerkamer (update connection).lua:39: attempt to index a nil value (field 'target_t')
Code: Select all
-- DzVents script for update of set temperature Shelly Valve
local IPADDRESS = 'xx' -- IP address
local USER = 'xx' -- login credentials
local PASSWORD = 'xx' -- login credentials
local THERMOSTAAT = 'Thermostaat studeerkamer' -- Thermostaat domoticz device name
return {
on = {
timer = {
'every minute'
},
httpResponses = {
'trigger'
}
},
execute = function(dz, item)
if (item.isTimer) then
dz.openURL({
url = 'http://' .. USER .. ':' .. PASSWORD .. '@' .. IPADDRESS .. '/thermostat/0',
method = 'GET',
callback = 'trigger',
})
end
if (item.isHTTPResponse) then
if (item.ok) then
-- Parsing JSON data and interpreting data...
dz.log('processing data...', dz.LOG_INFO)
local shellyvalve = dz.utils.fromJSON(item.data)
local setpointshellyvalve = shellyvalve.target_t.value
-- Updating domoticz devices
dz.devices(THERMOSTAAT).updateSetPoint(setpointshellyvalve).silent()
else
dz.log('HTTP response error', dz.LOG_ERROR)
end
end
end
}