Hi
I have been migrating all my lights from Philips Hue hub and over to Deconz (with Conbee II stick)
One of the things that puzzled me was how to get the same press and hold dimming of the lights.
In the Deconz documention there is an example of a method where you step up and down in brightness. That works but it is not as elegant as holding in the increase or decrease buttons and let go when you think the light is right.
But it is actually possible to implement this in Deconz. I have been finding bits and pieces of documentation here and there but not a full example. So here are TWO examples.
Before you start you need to define groups in the Deconz app. We are working with deconz.configure messages and they work on deconz objects.
So in Phoscon you create the groups. One for each room or function that you want to control with a dimmer switch. And then you put the lights in each group.
If you have a mix of dimmable lights and switches it is not a problem. The system is smart enough to ignore the brightness changes for switches but you can still turn the whole group on and off. So put all the lights in the group.
And Deconz allows that the same light is in multiple groups.
Then you either restart home assistant or go to the Developer Tools -> Services and run a deconz.device_refresh (no service data needed). This imports the new groups into Home Assistant where they will be created as for example light.bedroom
We also assume you have a dimmer switch like the 4-button Philips Hue switch paired and available in Home Assistant. Remember that dimmers are event devices. They create events when you press the buttons. You can see the event device id and event values in Developer Tools -> Events where you type in deconz_event and click Start Listening. And then just press the buttons and watch the events below
Now we need to create an Automation. I have my configuration.yaml a line that says
automation: !include_dir_merge_list automation
And I have created a directory called automation in which I have one file for each set of related automation. So I have one file for each dimmer that controls a group of lights.
The first example is a 4-button Philips Hue dimmer that controls the lights in my bedroom.
Short press on the ON button turns on the light at 50%. Long press 100%. And the OFF buttons turns all light off.
The increase and decrease buttons turn the light up and down.
The way it works it that pressing and holding the increase/decrease buttons actually turn the light up or down 254 steps relative to current brightness with a long transition time. When you release the button a stop signal is sent to the lights (increase with the value 0). If you want the light to change faster you just change the value 50 to something smaller. I experimented with the increment/decrement value and 255 does nothing. 254 is max.
- alias: 'Turn On Bedroom from dimmer normal'
initial_state: 'on'
trigger:
platform: event
event_type: deconz_event
event_data:
id: bedroom_switch
event: 1002
action:
- service: light.turn_on
data:
entity_id:
- light.bedroom
brightness_pct: 50
- alias: 'Turn On Bedroom from dimmer bright'
initial_state: 'on'
trigger:
platform: event
event_type: deconz_event
event_data:
id: bedroom_switch
event: 1001
action:
- service: light.turn_on
data:
entity_id:
- light.bedroom
brightness_pct: 100
- alias: 'Increase brightness Bedroom from dimmer'
initial_state: 'on'
trigger:
platform: event
event_type: deconz_event
event_data:
id: bedroom_switch
event: 2001
action:
- service: deconz.configure
data:
entity: light.bedroom
field: "/action"
data: {"bri_inc":254, "transitiontime":50}
- alias: 'Decrease brightness Bedroom from dimmer'
initial_state: 'on'
trigger:
platform: event
event_type: deconz_event
event_data:
id: bedroom_switch
event: 3001
action:
- service: deconz.configure
data:
entity: light.bedroom
field: "/action"
data: {"bri_inc":-254, "transitiontime":50}
- alias: 'Stop brightness Bedroom from dimmer'
initial_state: 'on'
trigger:
- platform: event
event_type: deconz_event
event_data:
id: bedroom_switch
event: 2003
- platform: event
event_type: deconz_event
event_data:
id: bedroom_switch
event: 3003
action:
- service: deconz.configure
data:
entity: light.bedroom
field: "/action"
data: {"bri_inc":0}
- alias: 'Turn Off Bedroom from dimmer'
initial_state: 'on'
trigger:
platform: event
event_type: deconz_event
event_data:
id: bedroom_switch
event: 4002
action:
- service: light.turn_off
entity_id:
- light.bedroom
Next example is a Closet with only one lamp so I did not bother creating a group. When you use the deconz.configure on a light instead of a group the field has to be âstateâ and not âactionâ!!
Here is the example
- alias: 'Turn On Closet from dimmer'
initial_state: 'on'
trigger:
platform: event
event_type: deconz_event
event_data:
id: closet_switch
event: 1002
action:
- service: light.turn_on
data:
entity_id:
- light.closet
brightness_pct: 100
- alias: 'Increase brightness Closet from dimmer'
initial_state: 'on'
trigger:
platform: event
event_type: deconz_event
event_data:
id: closet_switch
event: 2001
action:
- service: deconz.configure
data:
entity: light.closet
field: "/state"
data: {"bri_inc":254, "transitiontime":50}
- alias: 'Decrease brightness Closet from dimmer'
initial_state: 'on'
trigger:
platform: event
event_type: deconz_event
event_data:
id: closet_switch
event: 3001
action:
- service: deconz.configure
data:
entity: light.closet
field: "/state"
data: {"bri_inc":-254, "transitiontime":50}
- alias: 'Stop brightness Closet from dimmer'
initial_state: 'on'
trigger:
- platform: event
event_type: deconz_event
event_data:
id: closet_switch
event: 2003
- platform: event
event_type: deconz_event
event_data:
id: closet_switch
event: 3003
action:
- service: deconz.configure
data:
entity: light.closet
field: "/state"
data: {"bri_inc":0}
- alias: 'Turn Off Closet from dimmer'
initial_state: 'on'
trigger:
platform: event
event_type: deconz_event
event_data:
id: closet_switch
event: 4002
action:
- service: light.turn_off
entity_id:
- light.closet
Update showing how to do the same with the new automation features introduced with Home Assistant 0.113. It is same principle but now we can do all the functions with a single automation.
- alias: 'Bedroom Dimmer'
initial_state: 'on'
trigger:
platform: event
event_type: deconz_event
event_data:
id: bedroom_switch
action:
- choose:
# Normal ON dimmed
- conditions:
- condition: template
value_template: "{{ trigger.event.data.event == 1002 }}"
sequence:
- service: light.turn_on
data:
entity_id:
- light.bedroom
brightness_pct: 50
# Long press full brightness
- conditions:
- condition: template
value_template: "{{ trigger.event.data.event == 1001 }}"
sequence:
- service: light.turn_on
data:
entity_id:
- light.bedroom
brightness_pct: 100
# Increase
- conditions:
- condition: template
value_template: "{{ trigger.event.data.event == 2001 }}"
sequence:
- service: deconz.configure
data:
entity: light.bedroom
field: "/action"
data: {"bri_inc":254, "transitiontime":50}
# Decrease
- conditions:
- condition: template
value_template: "{{ trigger.event.data.event == 3001 }}"
sequence:
- service: deconz.configure
data:
entity: light.bedroom
field: "/action"
data: {"bri_inc":-254, "transitiontime":50}
# Stop increase/decrease
- conditions:
- condition: template
value_template: "{{ trigger.event.data.event in ( 2003, 3003 ) }}"
sequence:
- service: deconz.configure
data:
entity: light.bedroom
field: "/action"
data: {"bri_inc":0}
# Off
- conditions:
- condition: template
value_template: "{{ trigger.event.data.event == 4002 }}"
sequence:
- service: light.turn_off
data:
entity_id:
- light.bedroom
#default:
I hope this topic will be a good help to new and maybe also old Deconz users. Enjoy
Kenneth