I am a newbie trying to start with LUA. Can anybody help me with an answer for, Will the expression"math.floor( (luup.sunrise() % 86400) / 60 ) + 15" return a value of fifteen minutes past sunrise ? I get a wrong value all the time !
I think you need to divide by another 60 to convert to minutes?
Anyway, the best way to extract the type of information you seek is to use the os.date () call.
local t = os.date ("*t",luup.sunrise())
print (pretty(t))
which gives you all the components
{
day = 1,
hour = 8,
isdst = false,
min = 11,
month = 1,
sec = 58,
wday = 6,
yday = 1,
year = 2016
}
Thanks akbooer.
I am getting a difference of 3 hours from expected time. So anopther division by 60 may not give the intended result as well.
I am a new so excuse my silly questions. 1. How do I convert the result into minutes as I want to trigger another action after 15 minutes following sunrise ? 2. when I add “print (pretty(t))” , what does really ‘pretty’ do or mean ?
Then your latitude and longitude are probably set wrongly, or nearby town.
1. How do I convert the result into minutes as I want to trigger another action after 15 minutes following sunrise ?
I wouldn’t do it that way… Simply set a timer to trigger a scene 15 minutes after sunrise. There’s syntax to do that.
2. when I add "print (pretty(t))" , what does really 'pretty' do or mean ?
Ignore that line, it was simply what I used to print the content of the table returned by os.date().
If you want to start using Lua you’ll need to read the book Programming in Lua
That is a good point. I, probably, overlooked. However, it has bought out another issue. I dont if any one from Ver will clarify.
I have two controllers at two different locations under one log in credentials. When IO change location details of one the other just follows. To keep the controllers separate, Vera wont permit me to have two accounts on one email. Any solution ? Am I clear enough ?