I am trying to program a watering selector so as not to disrupt a watering in progress: it is mandatory to go through STOP before changing the watering mode.
When level 0 is hidden my script works correctly but the icon remains blue even in the STOP position which is not normal.
On the other hand, when I activate level 0 the script does not work because devSel.lastLevel never takes the value 0. On the other hand, the icon becomes grayed out which I like more.
Code: Select all
execute = function(dz, item)
local devSel = dz.devices('Arrosage')
local varEtat = dz.variables('Etat Arrosage Auto')
print('==> Selecteur NEW = ' .. devSel.level)
print('==> Selecteur LAST = ' .. devSel.lastLevel)
-- Selecteur sur Auto ou Auto fixe
if devSel.level > 30 then
varEtat.set ('Manuel')
elseif devSel.level > 10 then
varEtat.set ('En cours')
else
varEtat.set ('Terminé')
print('Color ' ..devSel.getColor)
devSel.icon= Light
devSel.setHotWater(true) -- non defini
end
if devSel.level > 10 and devSel.lastLevel > 10 then -- <> de STOP on interdit la maj
devSel.switchSelector(devSel.lastLevel).silent()
end
end