this script works fine but I'm trying to convert this script into dzVents.
The uRadmonitor sensor on '192.168.178.26/j' generates this json format line
{"data":{ "id":"12000059","type":"1","detector":"SI29BG","cpm":9,"temperature":29.31,"uptime": 1407157}}
My first try is to extract the cpm value , the sensorname is cpmCount
apparently the json decoding is not right becouse cpmCount is always zero
Code: Select all
local IP = '192.168.178.26' -- uRadmonitor sensor IP
return {
active = true,
on = {
timer = { 'every minute' },
httpResponses = { 'cpmRetrieved' } -- matches callback string below
},
execute = function(domoticz, item)
if (item.isTimer) then
domoticz.openURL({
url = 'http://' .. IP .. '/j',
method = 'GET',
callback = 'cpmRetrieved',
})
elseif (item.isHTTPResponse) then
if (item.ok) then -- and item.isJSON) then -- statusCode == 2xx
-- if (item.statusCode==0) then
local Count = item.data.cpm
domoticz.log('status = ',tonumber(Count))
domoticz.devices('cpmCount').updateCustomSensor(Count)
end
end
end
}
log output:
2025-05-11 21:57:00.216 dzVents: Handling httpResponse-events for: "cpmRetrieved"
2025-05-11 21:57:00.216 dzVents: ------ Start internal script: cpm_dzvents: HTTPResponse: "cpmRetrieved"
2025-05-11 21:57:00.216 dzVents: status =
2025-05-11 21:57:00.217 dzVents: ------ Finished cpm_dzvents