Tradfri bulb white balance

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
User avatar
jacobsentertainment
Posts: 223
Joined: Thursday 01 October 2020 1:47
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021-1
Location: Not @ home
Contact:

Tradfri bulb white balance

Post by jacobsentertainment »

Hi all,

I'm not getting my ikea tradfri bulbs to change color, I have the type that only goes from yellow to bright white.
Currently I use setLevel to change the brightness that works but if I try kelvin or setcolbrightnessvalue i cant make it work

If I manually change he color I get this in the log

Code: Select all

2025-02-24 22:00:55.140 Status: setcolbrightnessvalue: ID: 31d, bri: 65, color: '{m: 2, RGB: 000000, CWWW: 15ea, CT: 234}'
2025-02-24 22:00:55.728 Status: setcolbrightnessvalue: ID: 31d, bri: 65, color: '{m: 2, RGB: 000000, CWWW: 15ea, CT: 234}'
2025-02-24 22:00:57.525 Status: setcolbrightnessvalue: ID: 31d, bri: 65, color: '{m: 2, RGB: 000000, CWWW: 7b84, CT: 132}'
2025-02-24 22:01:05.822 Status: setcolbrightnessvalue: ID: 31d, bri: 65, color: '{m: 2, RGB: 000000, CWWW: 1de2, CT: 226}'
2025-02-24 22:01:14.901 Status: setcolbrightnessvalue: ID: 31d, bri: 65, color: '{m: 2, RGB: 000000, CWWW: 2ad5, CT: 213}' 
If any of you have a idea how to proceed that would be awsome.
User avatar
waltervl
Posts: 5781
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Tradfri bulb white balance

Post by waltervl »

What is the command you use?
RGB: 000000 indicates no color (white or black?)
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
jacobsentertainment
Posts: 223
Joined: Thursday 01 October 2020 1:47
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021-1
Location: Not @ home
Contact:

Re: Tradfri bulb white balance

Post by jacobsentertainment »

Hi Waltervl,

I use this to increase the brightness

Code: Select all

   if lux < lux_threshold_low then
                setLamps(55)
I have no clue how to implement the color change
User avatar
waltervl
Posts: 5781
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Tradfri bulb white balance

Post by waltervl »

I cannot find a setLamps() function in the documentation https://wiki.domoticz.com/DzVents:_next ... _scripting
So it seems you created your own setLamps() function.

Please check the wiki on RGBW(W) compatible dzvents functions:
https://wiki.domoticz.com/DzVents:_next ... ss/Applamp

and for the setColor(r, g, b, br, cw, ww, m, t): Function check also API wiki:
https://wiki.domoticz.com/Domoticz_API/ ... emperature
RGBW(W) / Lighting Limitless/Applamp
decreaseBrightness(): deprecated because only very limited supported and will be removed from API
getColor(); Function. Returns table with color attributes or nil when color field of device is not set.
increaseBrightness(): deprecated because only very limited supported and will be removed from API
setColor(r, g, b, br, cw, ww, m, t): Function. Sets the light to requested color. r, g, b required, others optional. Supports command options. Meaning and limits of parms can be found here.
setColorBrightness(): same as setColor
setDiscoMode(modeNum): deprecated because only very limited supported and will be removed from API
setHex(r, g, b): Function. Sets the light to requested color. r, g, b required (decimal Values 0-255). Supports command options.
setHue(hue, brightness, isWhite): Function. Sets the light to requested Hue. Hue and brightness required. Supports command options.
setKelvin(Kelvin): Function. Sets Kelvin level of the light (For RGBWW devices only). Supports command options.
setNightMode(): Function. Sets the lamp to night mode. Supports command options.
setRGB(red, green, blue): Function. Set the lamps RGB color. Values are from 0-255. Supports command options.
setWhiteMode(): Function. Sets the lamp to white mode. Supports command options.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
jacobsentertainment
Posts: 223
Joined: Thursday 01 October 2020 1:47
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021-1
Location: Not @ home
Contact:

Re: Tradfri bulb white balance

Post by jacobsentertainment »

waltervl wrote: Tuesday 25 February 2025 9:28 I cannot find a setLamps() function in the documentation https://wiki.domoticz.com/DzVents:_next ... _scripting
So it seems you created your own setLamps() function.
Correct Waltervl I did that with

Code: Select all

local function setLamps(level)
Current script I only set the level as I dont know how to change the color.
User avatar
waltervl
Posts: 5781
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Tradfri bulb white balance

Post by waltervl »

Check for example topic viewtopic.php?p=248712#p248712
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
jacobsentertainment
Posts: 223
Joined: Thursday 01 October 2020 1:47
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021-1
Location: Not @ home
Contact:

Re: Tradfri bulb white balance

Post by jacobsentertainment »

I got it sorted my little scropt to change the white to yellow isch lapms of Ikea.
I was focused on changing the CWWW with 0000, 00ff or ff00 but nothing worked for me. But it wasn't necessary at all I only had to change the t(emperatur) between 0 & 255 See the script that works for me.

Code: Select all

return {
    on = {
        devices = { 798 } -- trigger
    },

    execute = function(domoticz, device)
        domoticz.log("Kleurinstelling...", domoticz.LOG_INFO)

        --JSON kleurinstellingen
        local colorJSON = '{"m":2,"t":255,"cw":0,"ww":0,"r":0,"g":0,"b":0}' --change color @ "t":.. "0 for cold white & 255 for warm"
        local encodedColor = domoticz.utils.urlEncode(colorJSON)

        --API JSON
        local url = "http://192.168.178.72:8080/json.htm?type=command&param=setcolbrightnessvalue"
                  .. "&idx=797"
                  .. "&brightness=65"   --change brightness here
                  .. "&color=" .. encodedColor

        --URL voor debug
        domoticz.log("Verzonden URL: " .. url, domoticz.LOG_DEBUG)

        domoticz.openURL(url)
    end
}
User avatar
waltervl
Posts: 5781
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Tradfri bulb white balance

Post by waltervl »

You dont need to use the API as dzvents does exactly the same.
"m":2,"t":255,"cw":0,"ww":0,"r":0,"g":0,"b":0 is the same as
domoticz.devices(ýour bulb').setColor(2,255,0, 0, 0, 0, 0, 0)
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
jacobsentertainment
Posts: 223
Joined: Thursday 01 October 2020 1:47
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021-1
Location: Not @ home
Contact:

Re: Tradfri bulb white balance

Post by jacobsentertainment »

Works! Cheers Waltrvl
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest