With a custom switch, the Wakeup selector, i can select: off, auto/calender of multiple time options
The auto/calender options loads a text string from a custom switch (text) where the next calender item is linked into (ical).
The time options (and the second part of the auto/calender option) are using the script below.
Code: Select all
return {
active = true,
on = {
devices = {'Wakeup selector'},
timer = {'at 04:00'}
},
execute = function(domoticz)
if domoticz.devices('Wakeup selector').levelName == 'Uitgeschakeld' then
domoticz.variables('WEKKER').set('00:00')
elseif domoticz.devices('Wakeup selector').levelName == 'Agenda' then
if domoticz.devices('Agenda').text == 'D8G' then
domoticz.variables('WEKKER').set('05:45')
end
if domoticz.devices('Agenda').text == 'IEG' then
domoticz.variables('WEKKER').set('06:45')
end
if domoticz.devices('Agenda').text == '8IG' then
domoticz.variables('WEKKER').set('07:30')
end
else
if domoticz.devices('Wakeup selector').levelName == '06:17' then
domoticz.variables('WEKKER').set('05:45')
end
if domoticz.devices('Wakeup selector').levelName == '06:37' then
domoticz.variables('WEKKER').set('06:05')
end
.... and so on....
end
end
}
1. i have troubles to compare the .text (string) form my calendar with the given codes. Somehow it never result in a match. if i print the value in my log it shows identical values with the one to compare with but it refuses to work

2. Is there a cleaner option for handling the custom time selections? Because i cannot save the selector.levelName as a time variable i cannot count and say like, "set wekker .levelname minus 30 minutes." (not a big problem, just wondering how to solve this)
any tips/advice to solve this problem?