My problem at the moment is I would like the script to start when the UV from Accuweather changes. The value of UV.uv works, but this local is made in the script so I can't use it to start the script. Is there a way to make this happen?
Thanks in advance!
Code: Select all
return {
on = {
timer = {'at 9:00', 'at 12:00', 'at 19:01', 'at 21:00'},
devices = {'UV Accuweather', 'Raam Ons Links', 'Raam Ons Rechts', 'Raam Ivo', 'Raam Pim'}
},
execute = function(dz, timer)
local UV = dz.devices('UV Accuweather')
local VarPimIvo = dz.variables('Var Luik Pim Ivo')
local VarOns = dz.variables('Var Luik Ons')
if dz.time.matchesRule('at 09:00') or
(UV.uv < 2 and
dz.time.matchesRule('at 09:00-19:00') ) then
dz.devices('Gordijn Ivo').switchOff()
dz.devices('Gordijn Pim').switchOff()
elseif dz.time.matchesRule('at 09:00') and
dz.time.matchesRule('on mon, tue, wed, thu, fri') then
dz.devices('Gordijn Ons').switchOff()
elseif dz.time.matchesRule('at 12:00-18:00') and
UV.uv < 2 then
dz.devices('Gordijn Ons').switchOff()
elseif dz.time.matchesRule('at 12:00-18:00') and
UV.uv > 1 and (
dz.devices('Raam Ivo').state == 'Open' or
dz.devices('Raam Pim').state == 'Open' ) then
dz.devices('Gordijn Ivo').stop()
dz.devices('Gordijn Pim').stop()
elseif dz.time.matchesRule('at 12:00-19:00') and
UV.uv > 1 and (
dz.devices('Raam Ons Rechts').state == 'Open' or
dz.devices('Raam Ons Links').state == 'Open' ) then
dz.devices('Gordijn Ons').stop()
elseif dz.time.matchesRule('at 12:00-18:00') and
UV.uv > 1 and
dz.devices('Raam Ivo').state == 'Closed' and
dz.devices('Raam Pim').state == 'Closed' then
dz.devices('Gordijn Ivo').switchOn()
dz.devices('Gordijn Pim').switchOn()
elseif dz.time.matchesRule('at 12:00-19:00') and
UV.uv > 1 and
dz.devices('Raam Ons Rechts').state == 'Closed' and
dz.devices('Raam Ons Links').state == 'Closed' then
dz.devices('Gordijn Ons').switchOn()
elseif dz.time.matchesRule('at 19:01') then
dz.devices('Gordijn Ivo').switchOn()
dz.devices('Gordijn Pim').switchOn()
elseif dz.time.matchesRule('at 21:00') then
dz.devices('Gordijn Ons').switchOn()
end
end
}