Page 1 of 1

local = (day of the week)

Posted: Thursday 08 February 2018 10:38
by TheCondor
Sorry for the very dummy question but how it's possible to fill a local variable with the day of the week?
I'm building a basic script that remind me to put out the garbage based on the week of the day but i'm stuck to define the variable:

local today = (day of the week)
if today = mon then
.... notify....
else if today = tue then
... notify ...
....
...

Re: local = (day of the week)

Posted: Thursday 08 February 2018 10:54
by alanlsmith
See: https://www.domoticz.com/wiki/User_variables

local day = tonumber(os.date("%w")) 0 is Sunday, 1 is Monday. ...

Re: local = (day of the week)

Posted: Thursday 08 February 2018 13:10
by TheCondor
thanks, it works!

Re: local = (day of the week)

Posted: Friday 09 February 2018 17:49
by dannybloe
Why not something like this?

Code: Select all

return {
	on  = {
		timer = { 'at 18:00 on mon', 'at 09:00 on tue' }
	}, 
	execute = function(domoticz, timer)
		if (timer.trigger == 'at 18:00 on mon') then
			-- it is monday
			domoticz.notify(' ..... ')
		end
		-- etc
	end
}