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

[SOLVED]Lights on/off time stamp


Question

Posted (edited)

Hello, i want to make program to turn on/off lights between time which i setup. For exapmle, between 12-16 turn on between 16-12 turn off. Could u help me. HC2

Edited by Adios

11 answers to this question

Recommended Posts

  • 0
Posted

In block or LUA?

 

  • 0
  • Inquirer
  • Posted

    In block and in lua i wanna learn it

    • 0
    Posted

    Please login or register to see this link.

     

    Please login or register to see this link.

     

    And finally 

    Please login or register to see this link.

    • 0
  • Inquirer
  • Posted

    Ok. Now i ve got motion sensor. I wanna light on when move is detected but only between 16-20. When move is detected before 16 or after 20 lights have to be off. I cant do it with yours examples. 

    • 0
    Posted (edited)

    Here is a simple scene for that: 

    Please change motionID and lightID (marked red) to your real device IDs 

     

    --[[
    %% properties

    motionID value
    %% globals
    --]]

    local devID = tonumber(fibaro:getSourceTrigger()["deviceID"]) 

    local cTime = os.date("*t")

     

    if (cTime.hour > 15 and cTime.hour < 21) then

         if ( tonumber(fibaro:getValue(devID,  "value")) > 0 ) then

              fibaro:call(lightID,  "turnOn")

        end

    else

       fibaro:call(lightID,  "turnOff")

    end

     

     

    Works as requested between 16-20  not tested. 

    BTW what about when the motion sensor goes back to safe, do you need to turn off the light?

    Edited by cag014
    • 0
  • Inquirer
  • Posted

    Thanks today i wlll check. Yes when motion sensor goes to 0 berweetn 16-21 lights off

    • 0
  • Inquirer
  • Posted (edited)

    I did something like this

     

    local cTime = os.date("*t")

     

    if (((cTime.hour >= 15) and (cTime.hour < 23)) or (cTime.hour == 23) or ((cTime.hour >= 0) and (cTime.hour < 8))) and (tonumber(fibaro:getValue(5, "value")) > 0 ) then
      fibaro:call(9,  "turnOn")
      print ("wlaczono")
      else
      fibaro:call(9,  "turnOff")
       print ("wylaczono")

    end

    Edited by Adios
    • 0
    Posted (edited)

    looks OK, but as we all know the best SW engineer, is the lazy engineer who writes as minimum code as possible to provide better understanding of the code from the first glance 

    So may I suggest follow line (does the same):

     if ( (cTime.hour > 14  or  cTime.hour < 8 ) and

    .....

    ....

    but either way it should work.

    Edited by cag014
    • 0
  • Inquirer
  • Posted

    Thank you. One more question... How can i make somethimg like that... Move sensor is ON, light is ON, when move sensore is OFF then wait 10 sec and light OFF. For my example which is above.

    • 0
    Posted
    On 12/15/2017 at 9:25 PM, Adios said:

    Thank you. One more question... How can i make somethimg like that... Move sensor is ON, light is ON, when move sensore is OFF then wait 10 sec and light OFF. For my example which is above.

     

     

    • 0
    Posted
    On 12/15/2017 at 9:25 PM, Adios said:

    Thank you. One more question... How can i make somethimg like that... Move sensor is ON, light is ON, when move sensore is OFF then wait 10 sec and light OFF. For my example which is above.

     

    Sorry about late reply, but here is the example for 10 seconds delay.

    It might be that the scene will have few instances (especially if you'll increase the 10 seconds delay to bigger value), but it should work correctly.

    In general the idea is to wait 10 seconds then  if the sensor still off (safe) and last change of the sensor happened more then 10 seconds ago to turn off the light.

     

    if (((cTime.hour >= 15) and (cTime.hour < 23)) or (cTime.hour == 23) or ((cTime.hour >= 0) and (cTime.hour < 8))) and (tonumber(fibaro:getValue(5, "value")) > 0 ) then
      fibaro:call(9,  "turnOn")
      print ("wlaczono")
      else

      fibaro:sleep(10000) -- sleep for 10 sec.

      if (tonumber(fibaro:getValue(5, "value")) == 0 and os.time() - fibaro:getModificationTime(5, "value") >10 ) then
           fibaro:call(9,  "turnOff")
           print ("wylaczono")

       end

    end

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