I have a wall switch that I use to control some lamps with dimmer function. I have NoOn Wall Switch Cozy White and Aeon Labs dimmers. Each button on the wall switch have 4 functions; press, press and hold, release and double click. When using the press and hold function, the LUA script starts the dimmer routine (up or down), and when I release the button it's supposed to stop dimming.
The problem is that the script don't get the release signal from the wall switch. As far as I can understand, the info sent to the script is static, and any triggers made during the execution isn't recognized inside the script? This means that the release signal from the wall switch wont be captured by the script. I'm a wrong, or is there a way round this limitation?
Right now I have a different, not very practical, solution.
Code: Select all
return {
active = true,
on = {
devices = {
'BT:*', 'BS:*'
}
},
execute = function(domoticz, switch)
local func = {}
func['BT: B1 - Press'] = {f = 'on/dim', device = 'Lampor trappa', step = 10, lmin = 18}
func['BT: B2 - Press'] = {f = 'dim', device = 'Lampor trappa', step = -10, lmin = 18}
func['BT: B2 - Hold'] = {f = 'off', device = 'Lampor trappa', step = 10, lmin = 18}
func['BT: B3 - Press'] = {f = 'on/dim', device = 'Lampor tak', step = 10, lmin = 28}
func['BT: B4 - Press'] = {f = 'dim', device = 'Lampor tak', step = -10, lmin = 28}
func['BT: B4 - Hold'] = {f = 'off', device = 'Lampor tak', step = 10, lmin = 28}
func['BS: B1 - Press'] = {f = 'on', device = 'Taklampor sovrum', step = 0, lmin = 0}
func['BS: B2 - Press'] = {f = 'off', device = 'Taklampor sovrum', step = 0, lmin = 0}
func['BS: B3 - Press'] = {f = 'on/dim', device = 'Lampor tak', step = 10, lmin = 28}
func['BS: B4 - Press'] = {f = 'dim', device = 'Lampor tak', step = -10, lmin = 28}
func['BS: B4 - Hold'] = {f = 'off', device = 'Lampor tak', step = 10, lmin = 28}
local dev = domoticz.devices(func[switch.name].device)
if dev.state == 'On' and string.find(func[switch.name].f, 'dim') then
dimLevel = math.min(math.max(func[switch.name].lmin,dev.level + func[switch.name].step),99)
dev.dimTo(dimLevel)
elseif string.find(func[switch.name].f, 'off') then
dev.switchOff()
elseif string.find(func[switch.name].f, 'on') then
dev.switchOn()
end
end
}