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
Jay Ess 6
HC3
I have a small table which i store in a global varibale, this is the table.
--Construct Music Table
jsonMusic = {
Song = {
S1 = "SholomAleichem",
S2 = "KohEchsoif",
S3 = "JoyShabbos",
S4 = "ItsTimeToSayGoodShabbos",
S5 = "Hamavdil",
},
Length = {
S1 = 401, --6.41,
S2 = 483, --8.03,
S3 = 256, --4.16,
S4 = 267, --4.27,
S5 = 332, --5.32
}
}
--END OF MUSIC TABLE
fibaro.setGlobalVariable("jMusicTable", json.encode(jsonMusic))
from a scene i can reference the table and get the values i need.
eg. local jMT = json.decode(fibaro.getGlobalVariable("jMusicTable"))
and then songName = MusicPathPi.. jMT.Song.S1 ..MusicPathEnd
which get me the song i want to play.
however if i put this same code in a qa i get the following error:
/usr/share/lua/5.3/json/util.lua:55: bad argument #1 to 'for iterator' (table expected, got number)
this is the lines in my qa.
local jMT = json.decode(fibaro.getGlobalVariable("jMusicTable"))
local songName = jMT.Song.S1
print(songName)
What am I doing wrong?
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.