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


Ca we use QA variable as table in code


Neo Andersson

Recommended Posts

Hi

 

I am trying to use QA variable as a table in my code, but it doesnt seem to work.

User gives the QA variable in format like 100,101,102 and i want to loop through these numbers.

But foreach loop doesnt work as it needs a table to loop through.

The solutions that i found on the net deosnt work either.

I tried this function:

 

Quote

Please login or register to see this code.

 

but doesnt work.

Link to comment
Share on other sites

local c = "100,101,102"

Alt1.

Please login or register to see this code.

Alt2.

Please login or register to see this code.

Alt3.

Please login or register to see this code.

 

Link to comment
Share on other sites

  • Topic Author
  • Please login or register to see this code.

    However i am getting this error

     bad argument #1 to 'for iterator' (table expected, got nil)

    Link to comment
    Share on other sites

    self.turn_on_device_table or self.turn_off_device_table ?

    Link to comment
    Share on other sites

  • Topic Author
  • its just a typo,  I was copy/pasting a part of the code..so its correctly set in the code, but it doesnt work.

     

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

  • Topic Author
  • I have found a typo in Variables, and after the fix there's error when calling the off part, and there's no error when calling the on part.

    Attaching the variables picture

     

    Please login or register to see this attachment.

     

    Here is the entire code..

    Please login or register to see this code.

     

    Edited by Neo Andersson
    Link to comment
    Share on other sites

    The user can have entered something that isn't a list in the quickAppVariable. 

    You can catch that  with

    Please login or register to see this 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
    Reply to this topic...

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