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

Scene for turning light off after specified time


tampiss
 Share

Question

Hi guys,

I would please need help with my scene. My aim is to turn automatically light off after specific time.

 

This works until this happens:

1) user turns the light on
2) user turns the light off before 10 minutes
3) another user comes and turns the light on
4) the previous scene is still running and turns the light off when it finished 10 minutes

 

What I would like is:
1) turn manually light on and start counting 10 minutes
2) if the light was not turned off manually within 10 minutes, turn the light off
3) if the light was turned off manually within 10 minutes and another user turned the light on again (within the first run), start new sleep for 10 minutes and so on


Here is what I have:

--[[
%% properties
45 value
%% events
%% globals
--]]

 

if (fibaro:countScenes() > 1) then fibaro:abort() end;


local myState = tonumber(fibaro:getValue(45, "value"))

if (myState > 0) then
  fibaro:sleep(10*60*1000);
  fibaro:call(45, "turnOff");
end

 

Thank you for any help,
tampiss

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0
  • Inquirer
  • Testing this one right now.

     

    --[[
    %% properties
    48 value
    %% events
    %% globals
    --]]

     

    local myID = 48
    local mySceneID = 23
    local myTime = 15*60*1000
    local myState = tonumber(fibaro:getValue(myID, "value"))
                   
    function lightOff()  
      fibaro:call(myID, "turnOff")
    end

     

    if (myState == 1) then
      setTimeout(lightOff, myTime)
    else
      fibaro:killScenes(mySceneID)  
    end

     

    edit: seems to work though

    Edited by tampiss
    Seems to work.
    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.

     Share

    ×
    ×
    • Create New...