Domoticz log:
Code: Select all
2021-10-02 17:33:00.509 Status: dzVents: Info: Air quality: ------ Start internal script: airrohr:, trigger: "every 1 minutes"
2021-10-02 17:33:00.536 Status: dzVents: Debug: Air quality: Processing device-adapter for airrohr PM10: Custom sensor device adapter
2021-10-02 17:33:00.537 Status: dzVents: Debug: Air quality: Processing device-adapter for airrohr PM2.5: Custom sensor device adapter
2021-10-02 17:33:00.537 Status: dzVents: Debug: Air quality: OpenURL: url = http://192.168.1.152/data.json
2021-10-02 17:33:00.537 Status: dzVents: Debug: Air quality: OpenURL: method = GET
2021-10-02 17:33:00.537 Status: dzVents: Debug: Air quality: OpenURL: post data = nil
2021-10-02 17:33:00.537 Status: dzVents: Debug: Air quality: OpenURL: headers = nil
2021-10-02 17:33:00.537 Status: dzVents: Debug: Air quality: OpenURL: callback = Air quality
2021-10-02 17:33:00.537 Status: dzVents: Info: Air quality: ------ Finished airrohr
2021-10-02 17:33:00.537 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2021-10-02 17:33:00.666 Status: dzVents: Info: Handling httpResponse-events for: "Air quality"
2021-10-02 17:33:00.667 Status: dzVents: Info: Air quality: ------ Start internal script: airrohr: HTTPResponse: "Air quality"
2021-10-02 17:33:00.680 Status: dzVents: Debug: Air quality: Processing device-adapter for airrohr PM10: Custom sensor device adapter
2021-10-02 17:33:00.681 Status: dzVents: Debug: Air quality: Processing device-adapter for airrohr PM2.5: Custom sensor device adapter
2021-10-02 17:33:00.681 Status: dzVents: Info: Air quality: ------ Finished airrohr
2021-10-02 17:33:00.681 Error: dzVents: Error: (3.0.2) Air quality: An error occurred when calling event handler airrohr
2021-10-02 17:33:00.681 Error: dzVents: Error: (3.0.2) Air quality: ...i/domoticz/scripts/dzVents/generated_scripts/airrohr.lua:41: attempt to index a nil value (field '?')
Code: Select all
local scriptVar = 'Air quality'
return
{
on =
{
timer =
{
'every 1 minutes', -- adjust to your needs
},
devices =
{
-- 'JSONTrigger', -- only used for test / development/ Can be ignored
},
httpResponses =
{
scriptVar,
},
},
logging =
{
level = domoticz.LOG_DEBUG, -- set to domoticz.LOG_ERROR when all OK
marker = scriptVar,
},
execute = function(dz, item)
local pm10 = dz.devices('airrohr PM10') -- define as air quality
local pm25 = dz.devices('airrohr PM2.5') -- define as air quality
if item.isTimer or item.isDevice then
dz.openURL({
url = 'http://192.168.1.152/data.json',
callback = scriptVar,
})
return
end
if item.isHTTPResponse and item.isJSON then
-- dz.utils.dumpTable(item.json) -- Only for debug purposes
local latestAirQuality = item.json[1].sensordatavalues
pm10.updateAirQuality(latestAirQuality[0].value)
pm25.updateAirQuality(latestAirQuality[1].value)
else
domoticz.log('There was a problem handling the request', domoticz.LOG_ERROR)
domoticz.log(item, domoticz.LOG_ERROR)
end
end
Code: Select all
software_version "NRZ-2020-133"
age "30"
sensordatavalues
0
value_type "SDS_P1"
value "9.95"
1
value_type "SDS_P2"
value "3.60"
2
value_type "BME280_temperature"
value "23.11"
3
value_type "BME280_pressure"
value "100378.88"
4
value_type "BME280_humidity"
value "56.71"
5
value_type "samples"
value "5058621"
6
value_type "min_micro"
value "28"
7
value_type "max_micro"
value "20037"
8
value_type "interval"
value "145000"
9
value_type "signal"
value "-42"