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
Rosavision 6
I’m using decoded JSON data tables to set global variables so that lighting scenes set different light ambience during the day / evening.
The following line works OK but its clumsy to change the references numbers in the decode string for each code line
Instead of this
decoded_light_settings.rgbw_4.r
I’d like to do this
Ref=4
decoded_light_settings.rgbw_(ref).r
but I can’t figure out the correct syntax
The complete code I’m using is….
local decoded_light_settings = json.decode(fibaro.getGlobalVariable("g_light_set"))
local ref=
{decoded_light_settings.al_4.c, decoded_light_settings.al_4.w, decoded_light_settings.rgbw_4.r, decoded_light_settings.rgbw_4.g, decoded_light_settings.rgbw_4.b, decoded_light_settings.rgbw_4.w, decoded_light_settings.rgb_4.r, decoded_light_settings.rgb_4.g, decoded_light_settings.rgb_4.b, decoded_light_settings.rgb_4.w, decoded_light_settings.sl_4.sl,}
local g=
{"g_al_cold", "g_al_warm", "g_rgbw_red", "g_rgbw_green", "g_rgbw_blue", "g_rgbw_white", "g_rgb_red", "g_rgb_green", "g_rgb_blue", "g_rgb_white","g_sl"}
if#g>0 then
for i = 1,#g do
--fibaro.call(g[i])
fibaro.setGlobalVariable(g[i], tostring(ref[i]))
end
end
Any help much appreciated
Link to comment
Share on other sites
7 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.