Dim lights connected to Tradfri Hub using HA automations

Using a few Hue Dimmer Switches to switch lights on/off and dim up/dowm them with HA automations like below (dim up in this case). This works with lights paired to a Conbee using deCONZ, but did not work for a light which are paired to a Tradfri Hub which is added to HA as an integration. I know, the Tradfri Hub is not necessary when using a Conbee, but I am testing some things at the moment :slight_smile:

Anyone able to share a working HA automation for dimming lights paired to a Tradfri Hub?

- alias: Spots logeerkamer Hue dimmer omhoog
  initial_state: true
  trigger:
  - event_data:
      event: 2002
      id: dimmer_switchlogeerkamer
    event_type: deconz_event
    platform: event
  action:
  - service: light.turn_on
    data_template:
      entity_id: light.logeerkamer
      brightness: '{% set bri = states.light.logeerkamer.attributes.brightness | int
        %} {{ [bri+30, 249] | min }}

Just an idea, could it be possible that the Ikea light doesn’t accept brighness but only brightness_pct?

Thanks for your suggestion. I have tried both ‘brightness’ and ‘brightness_pct’ from developer tools an both work (‘brightness 1-255’ and ‘brightness_pct’ 1-100).

Then it looks like the datatemplate is invalided when using a light connected to a Tradfri Hub.

Your template is wrong, you are missing a single quote at the end of the template. Also you should avoid using ‘states’ and rather use ‘state_attr’, check the documentation here.

This works for me:

- alias: Spots logeerkamer Hue dimmer omhoog
  initial_state: true
  trigger:
  - event_data:
      event: 2002
      id: dimmer_switchlogeerkamer
    event_type: deconz_event
    platform: event
  action:
  - service: light.turn_on
    data_template:
      entity_id: light.logeerkamer
      brightness: >-
        {% set bri = state_attr('light.logeerkamer', 'brightness') | int %} 
        {{ [bri+30, 249] | min }}

@Burningstone

Ah, the single quote at the end of the template was missing when copy/pasting the yaml here. It is actually there.

Unfortunately, your version does not work here with a light connected with a Tradfri Hub. With a deCONZ light, it is working.(up and down, for monts, without any issue)

I don’t see why this should work for deconz light but not a normal light?

When you enter this whole text block to the template editor, what do you get as a result?

Me neither, that the reason of opening this topic :slight_smile:
(The name of the light and dimmer are changed to match the actual situation)

Is the light turned on currently?

Let’s give this https://www.home-assistant.io/blog/2020/02/26/release-106/#stepping-up-and-down-the-brightness-of-lights a try for the Tradfri groups.

How is this possible, when you enter this template into the editor and the light is turned on, the number must be > 30.
Can you please show how the entity looks in Developer Tools -> States?

Of course this will always turn off the light, you need max not min :wink:

To be sure: My goal is to use this automation to set the brightness 30 higher every time when the automation is triggered.

When changing the brightness of the light group (Tradfri Hub) with the slider, the brightness of the light group is not changing, only the brightness of the individual lights of the group is changing:

When doing the same with a light group from deCONZ, the brightness of the group is also changing.

Maybe there is actually a difference in dimming lights from deCONZ and Tradfri Hub?

Is this light group one you created in home assistant or in the Tradfri Hub?

Created in the Tradfri Hub.

In addition to this: dimming the Tradfri (group) light using this custom slider does not work as expected either. Choosing a dim level works, but the slider jumps always back to ths left, and does not stay at the touched dim level (as with other, also deCONZ, lights).

Ok, strange behaviour. Time to move all the lights to deconz, no issues with dimming a group of lights there :stuck_out_tongue_winking_eye: I’m sorry but I really don’t know how to help you any further.

Thanks for your effort.

Trying the Tradfri Hub to figger out if this issue is causes by Conbee/deCONZ or is an (firmware) bulb issue.

Anyone able to share a working automation for this?