The switch is a fibaro dimmer 2 with one button attached. The problem that I seem to have is that I don't seem to have a way to differentiate between the button press and the light switching as as it is one and the same event.
Below is what I currently have, but at this point the light does not switch on a the right setting and I am not able to alter the dim setting. Could anyone help me out?
Code: Select all
return {
on = {
devices = {
'Slaapkamer Plafond'
}
},
data = {
turnedOn = {initial = false}
},
execute = function(domoticz, device)
local lastDimmerLevel = device.lastLevel
if domoticz.time.isDayTime then
dimLvl = 98
else
dimLvl = 28
end
if (device.active and not turnedOn) then
-- de call naar silent() is nodig om te voorkomen dat dit script zichzelf blijft triggeren
device.dimTo(dimLvl).silent()
turnedOn = true;
domoticz.log(device.level)
elseif(not device.active) then
turnedOn = false
end
-- in alle gevallen na 40 minuten uit
device.switchOff().afterMin(40)
end
}