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

Can someone help me understand this code? Block scene.


rajp

Question

Hi all

 

I have a simple scene that says that if the night variable is set and if the Porch and Driveway lights are off and if front door is breached, it should switch the Porch and Driveway light on for 300 seconds. I have put the 300 as a value in the device.. however, when I opened the door in the morning, the lights didn't switch on at 6AM but when I returned home at 7AM, they were on. That would mean that what I thought was a setting to keep the lights on for 300 seconds is not really that but is a delay of 300 seconds.

 

Am I correct in understanding this ?? Haven't touched the scenes for a while and need to get back into this. I have attached a screenshot of the scene and also the LUA code it generated. How can I change the code to keep the lights on for 300 seconds and then switch off?

 

Thanks in advance.

Please login or register to see this attachment.

Please login or register to see this attachment.

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0
  • Inquirer
  • Ahh found the answer.. I had that the wrong way round..  changed the code to this and it should do it..

     

    --[[
    %% autostart
    %% properties
    22 value
    74 value
    %% weather
    %% events
    %% globals
    Night
    --]]
    if (fibaro:countScenes()>1) then
      fibaro:debug('Kill second scene!');
      fibaro:abort();
    end
    local startSource = fibaro:getSourceTrigger();
    if (
     ( tonumber(fibaro:getGlobalValue("Night")) == tonumber("1") )
    and
     ( tonumber(fibaro:getValue(22, "value")) == 0 )
    and
     ( tonumber(fibaro:getValue(74, "value")) > 0 )
    or
    startSource["type"] == "other"
    )
    then
     fibaro:call(22, "turnOn");
     fibaro:call(34, "turnOn");
     fibaro:debug('Turn On');
     fibaro:debug('Wait Now');
     setTimeout(function()
           fibaro:call(22, "turnOff");
      fibaro:call(34, "turnOff");
      fibaro:debug('Turn Off');
     end, 300000)
    end
    Link to comment
    Share on other sites

    • 0

    The topic has been moved from "

    Please login or register to see this link.

    " to "

    Please login or register to see this link.

    ".

     

    Temat został przeniesiony z "

    Please login or register to see this link.

    " do "

    Please login or register to see this link.

    ".

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • thank you for moving this to the right place.

    Link to comment
    Share on other sites

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