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

Setting time variables


Question

Posted

Hi

 

I am trying to set up three time variables. One starts at sunrise. The other starts at sunset. I also want a period between sunset and sunrise (when we are asleep) to be set.

 

Will the time variable setting below work?  Will this variable start at 11:00pm (and therefore turnoff the sunset time variable) and stop when the sunrise variable starts?

 

Please login or register to see this image.

/monthly_2018_12/139780068_ScreenShot2018-12-30at10_27_05PM.png.7a9494e0506807d966f35fe95cd41d25.png" alt="139780068_ScreenShot2018-12-30at10_27_05PM.png.7a9494e0506807d966f35fe95cd41d25.png" />

4 answers to this question

Recommended Posts

  • 0
Posted (edited)

No this doesn't work look into the next link, maybe this will help you. 

Ore perhaps you can the next scene. 

--[[
%% autostart
%% properties
%% globals
--]]

local sourceTrigger = fibaro:getSourceTrigger()
 
if (sourceTrigger["type"] == "autostart") then
 
   while true do
 

   local currentDate = os.date("*t")
   local TimeNow = (string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min))
   local sunrise = fibaro:getValue(1, "sunriseHour")
   local sunset = fibaro:getValue(1, "sunsetHour")
   local Bedtime = "23:00"
 
   local startSource = fibaro:getSourceTrigger()
 
   fibaro:debug("Time no: "..TimeNow)
   fibaro:debug("Sunrise: "..sunrise)
   fibaro:debug("Sunset: "..sunset)
   fibaro:debug("Bedtime: "..Bedtime)
      
  if (TimeNow >= Bedtime and TimeNow >= sunrise) then
      fibaro:setGlobal("lightMode","sleep")
      fibaro:debug("Sleep")
   
  elseif ((TimeNow >= sunrise) and (TimeNow <= sunset)) then
      fibaro:setGlobal("lightMode","day")
      fibaro:debug("day")
    
  elseif ((TimeNow >= sunset) and (TimeNow <= Bedtime)) then
      fibaro:setGlobal("lightMode","evening")
      fibaro:debug("evening")
    end
    
   fibaro:sleep(5*60*1000)
  end
end

Edited by Reinhold
  • Thanks 1
  • 0
  • Inquirer
  • Posted

    Thanks Reinhold

    I will try this. Do I need to have for predefined variables? Day, evening, sleep, and bedtime?

    • 0
  • Inquirer
  • Posted

    Thanks Reinhold. It seems to be working. Will test it over the next few days.

    • 0
    Posted

    If there are any problems i try to help. 

    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...