[SOLVED] Time trigger fires outside of defined date range

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

Moderator: leecollings

Post Reply
zavjah
Posts: 36
Joined: Tuesday 13 August 2019 10:20
Target OS: Raspberry Pi / ODroid
Domoticz version:

[SOLVED] Time trigger fires outside of defined date range

Post by zavjah »

Hello,

I have encountered a strange behavior with this time trigger recently:

Code: Select all

	on = {timer = 
	        {'20 minutes after sunrise on mon,tue,wed,thu,fri on 2/3-30/09',    	-- Summer time during the week
	         'at 08:00 on sat,sun on 2/3-30/09',                                			-- Summer time, weekend
	         'at 09:00 on 1/10-31/12,1/1-01/03'                                			-- Winter time
	        }
	     },
Although it should not (it is before 2/3) the first line is triggering the rest of the script, which ios shown in the log, too:

Code: Select all

2021-01-21 08:26:00.483  Status: dzVents: Info: ------ Start internal script: Rollladen_AufMorgens:, trigger: "20 minutes after sunrise on mon,tue,wed,thu,fri on 2/3-30/09"
2021-01-21 08:26:00.498  Status: dzVents: Info: ===>>> Normale Sommerzeit, werktags: öffne Rollladen 20 Min. nach Sonnernaufgang <<<===
2021-01-21 08:26:00.598  Status: dzVents: Info: ------ Finished Rollladen_AufMorgens
Interesting enough, the last line, the only one that is supposed to trigger the script, is also triggered:

Code: Select all

2021-01-21 09:00:00.390  Status: dzVents: Info: ===>>> Winterzeit: öffne Rollladen erst um 09:00 <<<===
2021-01-21 09:00:00.493  Status: dzVents: Info: ------ Finished Rollladen_AufMorgens
I've checked everything but I cannot figure out, why this started to happen. I am not sure, when did it start, but i am pretty sure that it worked for a while correctly.

Can anyone tell me what is wrong?

thx,
Zavjah
Last edited by zavjah on Friday 22 January 2021 10:58, edited 1 time in total.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Time trigger fires outside of defined date range

Post by waaren »

zavjah wrote: Thursday 21 January 2021 18:22 Although it should not (it is before 2/3) the first line is triggering the rest of the script, which ios shown in the log, too:

