time = variable value as trigger

Easy to use, 100% Lua-based event scripting framework.
Post Reply
TheCondor
Posts: 60
Joined: Thursday 18 June 2015 10:32
Target OS: Linux
Domoticz version:
Contact:

time = variable value as trigger

Post by TheCondor » Thursday 11 January 2018 18:54

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!

dannybloe
Posts: 1405
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi
Domoticz version:
Location: Ermelo
Contact:

Re: time = variable value as trigger

Post by dannybloe » Saturday 27 January 2018 11:47

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.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.

jake
Posts: 387
Joined: Saturday 30 May 2015 22:40
Target OS: Raspberry Pi
Domoticz version: beta
Contact:

Re: time = variable value as trigger

Post by jake » Wednesday 31 January 2018 19:10

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?

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests