I wrote script which use domoticz.time.matchesRule.
I try set LED lvl during all day depends on actual time.
script works well, but i wonder if its possible to write it in more elegant way?
Code: Select all
return {
on = {
timer = {'between 10:00 and 23:40'} --uruchomienie skryptu co minute
},
logging = {
level = domoticz.LOG_INFO,
marker = "A240_LED_BLUE"
},
execute = function(domoticz)
if (domoticz.time.matchesRule('at 10:00-20:10')) then
BLUE_LVL = 50
BLUE = domoticz.devices('B1').level
if (BLUE ~= BLUE_LVL) then
domoticz.devices('B1').dimTo(BLUE_LVL)
domoticz.log('nowy poziom BLUE ' .. BLUE_LVL)
end
end
if (domoticz.time.matchesRule('at 20:11-21:00')) then
BLUE_LVL = 25
BLUE = domoticz.devices('B1').level
if (BLUE ~= BLUE_LVL) then
domoticz.devices('B1').dimTo(BLUE_LVL)
domoticz.log('nowy poziom BLUE ' .. BLUE_LVL)
end
end
if (domoticz.time.matchesRule('at 21:01-21:10')) then
BLUE_LVL = 12
BLUE = domoticz.devices('B1').level
if (BLUE ~= BLUE_LVL) then
domoticz.devices('B1').dimTo(BLUE_LVL)
domoticz.log('nowy poziom BLUE ' .. BLUE_LVL)
end
end
if (domoticz.time.matchesRule('at 21:11-22:00')) then
BLUE_LVL = 50
BLUE = domoticz.devices('B1').level
if (BLUE ~= BLUE_LVL) then
domoticz.devices('B1').dimTo(BLUE_LVL)
domoticz.log('nowy poziom BLUE ' .. BLUE_LVL)
end
end
if (domoticz.time.matchesRule('at 22:01-22:30')) then
BLUE_LVL = 25
BLUE = domoticz.devices('B1').level
if (BLUE ~= BLUE_LVL) then
domoticz.devices('B1').dimTo(BLUE_LVL)
domoticz.log('nowy poziom BLUE ' .. BLUE_LVL)
end
end
if (domoticz.time.matchesRule('at 22:31-23:00')) then
BLUE_LVL = 1
BLUE = domoticz.devices('B1').level
if (BLUE ~= BLUE_LVL) then
domoticz.devices('B1').dimTo(BLUE_LVL)
domoticz.log('nowy poziom BLUE ' .. BLUE_LVL)
end
end
if (domoticz.time.matchesRule('at 23:01-23:30')) then
BLUE_LVL = 0
BLUE = domoticz.devices('B1').level
if (BLUE ~= BLUE_LVL) then
domoticz.devices('B1').dimTo(BLUE_LVL)
domoticz.log('nowy poziom BLUE ' .. BLUE_LVL)
end
end
end
}