Page 1 of 1

Sunset and sunrise trigger troubles

Posted: Thursday 24 August 2017 10:18
by dk78
I'm trying to close and open my curtains with the timer triggers sunset and sunrise. With sunset it's working, but with sunrise it won't. I've testing if the state is Open\Closed or On\Off and know that it's Open\Closed. So the curtains are closed with the sunset trigger after 20 minutes, but in the morning the curtains won't open automatically. Is there something I miss?

This is my script:

Code: Select all

-- Script wat gordijnen open en dicht doet.
-- 

return {
   active = true,
   on = {
      timer = {'at sunset'},
		  {'at sunrise'}
   },
   execute = function(domoticz, gordijnen) 
		local mswitch = domoticz.devices('Masterswitch') -- Masterswitch die script laat uitvoeren of niet
		local gordijnen = domoticz.devices('Gordijnen voor')
		   		        
      if (gordijnen.state == 'Open') and (mswitch.levelName == 'Automatisch') then
         gordijnen.close().afterMin(20)
	  elseif (gordijnen.state == 'Closed') and (mswitch.levelName == 'Automatisch') then
		 gordijnen.open().afterMin(15)
      end
   end
}
I'm running Domoticz on a RPi 2 with version V3.8300.

Re: Sunset and sunrise trigger troubles

Posted: Thursday 24 August 2017 10:21
by dk78
Hmm, when I"m looking at the script now, I think I see the issue. Can someone please confirm if it's in the manner to apply multiple timers?

Do I need to do it like this:

Code: Select all

	on = {
		['timer'] = {
			'sunset',
			'sunrise'
		}

Re: Sunset and sunrise trigger troubles

Posted: Thursday 24 August 2017 21:14
by dk78
Hmm, this didn't do the trick. I'll try no this method:

Code: Select all

	on = {
		timer = {
			'at sunset',
			'at sunrise'
		}
To bad that it will trigger only twice a day. Hope tomorrow the curtains are open when I wake up.

Re: Sunset and sunrise trigger troubles

Posted: Saturday 26 August 2017 12:47
by dk78
Yesterday I tried the following script, but it isn't working. I think it's because of the '(triggerInfo.trigger == 'at sunset')' and '(triggerInfo.trigger == 'at sunrise')'. Is there something I'm doing wrong?

Code: Select all

-- Script wat gordijnen open en dicht doet.
-- 

return {
   active = true,
   on = {
		timer = {
    			'at sunset',
	    		'at sunrise'
		        }
   },
   execute = function(domoticz, gordijnen)
	       local mswitch = domoticz.devices('Masterswitch') -- Masterswitch die script laat uitvoeren of niet
		   		   
		   local gordijnen = domoticz.devices('Gordijnen voor')
		   		        
      if (gordijnen.state == 'Open') and (triggerInfo.trigger == 'at sunset') and (mswitch.levelName == 'Automatisch') then
         gordijnen.close().afterMin(30)
	  elseif (gordijnen.state == 'Closed') and (triggerInfo.trigger == 'at sunrise') and (mswitch.levelName == 'Automatisch') then
		 gordijnen.open().afterMin(15)
      end
   end
}

Re: Sunset and sunrise trigger troubles

Posted: Saturday 26 August 2017 13:27
by EddyG
Should it not be:

Code: Select all

execute = function(domoticz, device, triggerInfo)

Re: Sunset and sunrise trigger troubles

Posted: Saturday 26 August 2017 14:16
by dk78
Should that do the trick? I'll try it today at sunset. Thanks!