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

Kill previous instances of a scene


ivalentinov

Question

Hi guys, fairly new to the forums, so excuse me if i ask stupid things

Please login or register to see this image.

/emoticons/default_icon_smile.gif" alt=":-)" />

Currently i am testing the system and loving it so far, but cannot get past this:

I have a motion detector (the fibaro motion detector) and i want to turn off a plug in the room after 30 minutes of no movement. I can easily do this with the scene block-builder, but at moments i can have more than 10 instances of the same scene sleeping. I am sure that with my simple test setup this is not a problem for the HC hardware but wonder what will happen if i have 20+ scenes each with timeouts.

As coding is no problem, i switched to lua and tried to optimize the scene and have only one instance of it, however it turns out that what i can do is either abort the newest instance or kill them all, when in fact what i want is to kill the older instance and keep the newly triggered.

If you have something to advise me that will be great and if this is not possible at the moment, maybe someone from Fibaro can tell us if and when this will be possible.

If this was already discussed - i apologize in advance.

Link to comment
Share on other sites

11 answers to this question

Recommended Posts

  • 0
  • Inquirer
  • From my experience, 20 scenes should not be a big problem. Of course, it all depends on their complexity.

    Thanks for the reply - so there is no way to do that?

    Link to comment
    Share on other sites

    • 0

    Create a globalvalue with the name endtimeplug

    Change 123 to the ID of you sensor (it is in the code 2 times) and 120 to the ID of your plug (it is in the code 1 time).

    Please login or register to see this code.

    It will update endtimeplug if there is any movement and is adding 30 minutes to the current time and then kills the process, if no movement is noticed it is counting down.

    It can be done in several ways, but this one is working fine for me.

    Enjoy!

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Thanks boerremk that's a really nice solution.

    Having the possibility to kill everything but the current scene instance would be easier and more efficient, but i'll play around with your code :->

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Hey dawiinci thanx for your response, but this actually aborts the current scene instance and not the previous.

    I just wanted to understand if that is possible, it appears it isn't, and if i am understanding the lack of feedback from Fibaro employees, they will not implement it

    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" />

    Thanx to all though

    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

    • 0

    Why not just make everything inside the script? I have something similar working in my setup; when yo enter a room, a scene which is constantly active will set a local variable to i.e. 120 and then use a sleep(1000), ecah time it loops after sleeping, it will subtract one from the local variable, if no movement is detected before the variable reaches 0 it will slowly dim the light. If movement is detected, the local variable is reset to 120. Same is ofcourse true if motion is detected during dimming.

    This avoids the need for a global variable for each individual dimmer and saves a bit of memory. If the scene is set to autostart and has the countscenes/abort feature, you'll never have multiple instances of the same scene running simultaneously.

    Link to comment
    Share on other sites

    • 0
    Why not just make everything inside the script? I have something similar working in my setup; when yo enter a room, a scene which is constantly active will set a local variable to i.e. 120 and then use a sleep(1000), ecah time it loops after sleeping, it will subtract one from the local variable, if no movement is detected before the variable reaches 0 it will slowly dim the light. If movement is detected, the local variable is reset to 120. Same is ofcourse true if motion is detected during dimming.

    This avoids the need for a global variable for each individual dimmer and saves a bit of memory. If the scene is set to autostart and has the countscenes/abort feature, you'll never have multiple instances of the same scene running simultaneously.

    Would you mind sharing this script? I am new to HC2 and Fibaro and have purchased the HC2 with AEOTECH Multisensors. I have installed the Sensor in the bathroom and would like it to control the light when it detects presence and at the same time switch the extractor fan on if the humidity level is above certain percent. Then switch off the light when no movement is detected. I can't work out how to build this.

    Thanks

    Raj

    Link to comment
    Share on other sites

    • 0

    Sure... I just need to get home. I'm stuck on an oil field in the middle of the north sea until tomorrow at the earliest, but I'll upload once I get home and have the time.

    [ Added: 2014-04-30, 14:58 ]

    As promised, the scene I use, I've included comments for easier integration:

    Please login or register to see this code.

    Link to comment
    Share on other sites

    • 0

    There is an error in above code! All instances of "dimon" should be changed to "ondim", I've adjusted above code to be correct.

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