local = (day of the week)

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

Moderator: leecollings

Post Reply
TheCondor
Posts: 78
Joined: Thursday 18 June 2015 10:32
Target OS: Linux
Domoticz version:
Contact:

local = (day of the week)

Post 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 ...
....
...
alanlsmith
Posts: 132
Joined: Monday 07 August 2017 17:17
Target OS: Linux
Domoticz version: Latest β
Location: Near London (Saaarf!)
Contact:

Re: local = (day of the week)

Post by alanlsmith »

See: https://www.domoticz.com/wiki/User_variables

local day = tonumber(os.date("%w")) 0 is Sunday, 1 is Monday. ...
Domoticz Latest β, RPi 4B with 110Gb SSD for Domoticz, RPi 4B with 110Gb SSD for Node-Red & a RPi 2B for logging / IP addressing. RFXCOM, PiZiGate, Z-Wave, Harmony, Hue lamps and a bit of Broadlink.
TheCondor
Posts: 78
Joined: Thursday 18 June 2015 10:32
Target OS: Linux
Domoticz version:
Contact:

Re: local = (day of the week)

Post by TheCondor »

thanks, it works!
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: local = (day of the week)

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

Who is online

Users browsing this forum: Google [Bot] and 1 guest