Is there a simple lua code i could use to deterime which seaon it is?
So if it is winter, spring, summer or autum (at my location)?
I want to use the season to set some lighting and temp control…
How can i do this simply?
Is there a simple lua code i could use to deterime which seaon it is?
So if it is winter, spring, summer or autum (at my location)?
I want to use the season to set some lighting and temp control…
How can i do this simply?
This may help:
Programming in Lua : 22.1
thx but not really, i still have to make rules to determine which season it is…
I meant more like a app or code like: isSummer() isWinter() isAutum() isSpring() which return me a true or false
Or a code like WhichSeason() which returns the actual season ‘spring’…
function WhichSeason()
local tNow = os.date("*t")
local dayofyear = tNow.yday
local season
if (dayofyear >= 79) and (dayofyear < 172) then season = "Spring"
elseif (dayofyear >= 172) and (dayofyear < 266) then season = "Summer"
elseif (dayofyear >= 266) and (dayofyear < 355) then season = "Autumn"
else season = "Winter"
end
return season
end
Note: This assumes that you are in the Northern hemisphere!
Or:
[code]function isSpring()
local tNow = os.date(“*t”)
local dayofyear = tNow.yday
return (dayofyear >= 79) and (dayofyear < 172)
end
function isSummer()
local tNow = os.date(“*t”)
local dayofyear = tNow.yday
return (dayofyear >= 172) and (dayofyear < 266)
end
function isAutumn()
local tNow = os.date(“*t”)
local dayofyear = tNow.yday
return (dayofyear >= 266) and (dayofyear < 355)
end
function isWinter()
local tNow = os.date(“*t”)
local dayofyear = tNow.yday
return (dayofyear >= 355) or (dayofyear < 79)
end[/code]
Note: The dayofyear conditions are only appropriate for the Northern hemisphere.
Best Home Automation shopping experience. Shop at Ezlo!
© 2024 Ezlo Innovation, All Rights Reserved. Terms of Use | Privacy Policy | Forum Rules