Weird problem with this selector switch...
This is the case:
Running Domoticz 2.4552 on a RPI2, using RFXTRX433E.
1 have a 3-speed fan. The motor is supplied by two 'hot' leads and one 'neutral'. I use 2 KAKU switches for it: Fan 1 and Fan 2. If only one of them is on, the fan runs at speed 1 or 2. If both are on, it's running at speed 3.
I control this fan by a 4-state Selector switch:
Off, low, medium, high
I also use a KAKU remote, named 'Kitchen Fan'. By pushing the On button, the fan cycles through speed 1, 2, 3. By pushing Off, the fan turns off.
Selector switch is called 'Fan'
A section of my master LUA script is handling the logic.
The weird part: when the fan is turned off, the LUA script keeps on looping: the selector switch keeps on triggering. It is not looping in any of the other states: low, medium, high.
To solve this issue.. (even weirder).. In the selector switch's options, I have hidden the built-in 'Off' state and I created a new state, called 'off'. (without capital O)
After adjusting my LUA script for this, everything works as a charm.
Here's part of my LUA script (current, working version)
Code: Select all
commandArray = {}
local dev=next(devicechanged)
local cmd=devicechanged[dev]
--Left out some code that's not relevant to the fan, here--
--Kitchen fan
if dev=='Kitchen Fan' and cmd=='On' and otherdevices['Fan']=='off' then
dev='SetFan'
cmd='Set Level: 20'
end
if dev=='Kitchen Fan' and cmd=='On' and otherdevices['Fan']=='low' then
dev='SetFan'
cmd='Set Level: 30'
end
if dev=='Kitchen Fan' and cmd=='On' and otherdevices['Fan']=='medium' then
dev='SetFan'
cmd='Set Level: 40'
end
if dev=='Kitchen Fan' and cmd=='On' and otherdevices['Fan']=='high' then
dev='SetFan'
cmd='Set Level: 20'
end
if dev=='Kitchen Fan' and cmd=='Off' and otherdevices['Fan']~='off' then
dev='SetFan'
cmd='Set Level: 10'
end
if dev=='SetFan' or dev=='Fan' then
cmdarr='Fan'
end
if cmdarr=='Fan' then
if cmd=='low' or cmd=='Set Level: 20' then
commandArray[1]={['Fan 2']='Off'}
commandArray[2]={['Fan 1']='On'}
end
if cmd=='medium' or cmd=='Set Level: 30' then
commandArray[1]={['Fan 1']='Off'}
commandArray[2]={['Fan 2']='On'}
end
if cmd=='high' or cmd=='Set Level: 40' then
commandArray[1]={['Fan 1']='On'}
commandArray[2]={['Fan 2']='On'}
end
if cmd=='off' or cmd=='Set Level: 10' then
commandArray[1]={['Fan 1']='Off'}
commandArray[2]={['Fan 2']='Off'}
end
end
--output
if (cmdarr~=nil) and (cmd~=nil) then
commandArray[cmdarr]=cmd
end
return commandArray
Dummy selector switch settings:
Fan icon, states: Off, off, low, medium, high
Off state hidden
No actions
Did I run into a bug, here? Has anyone else seen LUA looping at the built-in 'Off' state?