Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- %% properties
- 141 value
- %% globals
- --]]
- local co2ID = 141 -- ID des netatmo co2-Sensor
- local rgbw_opt = true
- local rgbwID = 171
- local co2 = tonumber(fibaro:getValue(co2ID, "value"))
- --local co2 = 1050
- local co2_old = fibaro:getGlobal('netatmo_co2')
- local startSource = fibaro:getSourceTrigger()
- Debug = function ( color, message )
- fibaro:debug(string.format('<%s style="color:%s;">%s</%s>', "span", color, message, "span"))
- end
- -- Funktion RGBW
- function setRGBW (rgbw_option, deviceID, colourString)
- local RGBWTable= {}
- local i = 1
- for value in string.gmatch(colourString,"(%d+)") do
- RGBWTable[i] = value
- i = i + 1
- end
- if (rgbw_option) then
- if (tonumber(fibaro:getValue(deviceID, "brightness")) ~= 0) then
- fibaro:call(deviceID, "setColor", RGBWTable[1], RGBWTable[2], RGBWTable[3], RGBWTable[4])
- else
- fibaro:debug('RGBW = true; RGBW ist aus')
- end
- else
- fibaro:debug('RGBW = false')
- end
- end
- if (startSource['type'] == 'other') then
- Debug('white', "netatmo co2-Check 1.0 gestartet. Szene manuell gestartet")
- else
- Debug('green', "netatmo co2-Check 1.0 gestartet. Szene durch CO2-Wert gestartet")
- end
- --[[
- if (co2_old == nil) then
- Debug('red', "Die Variable netatmo_co2 muss noch eingerichtet werden")
- fibaro:abort()
- end
- --]]
- if (co2 < 1000) then
- Debug( "green", "co2-Wert von " .. co2 .. " ppm ist ok.")
- -- Setze grün auf 255 und rot auf 0
- setRGBW(rgbw_opt, rgbwID, '0,255,0,0')
- elseif (co2 >= 1000 and co2 <= 1050) then
- Debug( "orange", "co2-Wert von " .. co2 .. " ppm liegt leicht über dem empfohlenen Wert von 1000 ppm.")
- -- Setze grün auf 232 und rot auf 23
- setRGBW(rgbw, rgbwID, '255,232,0,0')
- elseif (co2 >= 1050 and co2 <= 1100) then
- Debug( "orange", "co2-Wert von " .. co2 .. " ppm liegt liegt über 1050 ppm. Es sollte gelüftet werden.")
- -- Setze grün auf 209 und rot auf 46
- setRGBW(rgbw_opt, rgbwID, '255,209,0,0')
- elseif (co2 >= 1100 and co2 <= 1150) then
- Debug( "orange", "co2-Wert von " .. co2 .. " ppm liegt liegt über 1100 ppm. Es sollte gelüftet werden.")
- -- Setze grün auf 186 und rot auf 69
- setRGBW(rgbw_opt, rgbwID, '255,186,0,0')
- elseif (co2 >= 1150 and co2 <= 1200) then
- Debug( "orange", "co2-Wert von " .. co2 .. " ppm liegt liegt über 1150 ppm. Es sollte dringend gelüftet werden.")
- -- Setze grün auf 163 und rot auf 92
- setRGBW(rgbw_opt, rgbwID, '255,163,0,0')
- elseif (co2 >= 1200 and co2 <= 1250) then
- Debug( "orange", "co2-Wert von " .. co2 .. " ppm liegt liegt über 1200 ppm. Es sollte dringend gelüftet werden.")
- -- Setze grün auf 140 und rot auf 115
- setRGBW(rgbw_opt, rgbwID, '255,140,0,0')
- elseif (co2 >= 1250 and co2 <= 1300) then
- Debug( "red", "co2-Wert von " .. co2 .. " ppm liegt liegt über 1250 ppm. Es sollte DRINGEND gelüftet werden.")
- -- Setze grün auf 117 und rot auf 138
- setRGBW(rgbw_opt, rgbwID, '255,117,0,0')
- elseif (co2 >= 1300 and co2 <= 1350) then
- Debug( "red", "co2-Wert von " .. co2 .. " ppm liegt liegt über 1300 ppm. Es sollte DRINGEND gelüftet werden.")
- -- Setze grün auf 94 und rot auf 161
- setRGBW(rgbw_opt, rgbwID, '255,94,0,0')
- elseif (co2 >= 1350 and co2 <= 1400) then
- Debug( "red", "co2-Wert von " .. co2 .. " ppm liegt liegt über 1350 ppm. Es sollte DRINGEND gelüftet werden.")
- -- Setze grün auf 71 und rot auf 184
- setRGBW(rgbw_opt, rgbwID, '255,71,0,0')
- elseif (co2 >= 1400 and co2 <= 1450) then
- Debug( "red", "co2-Wert von " .. co2 .. " ppm liegt liegt über 1400 ppm. Es sollte DRINGEND gelüftet werden.")
- -- Setze grün auf 48 und rot auf 207
- setRGBW(rgbw_opt, rgbwID, '255,48,0,0')
- elseif (co2 >= 1450 and co2 <= 1500) then
- Debug( "red", "co2-Wert von " .. co2 .. " ppm liegt liegt über 1450 ppm. Es sollte DRINGEND gelüftet werden.")
- -- Setze grün auf 25 und rot auf 230
- setRGBW(rgbw_opt, rgbwID, '255,25,0,0')
- elseif (co2 >= 1500) then
- Debug( "red", "co2-Wert von " .. co2 .. " ppm liegt liegt über 1500 ppm. Es sollte DRINGEND gelüftet werden.")
- -- Setze grün auf 0 und rot auf 255
- setRGBW(rgbw_opt, rgbwID, '255,0,0,0')
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement