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

"one shot" Lua in Virtual Device


Question

Posted

I have a virtual device which pretty much is just a few buttons, and labels.

Each button toggles a global var 1/0.

Each label just shows the value of a global var.

Now, since I have read a few posts which seem to indicate that the main loop may get stuck and/or simply behave erratically, i wonder if there is any way for me to avoid it.

I would like to fire off lua when the device is opened in the client to be able to update all labels. But it does not need to auto-refresh (since i can update the labels when a button is clicked).

But the only way i see to do this is to put the code to update labels in main loop?

6 answers to this question

Recommended Posts

  • 0
Posted

"Best" practice is to put the update code in a separate button and then "hit" the button from main loop. This has been known to work for others, including me, instead of using the main loop straight up.

  • 0
  • Inquirer
  • Posted
    "Best" practice is to put the update code in a separate button and then "hit" the button from main loop. This has been known to work for others, including me, instead of using the main loop straight up.

    Unfortunately that leads to an unnessecary button in the device. Which bugs me.

    • 0
    Posted

    You could use a separate device for the looping to avoid that.

    • 0
  • Inquirer
  • Posted
    You could use a separate device for the looping to avoid that.

    Uhm.. okay.. so a VD can change properties of another VD? I actually did not know that. I just assume with all the sandboxing that... well you see what I mean

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

    • 0
    Posted

    I nice feature would be to be able to hide buttons and labels. That way you could do what you want but have them not to show up in the GUI's.

    • 0
  • Inquirer
  • Posted
    I nice feature would be to be able to hide buttons and labels. That way you could do what you want but have them not to show up in the GUI's.

    Oh, I second that

    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" /> Maybe even "Hide for all users except admin".

    Anyway, i think i will do it a bit differently.

    The scene is a "trigger on motion breach" kind of thing. So, the first statement is pretty much a "if sesor value == 1 then..."

    I figured that if i put code outside that statement to update the labels, and then set the scene to run on HC2 startup i would get what i want. Lables would be initialized properly, and then the buttons would update on press. So, this way i should be able to avoid the main loop all together.

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