[SOLVED] Timer trigger does not work

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

Moderator: leecollings

Post Reply
User avatar
McMelloW
Posts: 434
Joined: Monday 20 November 2017 17:01
Target OS: Raspberry Pi / ODroid
Domoticz version: V2024.1
Location: Harderwijk, NL
Contact:

[SOLVED] Timer trigger does not work

Post 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.
Last edited by McMelloW on Thursday 08 March 2018 16:55, edited 1 time in total.
Greetings McMelloW
User avatar
McMelloW
Posts: 434
Joined: Monday 20 November 2017 17:01
Target OS: Raspberry Pi / ODroid
Domoticz version: V2024.1
Location: Harderwijk, NL
Contact:

Re: Timer trigger does not work

Post 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?
Greetings McMelloW
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: Timer trigger does not work

Post 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 }
	},
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
User avatar
McMelloW
Posts: 434
Joined: Monday 20 November 2017 17:01
Target OS: Raspberry Pi / ODroid
Domoticz version: V2024.1
Location: Harderwijk, NL
Contact:

Re: Timer trigger does not work

Post 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.
Greetings McMelloW
User avatar
McMelloW
Posts: 434
Joined: Monday 20 November 2017 17:01
Target OS: Raspberry Pi / ODroid
Domoticz version: V2024.1
Location: Harderwijk, NL
Contact:

Re: Timer trigger does not work

Post 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.
Greetings McMelloW
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: Timer trigger does not work

Post 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.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
User avatar
McMelloW
Posts: 434
Joined: Monday 20 November 2017 17:01
Target OS: Raspberry Pi / ODroid
Domoticz version: V2024.1
Location: Harderwijk, NL
Contact:

Re: Timer trigger does not work

Post 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!
Greetings McMelloW
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest