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

get reference to global array


Penny_Wise

Question

Dear all,

 

maybe this is a rookie-question, nevertheless I am struggeling finding a solution:

I have stored several device ids within a global variable. Now I would like to get a reference to that very variable, not the value. But the function getGlobalVariable delivers the current selected value only. How can I get the reference to the array itself?

 

Thank you so much for you help!!

 

Does not work:

fibaro.getGlobalVariable("VARNAME");
Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Check API for that: /api/globalVariables/ to retrieve the enumValues

 

For example:

 

Name of a global variable: "InternetStatus"

 

Please login or register to see this code.

 

return

 

Please login or register to see this code.

 

Link to comment
Share on other sites

  • 0
  • Inquirer
  • Thank you Krikroff, :-) 

    but how can I include/reference the enumValues within LUA?

    getGlobalVariable  gets me the selected value, not the reference to the enum.

     

    The intention is to iterate the enum values.

    This is, what I've got so far (line marked yellow most likely does operate as expected). Any suggestions?

    Sorry for bothering you, just taking my first small steps with fibaro lua ...

     

     

    -------------------------------------------------------------------------
    -------------------------------------------------------------------------
    fibaro.debug("Scene52""starting scene alarm notifications ...");
    -------------------------------------------------------------------------
    -------------------------------------------------------------------------

     

    localPushNotifications = fibaro.getGlobalVariable("PUSH_NOTIFICATIONS")); 

    localPushNotifications = {1, 2};
     
    -- user 3 gets all the emails as single point of contact
    fibaro.call(3"sendEmail""Alarm triggered!", fibaro.getGlobalVariable("ALARM_TEXT")); 
     
    -- send push notifications to each of the users
    fibaro.debug("Scene52: sending to the following ids: ", localPushNotifications);
    for idCount = 1, #localPushNotifications do
      fibaro.call(localPushNotifications[idCount], "sendPush", fibaro.getGlobalVariable("ALARM_TEXT")); 
    end
     
    -------------------------------------------------------------------------
    -------------------------------------------------------------------------
    fibaro.debug("Scene52""scene alarm notifications finished ...");
    -------------------------------------------------------------------------
    -------------------------------------------------------------------------
     
    Link to comment
    Share on other sites

    • 0

    In my previous exemple:

     

    For example:

     

    Name of a global variable: "InternetStatus"

    Please login or register to see this code.

    return

     

    { "name": "InternetStatus", "value": "Connected", "readOnly": false, "isEnum": true, "enumValues": [ "Connected", "Disconnected" ], "created": 1586471912, "modified": 1586471912 }

     

     to iterate the enum values in lua

     

    Please login or register to see this code.

    print

     

    1 Connected

    2 Disconnected

    Edited by Krikroff
    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...