sunrise / sunset trigger

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
GAEvakYD
Posts: 10
Joined: Saturday 16 August 2014 13:34
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

sunrise / sunset trigger

Post 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
}
Last edited by dannybloe on Friday 15 December 2017 20:35, edited 1 time in total.
Reason: code block
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: sunrise / sunset trigger

Post 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?
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
GAEvakYD
Posts: 10
Joined: Saturday 16 August 2014 13:34
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: sunrise / sunset trigger

Post 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
rjblake
Posts: 142
Joined: Friday 21 October 2016 9:25
Target OS: NAS (Synology & others)
Domoticz version:
Location: Netherlands
Contact:

Re: sunrise / sunset trigger

Post 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
User avatar
Varazir
Posts: 459
Joined: Friday 20 February 2015 22:23
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: sunrise / sunset trigger

Post 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
Raspberry PI 2 with RaZberry Controller 2016 ZWave+ and CC2531(zigbee)
Several IKEA devices/z-wave devices
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest