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
i have a global variable called sonosPlayer which stores the ip address of the sonos i want to play music to, the ip addresses are stored in the variable as a enum.
i have made a qa with a button which toggles through the different sonos ip addresses.
this is my function;
function QuickApp:ToggleMusicPlayer()
local gv = api.get("/globalVariables/sonosPlayer")
local MusicPlayer = fibaro.getGlobalVariable(self.gloVarNameMusicP)
counter = 0
for k,v in pairs(gv.enumValues) do counter = counter +1 end
for k,v in pairs(gv.enumValues) do
if MusicPlayer == v then
if k < counter then
newK = k + 1
print(newK)
else
newK = 1
end
-- print (k,v)
end
end
for k,v in pairs(gv.enumValues) do
if k == newK then
print(v)
fibaro.setGlobalVariable(self.gloVarNameMusicP,v)
end
end
self:MusicPlayer()
end
while it works i am cycling 3 times through the table and i wanted to know if there was a more effcient way to change the ip address without having to cycle so many times through the table.
6 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.