I had a hard time finding documentation for using the Hue dimmer switch as a Home Assistant switch, so thought I’d document here. A lot of the posts are about the now-deprecated code here. This does not use that github repo at all and instead only uses the official Hue integration
Update: As of 2012.12 HA release, the hue_event data coming from a switch has changed. This is the new instructions with the original below that.
- Add the dimmer switch in the Hue app as an accessory. Name it. Don’t associate it with any Hue lights (unless that is how you want it to work)
- Assuming you already have the official Hue integration running, I had to restart Home Assistant to get the switch to show up.
- Once you’ve restarted HA, you’ll know it is working because you’ll see a battery sensor for the new switch in the entity list, but nothing else about the switch.
- In Developer Tools → Events → create a listener for “hue_event”.
- Press a button on the hue switch.
- The events listener will show you the “id” (entity name) and “type” (“initial_press” usually. They seem to have a short_press as well) and “subtype” (1 for the top dimmer button. 4 for the bottom “off” dimmer button). Note these.
- Create an automation (i just used the UI) with type “Event”, put “hue_event” in as the event name, and then in event data put “id: your_id_from_the_listener”, and on a new line, “type: initial_press”, then another new line and subtype: 1 (for on button)
Previous to 2021.12
- Add the dimmer switch in the Hue app as an accessory. Name it. Don’t associate it with any Hue lights (unless that is how you want it to work)
- Assuming you already have the official Hue integration running, I had to restart Home Assistant to get the switch to show up.
- Once you’ve restarted HA, you’ll know it is working because you’ll see a battery sensor for the new switch in the entity list, but nothing else about the switch.
- In Developer Tools → Events → create a listener for “hue_event”.
- Press a button on the hue switch.
- The events listener will show you the “id” (entity name) and “event” (code for button you pressed. Note these. I bet “on” is always 1002 and “off” is always 1004.
- Create an automation (i just used the UI) with type “Event”, put “hue_event” in as the event name, and then in event data put “id: your_id_from_the_listener”, and on a new line, “event: 1002” (for on button)