Hue Dimmer with deconz - toggle scenes with "on" button

I have connected some Hue lamps and their corrosponding dimmer to HA via deconz. I have used the below appdaemon app for it:

import appdaemon.plugins.hass.hassapi as hass

class RemoteControl(hass.Hass):

    def initialize(self):
        if 'event' in self.args:
            self.listen_event(self.handle_event, self.args['event'])

    def handle_event(self, event_name, data, kwargs):
        if data['id'] == self.args['id']:
            self.log(data['event'])
            if data['event'] == 1002:
                self.log('Button on')
                self.turn_on(self.args["lightID"])
            elif data['event'] == 2002:
                self.log('Button dim up')
                self.new_brightness = self.get_state(self.args["lightID"], attribute = "brightness") + 25
                if self.new_brightness >= 255:
                  self.new_brightness = 255
                self.turn_on(self.args["lightID"], brightness = self.new_brightness)
            elif data['event'] == 3002:
                self.log('Button dim down')
                self.new_brightness = self.get_state(self.args["lightID"], attribute = "brightness") -25
                if self.new_brightness <= 0:
                  self.new_brightness = 25
                self.turn_on(self.args["lightID"], brightness = self.new_brightness)
            elif data['event'] == 4002:
                self.log('Button off')
                self.turn_off(self.args["lightID"])

That basically means that I can turn on the lamp via the dimmer and dim it up/down and shut it off. I am however missing the original functionality of the dimmer to change the color temperature when toggling the “on” button. Is it somehow possible to modify the turn on (1002 event) so that it just toggles between 3 different color temperatures - fx. 200,300,400? Or alternatively call 3 different scenes.

You could try to save the timestamp when a button was pressed and a counter for how many times the button was pressed but I’m not sure if this will work out due to timing issues.

The other thing you could do would be to use long press of the 4 buttons and define different scenes for each button.

1 Like

I went for the long press it works fine - expect that i need to long press “off” to get a certain color temperature which is a little counter intuitive :slight_smile: