Jump to content

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


  • 0

How do I get the RGB values of a bulb?


Question

Posted (edited)

I've googled and googled and can't seem to find the answer.

 

I'm wanting the 'opposite' of this command

fibaro:call(69, "setColor", "0","0","0","255");

 

so instead of setting the values, I first want to read them.

 

I'm trying to create a scene that would transition from an existing colour to a new colour.  To do that, I need to know what the current colour *is* so I can then change the values over time to the target values.  Hope that makes sense.

 

i have the Aeotec RGB bulb in case that makes a difference.

 

Edited by disorganise

3 answers to this question

Recommended Posts

  • 0
Posted (edited)

Makes sense absolutely...

To read the color value use:

colorValue = fibaro:getValue(devID, "color")

The response  is string value and has four numbers (RGBW) and it looks like:

"10,15,230,0"

You can extract the value as numbers, but since when you set the color you need to send string, so it  better to compare string to string.

For example:

Please login or register to see this code.

Hope it helps

Edited by cag014
  • 0
  • Inquirer
  • Posted

    awesome, that helps a LOT.  Thanks

    umm....

    If I want to do maths on the values (calculate difference between targeted red value and current red value for example), I need to extract the four values as separate numbers (or strings I can 'tonumber' anyway).  Is there a simple way to do that?

     

     

    Big picture...

    I'm reading one of the tutorials from autofrank to figure out the LUA overall.   My goal is to have:

    Each button on a touch panel set a target RGB by writing out to global variables.

    A scene that triggers whenever the global target variables are changed.  This scene reads the existing bulb colour, calculates the difference between it and the target values gleaned from the global variables, and then adjusts the RGB values over an adjustable amount of time towards the target - so white slowly becomes purple for example.

     

    I assume I can then have timed events to also trigger updating the target values, and the same scene will pick up and react to the change.

    • 0
    Posted (edited)

    The simple way to extract the numbers from string:

    Note ; colorValue is variable that has been received from colorValue = fibaro:getValue(devID, "color")

              R,G,B,W = colorValue:match("(%d+),(%d+),(%d+),(%d+)")

    Your "Big Picture" concept sounds OK and should work

    Note:

    colorValue is variable that has been received from colorValue = fibaro:getValue(devID, "color")

    Edited by cag014

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Answer this question...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...