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

LUA - Iterate through global variables


Question

Posted

Is it possible to iterate through all global variables? I have a number of "timer-variables" in which I set a time in seconds, then a scene count downs each variable each second and scenes triggers when they reach 0.

For instance, if there is motion in living room, set timer to 300, if there is motion again, reset to 300. After 300s turn off lamp.

Right now I have a scene with code duplicated for each variable.

Count down var 1

Count down var 2

..

I would like to make this more generic, like foreach(variable in getVariables("timer*")) or something like that. That way I don't need to modifiy my scene for each new variable.

Is this possible?

4 answers to this question

Recommended Posts

  • 0
Posted
For instance, if there is motion in living room, set timer to 300, if there is motion again, reset to 300. After 300s turn off lamp.

For each lamp you can make 2 Scenes. One to switch on and one to switch off. This can be done by easy use of blocks.

Why you need global variables to do that?

  • 0
  • Inquirer
  • Posted

    I don't want a lot of scenes. I have 6 timers for various implementations.

    The question was not about how to make the scenes, but on how to iterate variables.

    • 0
    Posted

    That sounds like rafal.m:s lights automation.

    Works like a sharm, only one virtual device is needed.

    Please login or register to see this link.

    • 0
    Posted
    The question was not about how to make the scenes, but on how to iterate variables.

    Excuse me just for trying to help...

    Please login or register to see this image.

    /emoticons/default_icon_curve.gif" alt=":-/" />

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