Code: Select all
return
{
on =
{
devices =
{
'CO<sub>2</sub>-sensor', -- custom sensor
},
},
logging =
{
level = domoticz.LOG_DEBUG, -- Change to domoticz.LOG_ERROR when script is OK
marker = 'CO2-alert',
},
execute = function(dz, device)
local co2 = dz.devices('CO<sub>2</sub>-sensor').sensorValue
local co2alert = dz.devices('CO2')
local function CO2_Index2Alert(value)
local alert = dz.ALERTLEVEL_RED
if index < 350 then alert = dz.ALERTLEVEL_GREY
elseif index < 1000 then alert = dz.ALERTLEVEL_GREEN
elseif index < 1100 then alert = dz.ALERTLEVEL_YELLOW
elseif index < 1200 then alert = dz.ALERTLEVEL_ORANGE
end
return alert
end
CO2_AlertText = "CO<sub>2</sub>" .. co2 .. "ppm" ..
dz.devices(co2alert).updateAlertSensor(CO2_Index2Alert(co2), CO2_AlertText)
end
end
}
Thanks in advance!