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

change color of light in lua


Jay Ess

Question

i have a zigbee light on a hc3 and am trying to set the color of the light in lua, can anyone please advise me how i can do this please?

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

The check you do like:

Please login or register to see this code.

 

Is not necessary and makes your code more complicated.

 

You use a variable rgbColor with string: "255,255,255". You now send this value to the first parameter of the  function fibaro.call() (or hub.call() in the new firmware), the other parameters are empty so nothing happens, try:

Please login or register to see this code.

 

Link to comment
Share on other sites

  • 0

Try:

 

hub:call(deviceId, "setColor", red, green, blue)

 

If it’s a RGBW bulb: hub:call(deviceId, "setColor", red, green, blue, white)


deviceId is the id of the Zigbee device, red, green, and blue are integers from the RGB you like. 

 

For example to set warm white: hub:call(22, "setColor", 239,235,216)

 

 

Link to comment
Share on other sites

  • 0
  • Inquirer
  • this is my scene:

    function TurnOnLights(GroupName,SetLightOnLevel,setColor)
        if SetLightOnLevel == nil then SetLightOnLevel = 100 end
        if rgbColor == nil then rgbColor = '255,255,255' end
        for k,i in ipairs(GroupName) do
            if fibaro.getType(i) == "com.fibaro.FGD212" then
                if fibaro.getValue(i, "value") ~= SetLightOnLevel then
                    fibaro.call(i, "setValue",SetLightOnLevel)
                end
            elseif fibaro.getType(i) == "com.fibaro.multilevelSwitch" then
                if SetLightOnLevel == 99 then SetLightOnLevel = 100 end
                if fibaro.getValue(i, "value") ~= SetLightOnLevel then
                    fibaro.call(i, "turnOn")
                    fibaro.call(i, "setValue",SetLightOnLevel)
                    fibaro.sleep(250)
                end
            elseif fibaro.getType(i) == "com.fibaro.FGRGBW442CC" then
                if SetLightOnLevel == 99 then SetLightOnLevel = 100 end
                if fibaro.getValue(i, "value") ~= SetLightOnLevel then
                    fibaro.call(i, "turnOn")
                    fibaro.call(i, "setColor",rgbColor)
                    fibaro.call(i, "setValue",SetLightOnLevel)
                    --print(rgbColor)
                    fibaro.sleep(250)
                end
            else
            --com.fibaro.colorController
                if fibaro.getValue(i, "state") == false then
                    fibaro.call(i, "turnOn")
                end
            end
        end
    end
     
    if fibaro.getValue(SwitchLeft, "value")==true then
        --TurnOnLights(GroupLeft)
        TurnOnLights(GroupLeft,25,'56,141,255')
    else
        TurnOffLights(GroupLeft)
    end
     
    it sets the light to 25% but does not change the colour what am i doing wrong?
    Link to comment
    Share on other sites

    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...