I use it with a light resistor on a ESP8266 with ESP Easy on it. The sensor added as analog input, value recalculated with formula "100-%value%/10" too make it appear as 0-100.
In domoticz i use this script:
Code: Select all
local DIMMABLE_LAMP = 'ding1' -- The light that must be dimmed
local SWITCH_ADAPTIVE = 'Adaptive light' -- The switch to turn on or off the adaptive option for this light
local LUX_VALUE = 'Lux anders' -- The input "Lux" sensor
local SMOOTH_FACTOR = 3 -- smooth factor, to prevent the light from adapting too much.
local MINIMUM = 20 -- minimum percentage the light can be, too prevent the light goes off
local MAXIMUM = 100 --maximum percentage the light can be, only change when you don't want it to go too 100%
-- Do not change anything below this, unless you know what you're doing...
return {
active = true,
on = {
devices = {
SWITCH_ADAPTIVE,
LUX_VALUE
},
},
data = {
averageLux = { history = true, maxItems = SMOOTH_FACTOR }
},
execute = function(domoticz, device, triggerInfo)
if (triggerInfo.type == domoticz.EVENT_TYPE_DEVICE) then
domoticz.data.averageLux.add(domoticz.devices(LUX_VALUE).lux)
end
if (domoticz.devices(SWITCH_ADAPTIVE).state == 'On') then
domoticz.devices(DIMMABLE_LAMP).dimTo(
(((MAXIMUM - MINIMUM) / 100) * (domoticz.data.averageLux.avg())) + MINIMUM
)
end
end
}
Leander