Page 1 of 1

at Sunrise and at Sunset not working?

Posted: Saturday 09 June 2018 22:47
by RoRoo
Hi all!

I've been trying to get my script working correctly, but strangely enough, my script isn't getting started.
I currently have this code:

Code: Select all

return {
	active = true,
	on = {
		timer = {
		    
			'at Sunset',                 
            'at Sunrise'
		}
	},
	execute = function(domoticz, device, triggerInfo)
	    local AchterTuin_Licht = domoticz.devices('Sonoff_Tuinlicht')
	    local Voortuin_Licht = domoticz.devices('Buitenlamp_Voor')
                        
	    if (triggerInfo.trigger == 'at Sunset')
	    then
		    AchterTuin_Licht.switchOn().withinMin(15)
		    Voortuin_Licht.switchOn().withinMin(15)
		    domoticz.log('Sunset, tuinverlichting gaat random aan binnen 15 minuten.');
		    domoticz.notify('Domoticz Notification', 'Sunset, tuinverlichting gaat random aan binnen 15 minuten.', 'domoticz.PRIORITY_NORMAL')
		
		elseif (triggerInfo.trigger == 'at Sunrise')
		then
		    AchterTuin_Licht.switchOff().withinMin(15)
		    Voortuin_Licht.switchOff().withinMin(15)
		    domoticz.log('Sunrise, tuinverlichting gaat random uit binnen 15 minuten.');
		    domoticz.notify('Domoticz Notification', 'Sunrise, tuinverlichting gaat random uit binnen 15 minuten.', 'domoticz.PRIORITY_NORMAL')
        
	end
end
}
When I change "at Sunset" to "at NightTime" and "at Sunrise" to "at Daytime" the script works and the lights switch on, but I get my Notification and Log entry every minute..

Am I missing something for the sunset and sunrise to work?
My location has been set in Domoticz and I can see the sunset and rise times.

Version information:
Version: 3.9530
Build Hash: 30295913
Compile Date: 2018-05-29 14:27:24
dzVents Version: 2.4.6
Python Version: 3.5.3 (default, Jan 19 2017, 14:11:04) [GCC 6.3.0 20170124]

Re: at Sunrise and at Sunset not working?

Posted: Saturday 09 June 2018 23:28
by waaren
RoRoo wrote: Saturday 09 June 2018 22:47 I've been trying to get my script working correctly, but strangely enough, my script isn't getting started.
I currently have this code:

Code: Select all

.....
		timer = {  'at Sunset',  'at Sunrise' } },
		.....
		
When I change "at Sunset" to "at NightTime" and "at Sunrise" to "at Daytime" the script works and the lights switch on, but I get my Notification and Log entry every minute..

Am I missing something for the sunset and sunrise to work?
I have not tested it but at first glance it looks like it has something to do with the use of uppercase in your timer settings.
You should use 'at sunset', 'at sunrise'

Re: at Sunrise and at Sunset not working?

Posted: Sunday 10 June 2018 12:16
by RoRoo
Could it be thát stupid? The DZVents editor autofills with a capital, but I can't remember if I've tested it without...

I'll change it. Thanks for the tip!

Re: at Sunrise and at Sunset not working?

Posted: Sunday 10 June 2018 15:43
by dannybloe
Yes, it is that stupid. Case sensitive it is.

Re: at Sunrise and at Sunset not working?

Posted: Sunday 10 June 2018 16:27
by RoRoo
dannybloe wrote: Sunday 10 June 2018 15:43 Yes, it is that stupid. Case sensitive it is.
Such a simple error that had me tinkering for days :)
I trust my lights will go on this evening.

The autofill in the editor was filling Sunrise due to my notification text. I've mistaken it for feature filling.