Bulb won't change brightness and color at the same time

I’m using IKEA tradfri lights with home assistant and everything seems to be working fine. I managed to create an automation that sets the lights to a specific scene when playing a movie on kodi and I noticed that the color changes, but the brightness does not. I tested the scene itself and I found that in order to change the brightness, I have to launch the scene twice. I read that there is a limitation with the scenes, so I wrote a script that would change the colour and brightness for the bulbs but the script also has to be executed twice in order for both the color and brightness to change. Am I doing something wrong?

set_bl_movie:
  sequence:
    - service: light.turn_on
      entity_id: light.living_br
      data:
        transition: 2
        brightness_pct: 30
        color_name: "red"
    - service: light.turn_on
      entity_id: light.living_bl
      data:
        transition: 2
        brightness_pct: 30
        color_name: "red"
        
set_bl_normal:
  sequence:
  - service: light.turn_on
    entity_id: light.living_br
    data:
      transition: 2
      brightness_pct: 100
      hs_color: [30, 85.71428571428571]
  - service: light.turn_on
    entity_id: light.living_bl
    data:
      transition: 2
      brightness_pct: 100
      hs_color: [30, 85.71428571428571]
1 Like

What I’ve found so far is this:
When changing the brightness and color of a bulb without transition, everything works, when changing the brightness and color with transition, the actual state of the brightness for the bulb updates, but the brightness does not change. Is this an issue with HASS itself, or the tradfri library being used?

I’ve also found that this issue only occours when using scenes

Trying to learn more about this behavior too. In this post a solution is offered by using scripts. Have you found a solution for proper transitioning?

1 Like

I have not, scripts have the same behaviour as the scenes, even calling the same script in a scene twice doesn’t solve the issue…

In the topic I linked to, a workaround is provided. After searching, I think it is the best solution available. Might be of use to you.

I know this is old but FWIW I managed to solve this issue by updating the Scene config (via the Deconz API) every 5 mins. This works because the ‘Zigbee Scene’ is stored inside the globes.

The following adjusts the white balance into sunset with a special late night mode to help preserve your night vision:

from requests import post, get, put
from datetime import datetime, timedelta
import json

deconzkey = '<use your own>'
hassauth  = {
    "Authorization": "Bearer <use your own>",
    "content-type": "application/json",
}
sceneid   = '2'
mins_transition = 60
noon_xyb = [0.324, 0.329, 254]
dusk_xyb = [0.501, 0.39 , 254]
late_xyb = [0.461, 0.306, 35 ]

response = get('http://deconz/api/{}/groups/5/scenes/{}'.format(deconzkey,sceneid))
scene    = json.loads(response.text)

response = get('http://homeassistant:8123/api/states',headers=hassauth)
states   = json.loads(response.text)
sun      = [x for x in states if x['entity_id'] == 'sun.sun'][0]
tzoffset = datetime.now() - datetime.utcnow()
now      = datetime.now()
sunset   = datetime.fromisoformat(sun['attributes']['next_dusk']) + tzoffset
sunset   = sunset.replace(day=now.day,month=now.month,year=now.year,tzinfo=None)

blend = min(max((sunset - now).total_seconds() / 60,0),mins_transition) / mins_transition
if now.hour <= 5:
    xyb = late_xyb
else:
    xyb = [noon_xyb[i]*blend + dusk_xyb[i]*(1-blend) for i in range(3)]
    
for light in scene['lights']:
    url = 'http://deconz/api/{}/groups/5/scenes/{}/lights/{}/state'.format(deconzkey,sceneid,light['id'])
    response = put(url, data=json.dumps({"xy":[xyb[0],xyb[1]],"bri":xyb[2]}))

This could be adapted to accept color and brightness - create a quick scene and immediately switch to it.

I have the same problem with scenes, i have to launch the scene twice!
deconz and Ha core. Is there no fix for this?

Appreciate this is a bit old but just adding to this that I had the same problem but I managed to resolve it by separating out the commands that change colour and the commands that change the brightness into their own code sections within the same script. I also needed to put a wait inbetween the two sections.

For example, if you have two lamps, then create an action for the colour changes in the script, put a wait command in for however long you set your transition in your first action and then add the action for your brightness. This seems to work albeit over two actions for the same device with a wait inbetween.

You will also need a second wait and third section of code if you want to change color temps of bulbs that are white only if you have a mixed RGB and White only bulbs in your script that you want to control.

It is a bit of a faff, but it works.

.

Hello there, I was also trying to set night light behaviour - when lights are switched on the brightness and temp should come up based on time/sun. This would always come to issues as the IKEA bulbs have this problem accepting colour and temp at the same time, and lights turning on only to change parameters is not smart at all. I now however seem to have found a solution to this issue using deconz scenes. having two scenes set up and calling one of them in HASS based on time of day or any other condition upon pressing switch button seem to do the trick. it seems like deconz scenes get stored into bulbs and activating scene when button is pressed makes the lights go into exact right settings. this even includes very nice transition and works so far flawlessly. no scripting no workarounds, just activate the right deconz scene in HASS. wondering if phoscon updated this? I will be testing this now extensively but so far not a single glitch!

Please could you let me know if it’s working for you as well? Thank you.

Arg. Took me a few days to figure out why my Ikea color blub would not change color and brightness at the same time. This post provided me a hint on how to patch it.

I have a script to return the light back to normal color and brightness. Instead of adding both brightness and rgb_color at the same time, I had to add a 1 second delay between each.