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

"while true do" mystery


AutoFrank

Question

CANCEL THIS - I SOLVED IT WITH A VD USING THE MAIN LOOP

 

 

 

Hi,

This is prob not a huge mystery and something basic I'm missing.

If I remove the While true do loop from the code below and execute it manually it works okay but once I add the while loop to get it check all the time the scene doesn't run

 

Could somebody take a look and tell me where I'm being stupid

 

Thanks

-F

Please login or register to see this code.

Edited by autofrank
Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

An "infinite while" does not work with HTTPClient and also not with setTimeout. Never. Those functions *schedule a task*. That task runs, *after* main code ends. So when main never ends, because you keep code alive in an infinite loop, the tasks never start! How can you keep a loop going with those special functions? In the "success" part (and even better: also in the "error part"!), you can do whatever you like, including... calling *yourself* (recursion) or any other function. If you don't do that, the "success" part simply ends and everything stops. I can explain that in a better way, but not right know. Fixing the code takes a while, btw. Yell if you need more help.

Link to comment
Share on other sites

  • 0
  • Inquirer
  • An "infinite while" does not work with HTTPClient and also not with setTimeout. Never. Those functions *schedule a task*. That task runs, *after* main code ends. So when main never ends, because you keep code alive in an infinite loop, the tasks never start! How can you keep a loop going with those special functions? In the "success" part (and even better: also in the "error part"!), you can do whatever you like, including... calling *yourself* (recursion) or any other function. If you don't do that, the "success" part simply ends and everything stops. I can explain that in a better way, but not right know. Fixing the code takes a while, btw. Yell if you need more help.

     

    Thanks Peter -

    that makes sense and actually answers another issue I was having.

     

    I solved the issue by creating a virtual device with the code running in the main loop and labels to display the state

     

    I only need to keep track of 3 zones ( as they are unamplified zones that leverage some power amps)

    For these three I write the state to a global variable and then have a listening scene the triggers on a global variable change

     

    the VD code is below. (the dining room zone is an example of where I write to the global variable as the state changes)

     

    -Frank

    Please login or register to see this code.

    Link to comment
    Share on other sites

    • 0

    i have another situation...

    I'm go away from home and set arm.

    one of my scrip doesn't have "Do not allow alarm to stop scene while alarm is running" flag.

    so: 

    [DEBUG] raspberry Pi:12:40:19: 19°С/22°С 32% 760mm-Hg
    [DEBUG] raspberry Pi:12:41:19: 19°С/22°С 32% 760mm-Hg
    as we can see script has been stopped.
    after when I disarm home I hoped what FHC continue my scrip again... but It was my mistake...
    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...