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

Question
RonS 0
I am building this for my own educational purpose and got stuck thinking I was almost there.
I build a table that holds my devices and their id’s. The table tutorial helped a great deal.
Please login or register to see this image.
/uploads/monthly_2021_11/image.png.6d663f504fed1c1881de45b42d665435.png" />I can traverse through the table. I store the table via an encode into a GlobalVar. Which seem to succeed.
Next I do a Get on the GlobalVar which is successful (status 200), I get a table when I extract the response (response.value).
But when I traverse with the “in pairs” construct I receive an error. Apparently, the response is now a string.
function getDeviceTable()
response, status = api.get("/globalVariables/DeviceTable/",
{
name="DeviceTable"
});
fibaro:debug(status);
fibaro:debug(response);
fibaro:debug(response.value);
local table = response.value;
--local jtable = json:decode(table);
--fibaro:debug(jtable);
for k,v in pairs(table) do
print("first level key: " ..k..", first level value: ".. tostring(v))
--for k2,v2 in pairs(v) do -- This works because we KNOW v is a table.
--print(" second level key: " ..k2..", second level value: "..v2)
--end;
end;
If I json:decode response.value the outcome is the same.
So, how do I get a response from the GlobalVar that I can work with?
Thanks for your help.
5 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.