DeCONZ Hue Dimmer Switch app with smooth dimming functionality

Hi everyone

Inspired by @KennethLavrsen awesome method for smoothly dimming deconz lights, I created a small app for controlling deconz lights (and more) with a Philips Hue Dimmer Switch.

The bad boy I’m talking about:

A description on how the app works and how you can configure it.

Basic configuration:
With the basic configuration the behaviour is as follows:

  • release ON button after short press of the button-> light turns on at 100%
  • release OFF button after short press of the button-> light turns off
  • press and hold INCREASE BRIGHTNESS button -> brightness increases smoothly
  • press and hold DECREASE BRIGHTNESS button -> brightness decreases smoothly
  • release INCREASE BRIGHTNESS or DECREASE BRIGHTNESS after holding the button -> dimming stops

Example config:

dimmer_test:
  module: hue_dimmer_switch
  class: HueDimmerSwitch
  entities:
    switch: dimmer_switch_bedroom (required)
    light: light.bedroom (required)

Advanced configuration:
The switch behaves the same way as with the basic configuration. However, the button presses can be overwritten and other button presses can be added. The available actions to assign to a button press are “turn_on”, “turn_off” and “service_call”.
The configuration for a button press looks like this.

button_press_name:
  action_type: turn_on | turn_off | service_call
  action_entity: entity_id of entity to be used in the action
  parameters: optional, parameters to give if you chose service_call

The following button_press_names are available and can be overwritten:

  • short_press_on
  • short_press_on_release
  • long_press_on
  • long_press_on_release
  • short_press_up
  • short_press_up_release
  • short_press_down
  • short_press_down_release
  • short_press_off
  • short_press_off_release
  • long_press_off
  • long_press_off_release

Example config:

dimmer_test:
  module: hue_dimmer_switch
  class: HueDimmerSwitch
  entities:
    switch: dimmer_switch_bedroom (required)
    light: light.bedroom (required)
  advanced:
    short_press_on_release: (optional)
      action_type: turn_on
      entity: scene.good_night
    long_press_on_release: (optional)
      action_type: service_call
      entity: light.bedroom
      service: turn_on
      parameters:
        brightness: 255
        color_name: blue
    short_press_off_release (optional):
      action_type: turn_off
      entity: light.bedroom
    long_press_off_release (optional):
      action_type: turn_off
      entity: group.bedroom

The app can be found here - > click me

I’d love to get some feedback on the app.
I could integrate other switches if there’s a demand for that, as long as they work with events and have a hold button and release button event.

If you have some issues/feature requests/ideas please let me know.

Edit: App now available in HACS as a custom repository under this address: https://github.com/Burningstone91/Hue_Dimmer_Deconz
I made a PR to get it added to the default store.

Edit 2: PR has been merged, app should be available in a few hours in the default store.

3 Likes

I will try this in the upcoming week. I have never tried AppDaemon before though, but I have it installed and ready to go. I will post my findings here next week (hopefully I will find time on monday).

It is looking good, the dimming part was the only thing missing in my deconz setup. With this post I also found the post you inspired your app on which is great.

Thank you.

Edit: could you release this on HACS?

Never done that before. I will read up on HACS and try to release it there.
I’ll let you know once I made some progress.

I read upon on HACS and it seems not so difficult, I’ll try to release something this week.

1 Like

Sorry for my late reply, was a bit busy with other smart home problems :upside_down_face:
I made a PR to get the app added to HACS, in the meantime you can add it as a custom repository with this address: https://github.com/Burningstone91/Hue_Dimmer_Deconz

2 Likes

No worries, I am extremely busy myself so I didn’t have much time to check out all new components and plugins anyways. I will test this as soon as I have the opportunity, though with the work on my current project I think this will be in the next year XD. Thanks, I have already shared your project with my slack group so maybe they’ll test it before I do. But I will let you know ofc.

1 Like

PR has been merged, in a few hours the repo should be visible in the default store.

Burningstone many thanks for this! I will try it on this weekend. :+1:

Yes, please :slight_smile: Would be happy to receive some feedback.