Interesting enough, the last line, the only one that is supposed to trigger the script, is also triggered:
I cannot replicate this on my installation (dzVents 3.1.1 (Build 12865 )
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
zavjah
Posts: 36
Joined: Tuesday 13 August 2019 10:20
Target OS: Raspberry Pi / ODroid
Domoticz version:

Re: Time trigger fires outside of defined date range

Post by zavjah »

I am using dzvents 3.0.2, I assume that is the version of the stable codlre (see attachment.

Might this be the problem?

I upgraded sometime last summer and it might be that I didn't noticed the change because the trigger fitted the time.

Is this possible?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Time trigger fires outside of defined date range

Post by waaren »

zavjah wrote: Friday 22 January 2021 8:37 I am using dzvents 3.0.2, I assume that is the version of the stable code
Might this be the problem?
I just checked against the latest stable and could replicate your issue.

That leaves you with some choices:

1. Change your script into something like

Code: Select all

return
{
    on = 
    {
        timer = 
	    {
	         '20 minutes after sunrise on mon,tue,wed,thu,fri on 2/3-30/09',    	--during the week
	         'at 08:00 on sat,sun on 2/3-30/09',                   			-- Summer time, weekend
	         'at 09:00 on 1/10-31/12,1/1-01/03',                   			-- Winter time
	    },
	},

	logging = 
	{ 
	    level = domoticz.LOG_DEBUG,
	    marker = 'timeChecker',
	},
	
	execute = function(dz, item)
       
       local timeruleSummer = ( item.trigger == '20 minutes after sunrise on mon,tue,wed,thu,fri on 2/3-30/09' or item.trigger ==  'at 08:00 on sat,sun on 2/3-30/09')
    
       if timeruleSummer and dz.time.matchesRule('on 2/3-30/9') then 
            dz.log('It is summertime. I will continue (' .. item.trigger .. ').' ,dz.LOG_DEBUG)
        elseif timeruleSummer then 
            dz.log('It is outside summertime (' .. item.trigger..') I will stop.' ,dz.LOG_DEBUG)
            return
        end
   
        dz.log('Minutes sunrise ' .. dz.time.sunriseInMinutes ,dz.LOG_DEBUG)
        
        dz.log('Minutes now ' .. (dz.time.hour * 60 + dz.time.minutes)  ,dz.LOG_DEBUG)
        dz.log('Minutes delta ' .. (dz.time.hour * 60 + dz.time.minutes) - dz.time.sunriseInMinutes ,dz.LOG_DEBUG)
        
	end
}
2. update to beta
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
zavjah
Posts: 36
Joined: Tuesday 13 August 2019 10:20
Target OS: Raspberry Pi / ODroid
Domoticz version:

[SOLVED] Re: Time trigger fires outside of defined date range

Post by zavjah »

HI waaren,

thanks for testing on the latest stable. I'm glad, that now I know that the script is fine but dzvents wrong.

I'll consider upgrading to beta.

thx
Zavjah
zavjah
Posts: 36
Joined: Tuesday 13 August 2019 10:20
Target OS: Raspberry Pi / ODroid
Domoticz version:

Re: Time trigger fires outside of defined date range

Post by zavjah »

waaren wrote: Friday 22 January 2021 10:24
zavjah wrote: Friday 22 January 2021 8:37 I am using dzvents 3.0.2, I assume that is the version of the stable code
Might this be the problem?
I just checked against the latest stable and could replicate your issue.

That leaves you with some choices:

1. Change your script into something like

Code: Select all

return
{
    on = 
    {
        timer = 
	    {
	         '20 minutes after sunrise on mon,tue,wed,thu,fri on 2/3-30/09',    	--during the week
	         'at 08:00 on sat,sun on 2/3-30/09',                   			-- Summer time, weekend
	         'at 09:00 on 1/10-31/12,1/1-01/03',                   			-- Winter time
	    },
	},

	logging = 
	{ 
	    level = domoticz.LOG_DEBUG,
	    marker = 'timeChecker',
	},
	
	execute = function(dz, item)
       
       local timeruleSummer = ( item.trigger == '20 minutes after sunrise on mon,tue,wed,thu,fri on 2/3-30/09' or item.trigger ==  'at 08:00 on sat,sun on 2/3-30/09')
    
       if timeruleSummer and dz.time.matchesRule('on 2/3-30/9') then 
            dz.log('It is summertime. I will continue (' .. item.trigger .. ').' ,dz.LOG_DEBUG)
        elseif timeruleSummer then 
            dz.log('It is outside summertime (' .. item.trigger..') I will stop.' ,dz.LOG_DEBUG)
            return
        end
   
        dz.log('Minutes sunrise ' .. dz.time.sunriseInMinutes ,dz.LOG_DEBUG)
        
        dz.log('Minutes now ' .. (dz.time.hour * 60 + dz.time.minutes)  ,dz.LOG_DEBUG)
        dz.log('Minutes delta ' .. (dz.time.hour * 60 + dz.time.minutes) - dz.time.sunriseInMinutes ,dz.LOG_DEBUG)
        
	end
}
2. update to beta
Hi waaren,

just out of curiosity: which part of the trigger is misinterpreted by dzvents, "20 minutes after sunset"?

Cheers,
zavjah
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Time trigger fires outside of defined date range

Post by waaren »

zavjah wrote: Friday 22 January 2021 12:57 just out of curiosity: which part of the trigger is misinterpreted by dzvents ?
It is the combination of rules. That part is reworked in recent builds
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Post Reply

Who is online

Users browsing this forum: heggink and 1 guest