Tradfri Transition

- alias: sensor.galo_pir turn_on light.hall_light motion_detected
  trigger:
    platform: state
    entity_id: sensor.hall_pir
    to: 'ON'
  condition:
    condition: state
    entity_id: sun.sun
    state: below_horizon
  action:
    service: homeassistant.turn_on
    entity_id: light.hall_light
    data:
      transition: 4
      brightness: 180

1 Like

Hereā€™s a little script you can use instead of light.turn_on. It uses half of the given time to first transition the brightness, afterwards it changes the color_temp in half of the given time:

alias: Tradfri_Transition
fields:
  entity_id:
    description: Name(s) of the IKEA Tradfri entities
    example: light.panel
  transition:
    description: >-
      The time in seconds it should take until the desired state is fully
      reached
    example: 60
  brightness:
    description: The desired brightness between 0..255
    example: 142
  color_temp:
    description: The desired color temperature in mireds
    example: 311
sequence:
  - service: light.turn_on
    data_template:
      entity_id: '{{ entity_id }}'
      brightness: '{{ brightness | int }}'
      transition: '{{ transition | int / 2 }}'
  - delay: '00:00:{{ transition | int / 2 + 1}}'
  - service: light.turn_on
    data_template:
      entity_id: '{{ entity_id }}'
      color_temp: '{{ color_temp | int }}'
      transition: '{{ transition | int / 2 }}'
mode: single

Hereā€™s a sample call:

service: script.tradfri_transition
data:
  entity_id: light.panel
  color_temp: 436
  transition: 60
  brightness: 26
entity_id: light.panel

So whenever you switch on one or more Tradfri lights just use the script as service instead of light.turn_on.

2 Likes

Iā€™m having issues with Tradfri and transitions as well. I have tried activating scenes with a transition in the automation. I have tried putting the transition directly into scripts, and now I put the transition back in an automation, but without using scenes. Nothing seems to work.

By separating the temperature and brightness it works better. Letā€™s say you want the bulb to slowly dim and get warmer. Try making the bulb first transition one of the two attributes, and then the other.

Still, itā€™s not reliable at all for me. I have two Tradfri bulbs. Sometimes only one bulb transitions, sometimes none of them do. Sometimes one of them transitions to a warmer state but does not dim, the other dims but does not get warmer. The total randomness of it made me suspect noise was the issue, as i had the Conbee II connected directly into the pi. I added an extension cord without success.

Iā€™m all out of ideas really.

EDIT: Just activating bulbs and scenes without transition work though. So Transition (or maybe automation) seems to be the issue.

1 Like

Some of my tradfri bulbs have issue with not beeing able to use transitions and set wanted brightness, the way i made it work is to first send a ā€œturn_onā€ to the problematic bulb first, and then the scene with the transition.
(scene includes that same problematic bulb)
It seem that some of the bulbs needs to be turned on before it can recive and understand the transition and brightness data.

Automation

    action:
      - service: light.turn_on
        entity_id: light.living_room_corner_hallway
      - service: scene.turn_on
        data:
          entity_id: scene.pre_watch_movie
          transition: 2.5

Scene

- id: c6298787-c935-497b-83b3-1fa5ccfc7b65
  name: Watch Movie
  entities:
    light.hallway_mirror:
      state: 'off'
    light.hallway_wardrobe:
      state: 'on'
    light.living_room_window:
      state: 'on'
      brightness: 29
    light.living_room_corner_hallway:
      state: 'on'
      brightness: 35

Thanks for this. Using homeassistant.turn_on rather than light.turn_on seems to be working :+1:

1 Like

What should I do if I am trying to get the light to dim up on a curve?