Hey! This looks really clean. Sadly, I don’t use Deconz, so I can’t really test it.

I love how you’re starting a long transition to do the dimming and then stopping the transition when the button is released. That’s very smart and MUCH better than other implementations I’ve seen where a button press sends a small increment every second or so. Your method should look nice and smooth while the usual method appears jumpy at best.

The code is clean and easy to read.

I think other Zigbee implementations (ZHA, Zigbee2MQTT) might support similar functionality, so this could be adapted to work with those integrations as well.

The only change I would consider is your first line of initialize.

set_namespace(‘hass’) likely works for you because you have appdaemon.yaml configured that way. But for most people (including me), it will not. And you don’t offer any way to configure this.

Most people, use the “default” namespace for HASS, because that’s what the docs offer as example configuration code.

I would do this instead to provide the ultimate in flexibility:

self.namespace = self.args.get('hass_namespace', 'default')
self.set_namespace(self.namespace)

Then, anyone using a “non-standard” namespace for HASS (or multiple HASS plugins) can add (in your case):

hass_namespace: hass

to their YAML and still be able to use your app.

Thanks a lot for your feedback! Highly appreciated.

It’s amazing that DeCONZ provides this functionality, as far as I know the others don’t provide this kind of functionality (yet), but I would be happy to change my app and add the functionality for ZigBee2MQTT and ZHA as well.

I removed the set_namespace for now, as I assume most people testing the app will be using a standard setup, more so now that I released it in HACS. Probably going to add your suggestion later.

I don’t know about ZHA. I use it for testing, but don’t have any bulbs attached at the moment that would support this kind of operation.

With Zigbee2MQTT it is supported, it’s just more complicated.

First, only SOME bulbs support transitions. This may be true for Deconz as well, I’m not sure. With a supported bulb in Zigbee2MQTT, to start the transition, you’d send this:

self.call_service('light/turn_on',
entity_id='light.front_table',
brightness=255,
transition=50)

That’s easy. It’s the stopping that’s harder. This should work, though I’ve only tested it manually:

current_brightness = self.get_state('light/turn_on', attribute='brightness')

self.call_service('light/turn_on',
entity_id='light.front_table',
brightness=current_brightness)

Essentially, the way to stop the transition from continuing is to set an explicit brightness level. By using get_state (since zigbee2mqtt reports state as the brightness changes) we can get the current brightness level of the light and use that to stop the transition.

Though I’d never considered it before now as I don’t have any functionality like this in my house, I think this is a useful feature to be supported natively. When I get some time, I may issue a PR for zigbee2mqtt to allow a “stop transition” without having to get the current state.

1 Like

Will this work with an ikea tradfri wireless dimmer (new style) and a conbee 2 stick with deconz? If so it’s exactly what I’m looking for…

I can add other remote controls, but you need to provide me the button codes and the corresponding button press. Like:
1002: long press left
1003: long press left release
etc.

And I need some time to code it and you need to be my tester as I dom’t own any of these remotes.

thank you, I’ll get you the codes shortly and as for the time, you have all the time you want… you are doing this out of the kindness of your heart and I greatly appretiate that so will never chase you ;-)… being a tester… gladly, if you are going to the time and effort to make this work, testing and feeding back is the least I could do for you :slight_smile:

in advance, Thank you

Hi, my apologies for the delay. the code are as follows

Short press on - 1002
long press on - 1001
long press on release - 1003

short press off - 2002
long press off - 2001
long press off release - 2003

in this switch there are only two buttons “on” & “off” and wile playing around to find all the codes these are all i could generate.

hope this helps and thank you for your time and help.

Robin

That’s perfect. Shouldn’t be a problem to integrate this. I’m going to provide you with something to test very soon

1 Like

I have something ready for you to test :slightly_smiling_face: Did you manage to install AppDaemon yet?

1 Like

Thank you :grinning: what’s the easiest way for you to send it over?

I managed to get it installed but when I try to open the web UI I get connection refused, haven’t found the cause yet but I’ve been out all day today and still out now,so will try again tomorrow night.

I’ll send you a PM with the code and some instructions tomorrow.