Page 1 of 1

time = variable value as trigger

Posted: Thursday 11 January 2018 17:54
by TheCondor
Hi, i'm looking to build some automations for the wake-up hour, like turn on tv on news channel and turn on some lamps.
I've already a script that is triggered as

Code: Select all

On
	Timer = 	(07.30 on Mon-Fri),
			(09.00 on Sat-Sun)

but it would usefull if i can put this value in a domoticz variable and let the dzvents scripts read the value of the variable as a trigger. So it will be possible

a) to change the hour more easy
b) let another script change the value according for example to a google calendar holiday date
c) in the future change the value from alexa or google home or similar....

Any workaround is currently working for achieve that? Thanks all!

Re: time = variable value as trigger

Posted: Saturday 27 January 2018 10:47
by dannybloe
You can use a function as the timer rule. See the rules section in the documentation. Your function would be something like:

Code: Select all

return  {
	on = {
		timer = { 
			function(domoticz)
				return  ( domoticz.time.matchesRule(domoticz.variables('myCustomVarRule') )
			end
		}
	}, 
	execute = ...
}
But not that this function is evaluated every minute coz that's the heartbeat of Domoticz timer-based events. So be careful with performance.

Re: time = variable value as trigger

Posted: Wednesday 31 January 2018 18:10
by jake
I am looking for such a solution as well, but don't understand your example regarding variables time function.

Is it also possible to define a local variable on the first lines and reuse it in the timer onexecute?