Page 1 of 1

sunrise / sunset trigger

Posted: Friday 15 December 2017 8:15
by GAEvakYD
I've a question about the sunrise and sunset trigger. I want to put on a virtual switch. So I've used the code below.

I expected two events. At sunrise and at sunset. But in the log I can see that I got four events. Before and After Sunset en Sunrise. Is there an option to only get two triggers? I've tried "1 minutes after sunrise" trigger, but I can't find where to check on in my code.

Code: Select all

return {
	active = true,
	on = {
		timer = {
		    --At sunrise en at sunset doesn't work because then you get to events. Before AND after sunset/sunrise
			'at sunrise',                 -- uses sunset/sunrise info from Domoticz
            'at sunset'
		}
	},
	execute = function(domoticz, device, triggerInfo)
	    local IsHetDonkerBuiten = domoticz.devices('IsHetDonkerBuiten')
                        
	    if (timerInfo.trigger == 'at sunset')
	    then
		    IsHetDonkerBuiten.switchOn()		 
		    domoticz.log('IsHetDonkerBuiten device is switched ON by dzVentz scripts TRIGGER 1');
		elseif (timerInfo.trigger == 'at sunrise')
		then
		    IsHetDonkerBuiten.switchOff()
		    domoticz.log('IsHetDonkerBuiten device is switched OFF by dzVentz scripts TRIGGER 2');
	end
}

Re: sunrise / sunset trigger

Posted: Friday 15 December 2017 20:41
by dannybloe
That is strange. There is no code that should trigger four events. Are you sure that you don't have the script double on your file system? Can you show the log?

Re: sunrise / sunset trigger

Posted: Saturday 16 December 2017 12:19
by GAEvakYD
Ahhhh I've found it.

My is dzVents is named vzIsDonker. Now I've got two triggers in that script:
'1 minutes after sunrise',
'1 minutes before sunset'

The log gives informatie that the triggers works Ok, but there are something with an internal Scheduler.
See the log rules at:
2017-12-15 08:09:01.245 Schedule item started! Name: IsHetDonkerBuiten, Type: Before Sunrise
2017-12-15 09:09:01.657 Schedule item started! Name: IsHetDonkerBuiten, Type: After Sunrise

I looked at the virtual devices and there where two internal timers on that devices.

So, can be closed. Oeps. :lol: :lol: :lol:

Code: Select all

2017-12-15 08:09:01.245 Schedule item started! Name: IsHetDonkerBuiten, Type: Before Sunrise, DevID: 78, Time: 2017-12-15 08:09:01
2017-12-15 08:40:00.368 dzVents: Info: ------ Start internal script: vzIsDonker:, trigger: 1 minutes after sunrise
2017-12-15 08:40:00.371 dzVents: Info: Trigger goes off:
2017-12-15 08:40:00.371 dzVents: Info: ------ Finished vzIsDonker
2017-12-15 09:09:01.657 Schedule item started! Name: IsHetDonkerBuiten, Type: After Sunrise, DevID: 78, Time: 2017-12-15 09:09:01
2017-12-15 16:21:00.317 dzVents: Info: ------ Start internal script: vzIsDonker:, trigger: 1 minutes before sunset
2017-12-15 16:21:00.320 dzVents: Info: Trigger goes off:
2017-12-15 16:21:00.320 dzVents: Info: ------ Finished vzIsDonker
2017-12-16 00:00:00.023 EventSystem: reset all events...
2017-12-16 00:00:00.023 EventSystem: Write file: /home/ruald/Downloads/domoticz/scripts/dzVents/generated_scripts/vzIsDonker.lua
2017-12-16 08:09:01.114 Schedule item started! Name: IsHetDonkerBuiten, Type: Before Sunrise, DevID: 78, Time: 2017-12-16 08:09:01
2017-12-16 08:41:00.424 dzVents: Info: ------ Start internal script: vzIsDonker:, trigger: 1 minutes after sunrise
2017-12-16 08:41:00.427 dzVents: Info: Trigger goes off:
2017-12-16 08:41:00.427 dzVents: Info: ------ Finished vzIsDonker
2017-12-16 09:09:01.525 Schedule item started! Name: IsHetDonkerBuiten, Type: After Sunrise, DevID: 78, Time: 2017-12-16 09:09:01

Re: sunrise / sunset trigger

Posted: Wednesday 20 December 2017 18:10
by rjblake
Just in case others have noticed some strange behaviours, with V3.8794 a bug has been introduced that results in 'Daytime' always being 'True'. There is a temporary fix if you compile yourself documented viewtopic.php?f=6&t=21002

Re: sunrise / sunset trigger

Posted: Wednesday 20 December 2017 19:06
by Varazir
Why not just create a dummy switch and add a timer to it ?

Code: Select all

Yes	After Sunrise		00:00	No	On	Everyday
Yes	After Sunset		00:00	No	Off	Everyday