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
konbaasiang 0
Howdy! Quick question, hopefully:
In order to have a "Main" button in a VD be a toggle switch, and to reflect the state, I've had to use a global variable as well as manual icon selection, as follows:
Button 1 (Main) - this is the toggle switch
local curmode=fibaro:getGlobalValue('innerwall_mode');
curmode = (curmode + 1) % 4
fibaro:call(fibaro:getSelfId(), "pressButton", 2+curmode)
Button 2
fibaro:setGlobal('innerwall_mode',0);
fibaro:call(fibaro:getSelfId(), "setProperty", "currentIcon", 1011);
-- more code
Button 3
fibaro:setGlobal('innerwall_mode',1);
fibaro:call(fibaro:getSelfId(), "setProperty", "currentIcon", 1012);
-- more code
Button 4
fibaro:setGlobal('innerwall_mode',2);
fibaro:call(fibaro:getSelfId(), "setProperty", "currentIcon", 1013);
-- more code
Button 5
fibaro:setGlobal('innerwall_mode',3);
fibaro:call(fibaro:getSelfId(), "setProperty", "currentIcon", 1014);
-- more code
This does the job, but it's a lot of manual labour to duplicate.
1) Is there a way to do this without having to define a global variable?
2) Is there a call to get the ID of the currently selected icon for that button, so that I don't have to hardcode the ID of each icon?
Either would help, both would be phenomenal.
Please login or register to see this attachment.
Please login or register to see this attachment.
3 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.