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 have a several RGBW units and I want to run them using scenes. I want to be able to easily set up scenes where each rgbw is a different colour and I want to be able to select colours by name (mauve, green, maroon etc) rather than manually set the individual colour settings
I've read the excellent article by @AutoFrank but I've got a lot to learn about tables and what I've done so far does work but its clumsy and difficult to use at scale
I’ve created a table with the RGBW settings for 140 colours. Here’s a sample showing how I formatted the table.
light_settings ={
maroon={r=128,g=0,b=0,w=0},
dark_red={r=139,g=0,b=0,w=0},
brown={r=165,g=42,b=42,w=0},
firebrick={r=178,g=34,b=34,w=0},
crimson={r=220,g=20,b=60,w=0},
red={r=255,g=0,b=0,w=0},
tomato={r=255,g=99,b=71,w=0},
coral={r=255,g=127,b=80,w=0},
indian_red={r=205,g=92,b=92,w=0},
light_coral={r=240,g=128,b=128,w=0},
dark_salmon={r=233,g=150,b=122,w=0},
salmon={r=250,g=128,b=114,w=0}
}
I store this as a global Json file
So far I’ve managed to decode the file and use it to set the colour of an RGBW with the following code
rgbw_light = 689
--Decode the Json global table
local light_settings = json.decode(fibaro:getGlobalValue("g_light_set"))
-- get the colour references from the decoded table – in this case the colour is salmon
r=(light_settings.salmon.r)
g=(light_settings. salmon.g)
b=(light_settings. salmon.b)
w=(light_settings. salmon.w)
--turns the light on
fibaro:call(rgbw_light, "setColor", r,g,b,w)
OK this works, but its clumsy and if I have a scene with 10 rgbw and I want them all different colours it’s a lot of individual modifications with a high chance of error. I'm trying to improve the code in two ways
1. I’d like to be able to have one piece of code that gets all four of the rgbw settings from the table in one go, rather than have to repeat the code 4 times
2. I’d like to be able to set the colour to look up from the table – eg “salmon” as a local variable so I can set the colour in a section with all the other variables rather than delve into the middle of the code each time I want to make a change. I can’t figure out how to join a variable to the lookup code line and make it work.
Any help with this would be really appreciated
HC2 v 4.60
10 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.