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


Scene to run only once


OLIVARE
 Share

Recommended Posts

I would like to setup a scene that is triggered with motion sensor.   But it should only run the scene between 8 am and 9 am an only once per day.   I have it work for the entire process, but it runs every time the motion is tripped.  Two things I am looking to solve.


1)   How can I have it only run between 8 am and 9 am
2)   Only run once per day?


Basically want motion sensor to open blinds in living area when i first walk in to living area in the morning.

 

Thanks

Kyle

Link to comment
Share on other sites

  • Topic Author
  • Right i have the run only between  8 am and 9 am part now with variables active/inactive, just need the run only once part.

    Link to comment
    Share on other sites

    1. Create a Global Variable with the name Blinds.

    2. Use this code (change the ID of the motionsensor and ID of the blinds:

    Please login or register to see this code.

    This should do the trick.

    Link to comment
    Share on other sites

  • Topic Author
  • Thank you very much 

    Please login or register to see this link.

     for the reply!

     

    Ok i have created the variable called Blinds and set the value to 0 (standard).

     

    I have then created a Lua Scene and added your code to it and changed the two ID as shown above the xxxx but its not triggering the blind to even open.

     

    Any idea what it could be? 

     

    Thanks in advance!

     

    Kyle

    Link to comment
    Share on other sites

    Can you post your scene?

     

    Try this (more logging):

    Please login or register to see this code.

    If triggered it says "Motionsensor trigger", if the if clause  passes it says "Blinds open", otherwise "Something else".

    Link to comment
    Share on other sites

  • Topic Author
  • --[[

    %% properties

    150 value

    %% globals

    --]]

     

    startTime = "08:00"

    stopTime = "11:00"

    currentDate = os.date("%x");

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

     

    fibaro:debug("Motionsensor trigger")

     

    -- check script instance count in memory 

    if (tonumber(fibaro:countScenes()) > 1) then 

      log("Script already running.");

      fibaro:abort(); 

    end

     

    local sourceTrigger = fibaro:getSourceTrigger();

    if sourceTrigger["type"] == "property" and fibaro:getGlobalValue("Blinds") ~= currentDate and currentTime >= startTime and currentTime < stopTime

    then

      fibaro:call(221, "open");

      fibaro:setGlobal("Blinds", currentDate)

      fibaro:debug("Blinds open")

      else

      fibaro:debug("Something else")

    end

    Link to comment
    Share on other sites

  • Topic Author
  • [DEBUG] 10:49:53: Motionsensor trigger
    [DEBUG] 10:49:53: Something else
    [DEBUG] 10:50:24: Motionsensor trigger
    [DEBUG] 10:50:24: Something else

    Link to comment
    Share on other sites

    But it is not working, should say once "Blinds open" (i see that you adjusted the time till 11:00, so that it should met)???

     

    If it is not working could you change

    if sourceTrigger["type"] == "property" and fibaro:getGlobalValue("Blinds") ~= currentDate and currentTime >= startTime and currentTime < stopTime

    to

    if fibaro:getGlobalValue("Blinds") ~= currentDate and currentTime >= startTime and currentTime < stopTime

    Please login or register to see this code.

    Link to comment
    Share on other sites

  • Topic Author
  • Yes it's not working, yes adjusted time to test now

    Please login or register to see this image.

    /emoticons/default_smile.png" alt=":)" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" />

     

    Ok let me make changes one second.

     

    kyle

    Link to comment
    Share on other sites

  • Topic Author
  • Ok made changes but still "something else"

     

    Please login or register to see this image.

    /emoticons/default_icon_cry.gif" alt=":cry:" />

     

    [DEBUG] 10:59:16: Motionsensor trigger
    [DEBUG] 10:59:16: Something else
    [DEBUG] 10:59:46: Motionsensor trigger
    [DEBUG] 10:59:46: Something else

     
     
    Again massive thank you for your help
    Link to comment
    Share on other sites

    Extra debugging

    Please login or register to see this code.

    Link to comment
    Share on other sites

  • Topic Author
  • [DEBUG] 11:08:39: Motionsensor trigger
    [DEBUG] 11:08:39: 07/23/16
    [DEBUG] 11:08:39: 11:08
    [DEBUG] 11:08:39: 07/23/16
    [DEBUG] 11:08:39: Something else

    Link to comment
    Share on other sites

  • Topic Author
  • The variable is showing the following now instead of a "0"

     

    Please login or register to see this image.

    Link to comment
    Share on other sites

    Should put it to 0 again, it already met the statement once and it will only run once (a day)

    Please login or register to see this image.

    /emoticons/default_smile.png" alt=":)" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" />

    Link to comment
    Share on other sites

  • Topic Author
  • Ok changed to "0".

     

    Debugging now showing the following:

     

    [DEBUG] 11:16:36: Motionsensor trigger
    [DEBUG] 11:16:36: 0
    [DEBUG] 11:16:36: 11:16
    [DEBUG] 11:16:36: 07/23/16
    [DEBUG] 11:16:36: Something else

    Link to comment
    Share on other sites

  • Topic Author
  • Please login or register to see this image.

     

    No i did not change it.....

     

    It now works!

     

    Gracias Gracias Gracias  :-D

    Link to comment
    Share on other sites

    Great!

     

    You can remove the extra lines of debugging if you want.

    Link to comment
    Share on other sites

  • Topic Author
  • Will do, again thank you very much for your help with this.

     

    Much appreciated.

     

    Kyle

    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
    Reply to this topic...

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