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

Best Way to break loop after another button press?


GlennNZ

Question

Hi

Have been struggling to find the best way to break out of a loop with another button press in timely fashion.

eg.

Trigger - device - door sensor toggle

Sets global variable timer

Turns Devices On

While do loop until timer equals current time (sleep 5 or 10 secs)

When time up

Turns Devices Off

End of Scene

Example from Richo - whichs works great on a few other scenes.

Please login or register to see this code.

Works well, count downs and turns off.

However I wish to turn these devices off if there is another button press on the same deviceId.

Options

- Within the loop Can check the deviceID status every 5 seconds and then turn off if triggered again - Quite a delay to turning off.

- Can check if scene running (fibaro:Countscenes) and if triggered again killscenes ? (would seem a bit 'aggressive') and countscene based triggers seem to run without clear trigger to me occasionally

- Is there an easier better way?

Thanks

Glenn

[/code]

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Please login or register to see this code.

Will stop a loop dead in its tracks. So just create an if-condition which monitors whichever variable you want to trigger the break and then add

Please login or register to see this code.

To break out of the loop. Do however note that it will only break out of the current loop. The rest of the code in the scene will still execute.

If you want to halt the current instance of a scene, you can use the function

Please login or register to see this code.

Instead. This will kill the current instance of the scene.

Link to comment
Share on other sites

  • 0
  • Inquirer
  • Thanks

    Yep - could put a check in the while do loop and break and abort if value changed - but this would come with a 10sec delay as the loop stands. Even if dropped sleep to 1 sec still likely to lead to multiple button presses when no (immediate) response.

    Or could extend count scenes abort and if countscenes>1 AND value changed then turn off and kill scene (killing the other running scene while loop whole scene) - this would seem a bit aggressive but maybe/perhaps the best way

    Still can't feel that I'm missing something easier though?

    eg code as below modification of above - turns all outdoor lights on when frontdoor opens and count downs and all off. If frontdoor light swtiched off meanwhile - aborts loop and turns the other lights off as well.

    Still doesn't help with this case where need much quicker response as button press event.

    Please login or register to see this code.

    Glenn[/code]

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