Sunset and sunrise trigger troubles

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

Moderator: leecollings

Post Reply
User avatar
dk78
Posts: 26
Joined: Monday 07 March 2016 15:50
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Veldhoven
Contact:

Sunset and sunrise trigger troubles

Post 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.
User avatar
dk78
Posts: 26
Joined: Monday 07 March 2016 15:50
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Veldhoven
Contact:

Re: Sunset and sunrise trigger troubles

Post 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'
		}
User avatar
dk78
Posts: 26
Joined: Monday 07 March 2016 15:50
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Veldhoven
Contact:

Re: Sunset and sunrise trigger troubles

Post 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.
User avatar
dk78
Posts: 26
Joined: Monday 07 March 2016 15:50
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Veldhoven
Contact:

Re: Sunset and sunrise trigger troubles

Post 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
}
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: Sunset and sunrise trigger troubles

Post by EddyG »

Should it not be:

Code: Select all

execute = function(domoticz, device, triggerInfo)
User avatar
dk78
Posts: 26
Joined: Monday 07 March 2016 15:50
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Veldhoven
Contact:

Re: Sunset and sunrise trigger troubles

Post by dk78 »

Should that do the trick? I'll try it today at sunset. Thanks!
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest