Automation for light: transition w/ template not working for light.turn_on

I have this automation with different delays and brightness for switching a light on or off.
The transition for switching the light on is disregarded, though it works for switching off.
I changed the values, recreated the automation, restarted HA but it to no avail.
The light does support this feature and using this template in a script does work fine.
What am I missing?

alias: "Toilet: Motion"
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.toilet_motion_occupancy
    from: "on"
    to: "off"
    for:
      hours: 0
      minutes: 2
      seconds: 0
  - platform: state
    entity_id:
      - binary_sensor.toilet_motion_occupancy
    from: "off"
    to: "on"
condition: []
action:
  - service: light.turn_on
    metadata: {}
    data:
      transition: "{{ 12 if trigger.to_state.state == 'off' else 9 }}"
      kelvin: >-
        {{ 2200 if is_state('input_boolean.bedtime', 'on') or
        is_state('input_boolean.sleeping', 'on') else 4000 }}
      brightness_pct: >-
        {{ 0 if trigger.to_state.state == 'off' else 1 if
        is_state('input_boolean.bedtime', 'on') or
        is_state('input_boolean.sleeping', 'on') else 100 }}
    target:
      entity_id: light.toilet
mode: single

put 12 in without the template and see if it does 12. Some hardware has limits.

Hi Petro, thanks for picking this up! :bowing_man:
This bulb does support transition, as I wrote in my OP.

I don’t get it…

  • Your proposition does work well (transition is used) but not with the other templates (kelvin & brightness_pct) in place
  • If I leave out the kelvin template, the template for transition works
  • With all 3 templates in place no matter if trigger.to_state.state == ‘off’ or ‘on’
    → light on is always immediately, off by transition value
Result:
params:
  domain: light
  service: turn_on
  service_data:
    transition: 9
    kelvin: 4000
    brightness_pct: 0
    entity_id:
      - light.toilet

Result:
params:
  domain: light
  service: turn_on
  service_data:
    transition: 6
    kelvin: 4000
    brightness_pct: 100
    entity_id:
      - light.toilet

Anyone who knows what is going wrong?
Of course I would like this to work but I’m also very curious to why it’s not functioning as expected.

Apparently this is a known issue with IKEA lights: Avoid IKEA smart light products!