Welcome to Smart Home Forum by FIBARO
Dear Guest,
as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.
As a member you can:
- Start new topics and reply to others
- Follow topics and users to get email updates
- Get your own profile page and make new friends
- Send personal messages
- ... and learn a lot about our system!
Regards,
Smart Home Forum by FIBARO Team

Question
Jay Ess 6
Hi
I am trying to add 5 hours to sunset and then use that time as an off time for some lights, am using the following code:
local fmt = string.format
function str2sec(str) local h,m,s=str:match("^(%d%d):(%d%d):?(%d*)") return 3600*h+60*m+(s~="" and s or 0) end
function sec2str(sec) return fmt("%02d:%02d%s",math.floor(sec/3600),math.floor((sec % 3600)/60),sec % 60 > 0 and fmt(":%02d",sec%60) or "") end
local SunSetTimeVariable = fibaro.getGlobalVariable("Sunset") --this is a stored value of sunset time updated every day.
local LightOffTime = sec2str(str2sec(SunSetTimeVariable)+(300*60))
when I debug this I get:
sunset 20:41
LightOffTime 25:41
This seems to be an error as there is no such time as 25 hours?
Can someone please help me where I have gone wrong please?
6 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.