But there is always this log that the Value is "a nil value" it seems the local variable is not recognized.
Someone any idea how to solve this? See script and log below.
Code: Select all
local RANDOM_DELAY_MINS = 20
return {
on = { timer = { 'at nighttime at 07:00 on mon, tue, wed, thu, fri',
'at nighttime at 08:20 on sat, sun',
'at sunrise',
'at sunset',
'at 15 minutes before sunset',
'at 22:00 at nighttime on mon, tue, wed, thu, fri, sat, sun',
'at 23:15' }
-- timer = { 'at sunrise' },
-- timer = { 'at 23:00 at nighttime on mon, tue, wed, thu, fri, sat, sun'}
},
execute = function(domoticz, timer)
domoticz.log(timer.trigger)
if (domoticz.time.matchesRule('at 07:00')) then
domoticz.log('Dit werkt om 7:00 uur')
domoticz.groups('Binnen-Lampen').switchOn().repeatAfterSec(1,3)
elseif (domoticz.time.matchesRule('at 08:20')) then
domoticz.log('Dit werkt om 8:20 uur op Zaterdag en Zondag')
domoticz.groups('Binnen-Lampen').switchOn().repeatAfterSec(1,3)
elseif (domoticz.time.matchesRule('at sunrise')) then
domoticz.log('Zonsopkomst')
domoticz.groups('Binnen-Lampen').switchOff().repeatAfterSec(1,3)
elseif (domoticz.time.matchesRule('at 15 minutes before sunset') and domoticz.time.matchesRule('at 00:00-23:00')) then
domoticz.log('15 minuten voor Zonsondergang')
domoticz.groups('Binnen-Lampen').switchOn().repeatAfterSec(1,3)
elseif (domoticz.time.matchesRule('at 23:15') and domoticz.devices('$Hulp-Laat-Thuis').state == 'Off') then
domoticz.log('Slaaplekker')
domoticz.groups('Binnen-Lampen').switchOff().within_min(RANDOM_DELAY_MINS)
domoticz.groups('Binnen-Lampen').switchOff().aftermin('30')
else
domoticz.log('Slaaplekkerrrrrr binnen')
end
end
}
Code: Select all
2019-06-14 23:15:00.611 Status: dzVents: Error (2.4.19): An error occured when calling event handler DZ_SfeerVerlichtingBinnen
2019-06-14 23:15:00.611 Status: dzVents: Error (2.4.19): .../dzVents/generated_scripts/DZ_SfeerVerlichtingBinnen.lua:30: attempt to call field 'within_min' (a nil value)
2019-06-14 23:15:00.611 Status: dzVents: Info: ------ Finished DZ_SfeerVerlichtingBinnen
2019-06-14 23:15:00.612 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua