I want to set a specific dim level at a specific time period.
Somehow the device is not acting on the setting.
this is my script
Code: Select all
return {
on = {
devices = {
'Dimmer 1'
}
},
execute = function(domoticz, device)
local dimmer = domoticz.devices('Dimmer 1')
local PreviousState = domoticz.variables('Dimmer_1').value
if ((dimmer.state == 'On') and (PreviousState) == ('Off')) then
domoticz.variables('Dimmer_1').set('On')
function timebetween(s,e)
timenow = os.date("*t")
year = timenow.year
month = timenow.month
day = timenow.day
s = s .. ":00" -- add seconds in case only hh:mm is supplied
e = e .. ":00"
shour = string.sub(s, 1, 2)
sminutes = string.sub(s, 4, 5)
sseconds = string.sub(s, 7, 8)
ehour = string.sub(e, 1, 2)
eminutes = string.sub(e, 4, 5)
eseconds = string.sub(e, 7, 8)
t1 = os.time()
t2 = os.time{year=year, month=month, day=day, hour=shour, min=sminutes, sec=sseconds}
t3 = os.time{year=year, month=month, day=day, hour=ehour, min=eminutes, sec=eseconds}
sdifference = os.difftime (t1, t2)
edifference = os.difftime (t1, t3)
isbetween = false
if sdifference >= 0 and edifference <= 0 then
isbetween = true
end
return isbetween
end
if timebetween("21:30:01","23:59:59") or timebetween("00:00:00","05:50:00") then
dimmer.switchSelector(70)
end
elseif ((dimmer.state == 'Off') and (PreviousState) ~= ('Off')) then
domoticz.variables('Dimmer_1').set('Off')
end
end
}
When I manually set the level (in domoticz) it does work.
Any pointers?
regards,