Jump to content

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


  • 0

Timer scene in LUA


Question

Posted

Is it possible in LUA to keep a a light on between eg. 7AM-10:30PM?

Do i need to set a trigger at 7AM and then sleep for 15,5h and then turn it off? Other solution?

Like this?

local currentTime = tonumber(os.date("%H%M"));

local wakeUp = tonumber(string.format("%02d%02d", "07", "00"));

local goSleep = tonumber(string.format("%02d%02d", "22", "30"));

if currentTime = wakeUp then

fibaro:call(7, "turnOn");

elseif time = goSleep then

fibaro:call(7, "turnOff");

end

5 answers to this question

Recommended Posts

  • 0
Posted

Please login or register to see this link.

Or there are a few other ways including one I posted a while back that will schedule all of yor timed events

  • 0
Posted

Please login or register to see this link.

Or there are a few other ways including one I posted a while back that will schedule all of yor timed events

Haven't tried this code so there could be some bugs but the intention is a bare bone scheduler (more flexible time formats would be nice). I would recommend GEA or robmac's scheduler for real use. The question is also if setTimeout will drift over longer time spans...?

Please login or register to see this code.

Btw, it seems like setTimeout returns a reference that can be used by removeTimeout to cancel the call-back...

  • 0
Posted
Btw, it seems like setTimeout returns a reference that can be used by removeTimeout to cancel the call-back...
YES

Please login or register to see this code.

  • 0
Posted

ahh the kill function on that timeout what exactly what I needed

Please login or register to see this image.

/emoticons/default_biggrin.png" alt=":D" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" /> (for something totally unrelated to this topic).

  • 0
Posted
Btw, it seems like setTimeout returns a reference that can be used by removeTimeout to cancel the call-back...
YES

Please login or register to see this code.

yes, it was named clearTimeout not 'remove'...

Please login or register to see this image.

/emoticons/default_icon_smile.gif" alt=":-)" />

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...