timer 'between sunset and civiltwilightend' not working

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

Moderator: leecollings

Post Reply
ronaldbro
Posts: 327
Joined: Thursday 15 November 2018 21:38
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Netherlands
Contact:

timer 'between sunset and civiltwilightend' not working

Post 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
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: timer 'between sunset and civiltwilightend' not working

Post 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.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
ronaldbro
Posts: 327
Joined: Thursday 15 November 2018 21:38
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Netherlands
Contact:

Re: timer 'between sunset and civiltwilightend' not working

Post by ronaldbro »

Ok, thanks.
I’m now using ‘between sunset and 60 minutes after sunset’ as a workaround. This works fine too.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: timer 'between sunset and civiltwilightend' not working

Post 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.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
ronaldbro
Posts: 327
Joined: Thursday 15 November 2018 21:38
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Netherlands
Contact:

Re: timer 'between sunset and civiltwilightend' not working

Post 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?
ronaldbro
Posts: 327
Joined: Thursday 15 November 2018 21:38
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Netherlands
Contact:

Re: timer 'between sunset and civiltwilightend' not working

Post by ronaldbro »

I can confirm that the timer also worked perfectly :)
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: timer 'between sunset and civiltwilightend' not working

Post 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.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: timer 'between sunset and civiltwilightend' not working

Post 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.
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: No registered users and 1 guest