Here is a good method for dimming lights in Deconz

What are you missing, it’s all right there. Can you show your current code please?

My code is the same as in the example. I get it yesterday also working with the 5 Button remote. Only the Dimmer Switch does not work at dimming.
I guess he needs a little adjustment.

switch_work_light_decrease_brightness.yaml

---
# Reduces the brightness of the worktop lighting.
# Devices:
#   Type: "Ikea Tradfri"
#     - Dimmer Switch
#     - Transformer

alias: worklight_dimmer_lights_decrease_brightness
initial_state: "on"
trigger:
  platform: event
  event_type: deconz_event
  event_data:
    id: ku_switch_worklight
    event: 2001
action:
  - service: deconz.configure
    data:
      entity: group.ku_group_work_light
      field: "/state"
      data: { "bri_inc": -254, "transitiontime": 50 }

switch_work_light_increase_brightness.yaml

---
# Increases the brightness of the worktop lighting.
# Devices:
#   Type: "Ikea Tradfri"
#     - Dimmer Switch
#     - Transformer

alias: worklight_dimmer_lights_crease_brightness
initial_state: "on"
trigger:
  platform: event
  event_type: deconz_event
  event_data:
    id: ku_switch_worklight
    event: 1001
action:
  - service: deconz.configure
    data:
      entity: group.ku_group_work_light
      field: "/state"
      data: { "bri_inc": 254, "transitiontime": 50 }

switch_work_light_off.yaml

---
# Switches the worktop lighting off.
# Devices:
#   Type: "Ikea Tradfri"
#     - Dimmer Switch
#     - Transformer

alias: worklight_dimmer_lights_off
initial_state: "on"
trigger:
  platform: event
  event_type: deconz_event
  event_data:
    id: ku_switch_worklight
    event: 2002
action:
  - service: light.turn_off
    data:
      entity_id: group.ku_group_work_light

switch_work_light_on.yaml

---
# Switches on the worktop lighting.
# Devices:
#   Type: "Ikea Tradfri"
#     - Dimmer Switch
#     - Transformer

alias: worklight_dimmer_lights_on
initial_state: "on"
trigger:
  platform: event
  event_type: deconz_event
  event_data:
    id: ku_switch_worklight
    event: 1002
action:
  - service: light.turn_on
    data:
      entity_id: group.ku_group_work_light
      brightness_pct: 100

switch_work_light_stop_brightness.yaml

---
# Stops the dimming of the worktop lighting.
# Devices:
#   Type: "Ikea Tradfri"
#     - Dimmer Switch
#     - Transformer

alias: worklight_dimmer_lights_stop_brightness
initial_state: "on"
trigger:
  - platform: event
    event_type: deconz_event
    event_data:
      id: ku_switch_worklight
      event: 1003
  - platform: event
    event_type: deconz_event
    event_data:
      id: ku_switch_worklight
      event: 2003
action:
  - service: deconz.configure
    data:
      entity: group.ku_group_work_light
      field: "/state"
      data: { "bri_inc": 0 }

edit: I also tried "field: “/state” and "field: “/action”

The deconz.configure service works only with deconz lights or deconz light groups, it does not work with groups created in home assistant.
Also note “field” must be “/action” if it is a light group and “/state” if it is a single bulb.

If you did not already create groups in phoscon, do this and then use these groups instead of “group.ku_group_work_light”. Groups created in phoscon exposed to home assistant will start with “light.” and the attribute “is_deconz_group” is true.

1 Like

Thank you. Now it works!

Is there any way to do this with regular Home Assistant switch?

I have a Deconz switch but a EspHome light.

No. This works only with deconz lights as the service is only available for deconz. Check out this app from @xaviml, it should cover your needs.

Thank you so much @KennethLavrsen! This is great. Saved me a lot of time.

Do someone knows how to translate all these code in Node Red (if possible) ?

I use deconz and i didn’t even bother with all the automations. I just use the Phoscon app to allocate dimmers to the light groups and do it that way.
If you are using Deconz you might and just want to dim hue globes that is easier.
Obviously if you want your hue dimmer to control non-zigbee lights, then the automations are needed.

I made an update of my original post above showing how to do the same function using the new HA version 0.113 automation features. Now you can do is all with one automation which makes it simpler to overview and maintain.

Since I posted my original post I have put all HA config on github. You can find more examples there using the dimming method with deconz

4 Likes

I was given this little simplification which I added to my original post

The stop condition can be

      - conditions:
          - condition: template
            value_template: "{{ trigger.event.data.event in ( 2003, 3003 ) }}"

A little more simple.

Thanks for sharing @KennethLavrsen , that’s really cool and just want I needed! Reduced 5 individual scripts down to one and I had got stuck on the stop dimming bit! Thanks again…

I’ve changed this to “… not in ( 2001, 3001 )…” this seems a bit more reliable. Some times I had that the automation kept dimming even after i stopped turning.

Thank you.
Your updated method is a showcase example to achieve a much sort after automation -it should be stickied somewhere.

I just want to say thank you!

This works perfect for the application i wanted.

I use ESPhome device to directly call the deconz.configure service calls.
Now my wifi wall switches can dim my zigbee lights.

@KennethLavrsen Can you help me figure out why this isn’t working:

alias: Test deConz Event from IKEA button_switch
description: ''
trigger:
  - platform: event
    event_type: deconz_event
    event_data:
      id: tradfri_on_off_switch
      event: template
      value_template: "{{ trigger.event.data.event in ( 1002, 1001 ) }}"
condition: []
action:
  - service: homeassistant.turn_on
    data: {}
    entity_id: light.pg_living_room
mode: single

If I just use event: 1002 and remove the templating, it works perfect.
But I want it to perform the same action whether its an on button press or off button press.
I know I could just make an additional trigger, but I’m pursuing this in order to learn.

Move the template to the condition, you can’t template the event like this.

trigger:
  - platform: event
    event_type: deconz_event
    event_data:
      id: tradfri_on_off_switch
condition:
  condition: template
  value_template: "{{ trigger.event.data.event in [1002, 1001] }}"

or shorter:

condition:
  - "{{ trigger.event.data.event in [1002, 1001] }}"

Fantastic! Thank you so much.
But did you mean; “You can’t template an event like this” or did you mean; “You can’t template an event at all” ?

@Burningstone in my updated example in the original post someone kindly suggested the syntax

{{ trigger.event.data.event in ( 2003, 3003 ) }}

And you now show

{{ trigger.event.data.event in [ 2003, 3003 ] }}

Both seem to work.

What is most correct? and why does the round () instead of the square [] work?

As far as I know you can’t template the event at all.