Page 1 of 1

timer 'between sunset and civiltwilightend' not working

Posted: Thursday 15 November 2018 21:59
by ronaldbro
Hi,

I have a problem with one of the timers, the timer 'between sunset and civiltwilightend' doesn't seem to work.
Also
domoticz.log(Time(domoticz.time.rawDate .. ' 17:10:00').matchesRule('between sunset and civiltwilightend'))
returns false where I would expect it to be true.

Am I doing something wrong?

The other timers in the script (see below) are working fine.

Code: Select all

		timer = {
			'at 7:00-7:05',
			'at 8:30-8:35 on mon,tue,wed,thu,fri,sat',
			'at 10:30-10:35',
			'between sunrise and 5 minutes after sunrise',
			'between sunset and civilnighttime'
		}
Thanks for your help,
Ronald

Re: timer 'between sunset and civiltwilightend' not working

Posted: Saturday 17 November 2018 14:28
by waaren
ronaldbro wrote: Thursday 15 November 2018 21:59 Hi,

I have a problem with one of the timers, the timer 'between sunset and civiltwilightend' doesn't seem to work.
Also
domoticz.log(Time(domoticz.time.rawDate .. ' 17:10:00').matchesRule('between sunset and civiltwilightend'))
returns false where I would expect it to be true.

Am I doing something wrong?

The other timers in the script (see below) are working fine.

Code: Select all

		timer = {
			'at 7:00-7:05',
			'at 8:30-8:35 on mon,tue,wed,thu,fri,sat',
			'at 10:30-10:35',
			'between sunrise and 5 minutes after sunrise',
			'between sunset and civilnighttime'
		}
Thanks for your help,
Ronald
Your code is OK but there is still an issue with the use of civilnighttime in these kind of rules. No idea if this is going to be fixed soon.

Re: timer 'between sunset and civiltwilightend' not working

Posted: Saturday 17 November 2018 14:40
by ronaldbro
Ok, thanks.
I’m now using ‘between sunset and 60 minutes after sunset’ as a workaround. This works fine too.

Re: timer 'between sunset and civiltwilightend' not working

Posted: Sunday 18 November 2018 0:11
by waaren
ronaldbro wrote: Thursday 15 November 2018 21:59 Hi,

I have a problem with one of the timers, the timer 'between sunset and civiltwilightend' doesn't seem to work.
Also
domoticz.log(Time(domoticz.time.rawDate .. ' 17:10:00').matchesRule('between sunset and civiltwilightend'))
returns false where I would expect it to be true.

Am I doing something wrong?

The other timers in the script (see below) are working fine.

Code: Select all

		timer = {
			'at 7:00-7:05',
			'at 8:30-8:35 on mon,tue,wed,thu,fri,sat',
			'at 10:30-10:35',
			'between sunrise and 5 minutes after sunrise',
			'between sunset and civilnighttime'
		}
Thanks for your help,
Ronald
@Ronald,
Had a look at this and do think I found something. Can you please have a look at the Lua code in domoticz/dzVents/runtime/Time.lua
at line 926 and change

Code: Select all

if (twilight) then
to

Code: Select all

if (twilightstart) then
and on line 932 and change

Code: Select all

if (twilight) then
to

Code: Select all

if (twilightend) then
and test your time rule 'between sunset and civilnighttime' with this ?
It looks like this code caused the issue.

Re: timer 'between sunset and civiltwilightend' not working

Posted: Sunday 18 November 2018 13:23
by ronaldbro
Thanks.
This works perfect with .matchRule

the following code now returns false, true, false which is correct.

Code: Select all

            dz.log(Time(dz.time.rawDate .. ' 16:10:00').matchesRule('between sunset and civiltwilightend'))
            dz.log(Time(dz.time.rawDate .. ' 17:10:00').matchesRule('between sunset and civiltwilightend'))
            dz.log(Time(dz.time.rawDate .. ' 18:10:00').matchesRule('between sunset and civiltwilightend'))
I guess the timer will work too now. I'll know for sure tonight.

Maybe more a theoratical question. (I'm new to Rasp Pi and Domoticz , busy for one week now, but I do have a software background.)
The main reason I use these timers is to limit the number of triggers during the day. Doesn't make sense to get a trigger every minute for 3 actions per day in my opinion. Or does dzVents check the trigger settings in the script every minute anyway? In that case it doesn't make sense to limit the number of triggers?

Re: timer 'between sunset and civiltwilightend' not working

Posted: Sunday 18 November 2018 19:29
by ronaldbro
I can confirm that the timer also worked perfectly :)

Re: timer 'between sunset and civiltwilightend' not working

Posted: Sunday 18 November 2018 22:32
by waaren
ronaldbro wrote: Sunday 18 November 2018 13:23 Maybe more a theoratical question. (I'm new to Rasp Pi and Domoticz , busy for one week now, but I do have a software background.)
The main reason I use these timers is to limit the number of triggers during the day. Doesn't make sense to get a trigger every minute for 3 actions per day in my opinion. Or does dzVents check the trigger settings in the script every minute anyway? In that case it doesn't make sense to limit the number of triggers?
@dannybloe is in a much better position to answer this but dzVents has to do more than just the check of the timers = section when the execute = function part needs to be loaded and executed. So there is an advantage of preventing the activation execute = function section but because of the very efficient Lua processing, the difference between one approach or the other, is almost not measurable on my RPI-3 system.

Re: timer 'between sunset and civiltwilightend' not working

Posted: Sunday 18 November 2018 22:37
by waaren
ronaldbro wrote: Sunday 18 November 2018 19:29 I can confirm that the timer also worked perfectly :)
Many thanks for testing this. I will create a PR to correct this and to add / change some dzVents device adapters later this week.
Please be aware that until this PR is merged into Domoticz, every update will overwrite the changes you made in the domoticz/dzVents/runtime folders. So you will have to redo those until the PR is merged.