Different behaviour color_temp and brightness

Hi,
First post and very new to all of this, but willing to learn :wink:

Running HA on Raspi 4b. Installed RaspBee II. Have a IKEA Tradfri remote and light bulb which can be manipulated from HA.

Now I’m trying to assign the normal functionality to the buttons of the remote. I know I can do this from within deCONZ, but I want to keep everything in HA.

These are the automations I use for that:

- id: '1587459801036'
  alias: Increase Color Temp
  description: Increase Color Temperature of lamp from remote
  trigger:
  - event_data:
      event: 5002
      id: remote_bureau_marc
    event_type: deconz_event
    platform: event
  condition: []
  action:
  - data_template:
      color_temp: '{{state_attr(''light.bureau_marc'', ''color_temp'') + 25}}'
    entity_id: light.bureau_marc
    service: light.turn_on
- id: '1587461216277'
  alias: Decrease Color Temp
  description: Decrease Color Temperature of lamp from remote
  trigger:
  - event_data:
      event: 4002
      id: remote_bureau_marc
    event_type: deconz_event
    platform: event
  condition: []
  action:
  - data_template:
      color_temp: '{{state_attr(''light.bureau_marc'', ''color_temp'') - 25}}'
    entity_id: light.bureau_marc
    service: light.turn_on
- id: '1586459801036'
  alias: Increase Brightness
  description: Increase Brightness of lamp from remote
  trigger:
  - event_data:
      event: 2002
      id: remote_bureau_marc
    event_type: deconz_event
    platform: event
  condition: []
  action:
  - data_template:
      brightness: '{{state_attr(''light.bureau_marc'', ''brightness'') + 10}}'
    entity_id: light.bureau_marc
    service: light.turn_on
- id: '1586461216277'
  alias: Decrease Brightness
  description: Decrease Brightness of lamp from remote
  trigger:
  - event_data:
      event: 3002
      id: remote_bureau_marc
    event_type: deconz_event
    platform: event
  condition: []
  action:
  - data_template:
      brightness: '{{state_attr(''light.bureau_marc'', ''brightness'') - 10}}'
    entity_id: light.bureau_marc
    service: light.turn_on
- id: '1586460637104'
  alias: Turn On normal
  description: ''
  trigger:
  - event_data:
      event: 1002
      id: remote_bureau_marc
    event_type: deconz_event
    platform: event
  condition:
  - condition: device
    device_id: 1598707957774db3830c017f782fc5c9
    domain: light
    entity_id: light.bureau_marc
    type: is_off
  action:
  - data:
      brightness_pct: 50
    entity_id: light.bureau_marc
    service: light.turn_on
- id: '1586460691667'
  alias: Turn On Bright
  description: ''
  trigger:
  - event_data:
      event: 1001
      id: remote_bureau_marc
    event_type: deconz_event
    platform: event
  condition: []
  action:
  - data:
      brightness_pct: 100
    entity_id: light.bureau_marc
    service: light.turn_on
- id: '1586460791735'
  alias: Turn Off
  description: ''
  trigger:
  - event_data:
      event: 1002
      id: remote_bureau_marc
    event_type: deconz_event
    platform: event
  condition:
  - condition: device
    device_id: 1598707957774db3830c017f782fc5c9
    domain: light
    entity_id: light.bureau_marc
    type: is_on
  action:
  - data: {}
    entity_id: light.bureau_marc
    service: light.turn_off

The frustrating part is that changing brightness works like a charm, changing color_temp does nothing. Instead of color_temp, I’ve also tried kelvin. Same issue.
If I don’t try to use a function for color_temp, but simply set it to an integer, it works. As soon as I try to do the formule, it stops working.

Any help appreciated to get this working.

Are you sure that it doesn’t work? In-/decreasing by 25 could be too small of a change to notice. Did you check whether the color temp actually changed or not?

You can also try this to make sure that it is an int, but as far as I know this shouldn’t make a difference.

 - data_template:
      color_temp: "{{state_attr('light.bureau_marc', 'color_temp') | int + 25 }}"
    entity_id: light.bureau_marc
    service: light.turn_on

I’ve also checked with bigger steps. It really isn’t changing.
Tried the including int actually throws an error:

  • Increase Color Temp: Error executing script. Unexpected error for call_service at pos 1: unsupported operand type(s) for +: ‘NoneType’ and ‘int’
  • Decrease Color Temp: Error executing script. Unexpected error for call_service at pos 1: unsupported operand type(s) for -: ‘NoneType’ and ‘int’

Still stuck here.

Actually, I’m seeing now that that error is also thrown with my initial setup without the int. So no I only need to understand why this is thrown with color_temp and not with brightness.

It probably has something to do with the fact that it is not actually a state atribute.
If I get the state attributes of light.bureau_marc, I get:

min_mireds: 153
max_mireds: 500
brightness: 127
is_deconz_group: false
friendly_name: Bureau Marc
icon: 'mdi:desk-lamp'
supported_features: 43

But I can set the color temp with a service call:

entity_id: light.bureau_marc
color_temp: 500

This sets the color_temp to yellow (500)

I’m guessing because color_temp is not a state, I can’t do the match light with brightness.
Then the question is, how do I make the color_temp increase in case of the event.

Reading colortemp in deconz is broken.

I use DeCONZ and it works for me:

@mvieleers
When you set the color temp manually, due you see color_temp as an attribute in Developer Tools -> States?

No only this:

min_mireds: 153
max_mireds: 500
brightness: 147
is_deconz_group: false
friendly_name: Bureau Marc
icon: 'mdi:desk-lamp'
supported_features: 43

If the bulb is on and you click on it do you see a color temperature slider or only a brightness slider?

When I use the Template section with {{state_attr('light.bureau_marc', 'color_temp')}} I get “None” as response

After your response, I searched for this issue in combination with deCONZ. There indeed was a github issue for this, but it has been closed as being fixed: https://github.com/home-assistant/core/issues/24143
Several users have reported however that it isn’t.

@Burningstone: very interested to understand why this is working for you.
I’m using a TRADFRI bulb E14 WS opal 600lm, could it be that you are using a different one which doesn’t have this issue?

I’m using only Philips Hue, had Ikea bulbs im the padt but never checked this feature sorry.

OK, clear. I think I have the automations correct now, where I can increase with steps on each press and smoothly go through the transition by long pressing it.
This works for brightness. Should work for color_temp as well.
It has to be a bug somewhere. Some more reading points the issue at ikea, others with deconz.
I’ll have to wait for a solution.

After a lot of messing around, I eventually stumbled upon this: https://xaviml.github.io/controllerx/

Short piece of code in /config/appdaemon/apps/apps.yaml and the remote has the native functionality as with the ikea gateway.

1 Like

There have been recent work that is committed, unsure if it’s in a release or if it works. Using my patched .69 until confirmed.

@Flurken What committed work are you referring to? An update to deconz?

Yeah, ebaauw has a branch merged where he seems to have done some work on ct. I have not checked it out since I am waiting for the whole ikea routing situatuion to be resolved. It seems to be in response to my initial ct bug with ikea.