Morning, Afternoon, Evening - How Will Vera Know ?

Hi

If I want to invoke different things at different times of the day (e.g in the morning, afternoon and evening), is there anything built into Vera?

If not; as such a request could be called at any time, so it needs to know which time of day it is - so to do this do I have to code it all from scratch, starting with something like this…?

local mornstartTime = "00:00" local mornendTime = "11:59" local afterstartTime = "12:00" local afterendTime = "17:59" local evenstartTime = "18:00" local evenendTime = "23:59"

Has it been done before?

I managed to find some related stuff hidden deeper in the forum - with a few tweaks this looks to work quite well. http://forum.micasaverde.com/index.php/topic,10226.msg70910.html#msg70910

Just like the link above, I have used a dimmer level as a way to show it can be different depending on the time of day.

[code]local t = os.date(‘*t’)
local current_second = t.hour * 3600 + t.min * 60 – number of sec since midnight
local morning = 0 * 3600 + 0 * 60 – 00:00
local afternoon = 12 * 3600 + 0 * 60 – 12:00
local evening = 18 * 3600 + 0 * 60 – 18:00
local halldimmer = 22

if (current_second > morning) and (current_second < afternoon) then
luup.call_action(“urn:upnp-org:serviceId:Dimming1”, “SetLoadLevelTarget”, {newLoadlevelTarget = “100”}, halldimmer)
else

    if (current_second > afternoon) and (current_second < evening) then
         luup.call_action("urn:upnp-org:serviceId:Dimming1", "SetLoadLevelTarget", {newLoadlevelTarget = "50"}, halldimmer)  
    else

         luup.call_action("urn:upnp-org:serviceId:Dimming1", "SetLoadLevelTarget", {newLoadlevelTarget = "10"}, halldimmer)  
    end

end[/code]