Page 1 of 1

[SOLVED] Timer trigger does not work

Posted: Saturday 10 February 2018 21:37
by McMelloW
Try to use the timer trigger according this example on the wiki page

'between aa and bb'

-- aa/bb can be a time stamp like 15:44
-- aa/bb can be sunrise/sunset
-- aa/bb can be 'xx minutes before/after sunrise/sunset'

Code: Select all

local StrTime = '15 minutes before sunrise'
local EndTime = '15 minutes after sunset'

	on = {
		timer = { 'every minute between StrTime and EndTime' }
	},
The script did not stop after 15 minutes past sunset, but kept on running every minute. Changed the line to:

Code: Select all

timer = { 'every minute at daytime' }
It stopped running straight away.

Re: Timer trigger does not work

Posted: Monday 12 February 2018 10:41
by McMelloW
Just wondering, the lines

local StrTime = '15 minutes before sunrise'
local EndTime = '15 minutes after sunset'


Are at the very top of the script. Is the correct place for these lines?

Re: Timer trigger does not work

Posted: Monday 12 February 2018 10:50
by dannybloe
Your rule isn't correct at all. It should be:

Code: Select all

local StrTime = '15 minutes before sunrise'
local EndTime = '15 minutes after sunset'

	on = {
		timer = { 'every minute between ' .. StrTime .. ' and ' .. EndTime }
	},

Re: Timer trigger does not work

Posted: Monday 12 February 2018 15:56
by McMelloW
dannybloe wrote: Monday 12 February 2018 10:50 Your rule isn't correct at all. It should be:

Code: Select all

local StrTime = '15 minutes before sunrise'
local EndTime = '15 minutes after sunset'

	on = {
		timer = { 'every minute between ' .. StrTime .. ' and ' .. EndTime }
	},
Thanks for the update. I misunderstood the examples on the wiki page.

Re: Timer trigger does not work

Posted: Tuesday 13 February 2018 12:04
by McMelloW
dannybloe wrote: Monday 12 February 2018 10:50 Your rule isn't correct at all. It should be:

Code: Select all

local StrTime = '15 minutes before sunrise'
local EndTime = '15 minutes after sunset'

	on = {
		timer = { 'every minute between ' .. StrTime .. ' and ' .. EndTime }
	},
From your example and the log I understood that the following should works too.

Code: Select all

	on = {
		timer = { 'every minute between 15 minutes before sunrise and 15 minutes after sunset' } 
	},
Changed it to the line I showed above. It worked OK yesterday evening and today in the morning.
Again, I am surprised by the simplicity of dzVents. It is so much easier to use dzVents for a script.

Re: Timer trigger does not work

Posted: Tuesday 13 February 2018 12:09
by dannybloe
Great!
What you did was put the name of a variable INSIDE the string (all between the quotes) so Lua doesn't know that it is a variable:

Code: Select all

'every minute between StrTime and EndTime'
So with this code dzVents just gets a string with literally 'StrTime' as piece of the rule and not your intended value.

Code: Select all

'every minute between ' .. StrTime .. ' and ' .. EndTime
Notice the concatenation of the string 'every minute between' and the VALUE of StrTime.

Re: Timer trigger does not work

Posted: Tuesday 13 February 2018 12:22
by McMelloW
Exactly, that is what I learned from your changed string. I did not realize dzVents is designed to recognize a string like

Code: Select all

timer = { 'every minute between 15 minutes before sunrise and 15 minutes after sunset' }
Well done!