When I use json from a browser to update sensor updates and there is an entry in the sensor log
Http://192.xxx.xxx.xxx:8080/json.htm?ty ... =%27RED%27
In Dzvents using update AlertSensor sensor updates but there is no entry in the sensor log
dz.devices(118).updateAlertSensor(ALERTLEVEL_YELLOW, 'Moderate')
Is there something else I need to do in Dzvents?
Thanks
-Gary
- Spoiler: show
Code: Select all
return { on = { timer = { 'every 30 minutes', --'every minute', }, httpResponses = { 'all', }, devices = { 'HRV Recirc SW', }, }, logging = { level = domoticz.LOG_ERROR, marker = "AQI Alert" }, execute = function(dz, item) if (item.isTimer) then dz.openURL({ url = 'http://192.168.1.29:8080/json.htm?type=devices&rid=111', method = 'GET', callback = 'all', -- see httpResponses above. --dz.log('Timer OpenURL') }) elseif (item.isDevice) then -- dzlog(HRV.state) --if (item.active) then if (dz.devices(150).active) then dz.devices(118).updateAlertSensor(ALERTLEVEL_YELLOW, 'Moderate') dz.devices(147).switchOn() else dz.devices(147).switchOff() dz.devices(118).updateAlertSensor(ALERTLEVEL_GREEN, 'GOOD') end elseif (item.isHTTPResponse) then --dz.log('HTTPResponse') if (item.statusCode == 200) then -- dz.log('Status 200') if (item.isJSON) then PM2_5 = item.json.result[1]['Data']; --dz.log('RAW '.. PM2_5 ) PM2_5Value = string.sub(PM2_5, 1, 1) --dz.log('ug/m3 ' .. PM2_5Value ) AlertLevel = tonumber(PM2_5Value) dz.log('AlertLevel ' .. AlertLevel ) --PM2.5 ug/m3 AirQI if ((AlertLevel) <=12 ) then dz.devices(118).updateAlertSensor(ALERTLEVEL_GREEN, 'GOOD') --dz.devices(147).switchOff().checkFirst() -- switch HRV into fresh air mode if (dz.devices(150).active) then dz.devices(147).switchOn() else dz.devices(147).switchOff().checkFirst() -- switch HRV into fresh air mode end --0.0-12 0-50 Green/Good 1 elseif ((AlertLevel) >=13 and (AlertLevel)<=35 ) then dz.devices(118).updateAlertSensor(ALERTLEVEL_YELLOW, 'Moderate') dz.devices(147).switchOn() --switch HRV into recirculation --12.1-35.4 51-100 Moderate/yellow 2 elseif ((AlertLevel) >=36 and (AlertLevel)<=55 ) then dz.devices(118).updateAlertSensor(ALERTLEVEL_ORANGE, 'Unhealthy sensitive Groups') dz.devices(147).switchOn() --35.5-55.4 101-150 Orange/Unhealthy sensitive Groups 3 elseif ((AlertLevel) >=56 and (AlertLevel)<=150 ) then dz.devices(118).updateAlertSensor(ALERTLEVEL_RED, 'UNHEALTHY') dz.devices(147).switchOn() --55.5-150.4 151-200 RED/UNHEALTHY 4 end end end else dz.log('There was a problem handling the request', dz.LOG_ERROR) dz.log(item, dz.LOG_ERROR) end end }