Accessing Philips Hue Bulb/Sensor Configuration With ZHA Integration?

What’s the preferred method for reading/writing the configuration options for Philips Hue products when using the Home Assistant ZHA integration?

The API is defined at, and I see how others are using deConz to access the settings, such as at the end of this thread: deConz + Hue motion sensor - adjust senisitivity

The configuration options I’m most interested in are:

Hue Bulbs:

  • startup (object):
    • mode (attribute in object): controls bulb behavior after power failure; values are safety, powerfail, lastonstate, custom; default appears to be safety in my experience

Hue Motion Sensor:

  • ledindication (bool): controls whether the red LED lights up when motion is detected or not
  • sensitivitymax (int, readonly): the maximum integer value for the sensitivity option
  • sensitivity (int): motion detector sensitivity (0…sensitivitymax)

I currently have a mixture of Hue bulbs connected to the Hue Bridge and some Hue bulbs connected directly to a ConBee II controller to help strengthen my Zigbee mesh.

I realized the other day that I think the only reason I still use the Hue Bridge is that the bulbs connected to the ConBee II have all reverted to their default startup behavior of safety, where they turn on to full brightness when power is reapplied after a power failure. This option is configurable in the Hue app, but the bulb does not retain this setting when removed via the Hue app or when reset via the Hue Remote method. From what I understand, one of those two options is necessary when connecting a Hue bulb to a ConBee II if it’s previously been connected to a Hue Bridge.

The default safety startup behavior is annoying but workable in most areas of my home, but not acceptable for my bedroom. If the power has a momentary hiccup in the middle of the night, my bedroom becomes noon on a sunny day. While I find this super-annoying, the more important factor is that this behavior invokes spousal comments of our previous dumb home being preferable to the new sorta-smart home and how perhaps HA should be uninstalled. Thus, I still use the Hue Bridge for the bedroom lights because I want the lights configured to powerfail, where they retain their previous state.

I’d also like to be able to turn off the red LEDs on the motion sensor when they detect motion, as well as adjust the sensitivity in a few locations, but that’s a little less critical than the lights’ power-on behavior.

Anyone have this functionality working with the ZHA integration?

1 Like

After updating to 0.112.2 today, I was poking around the new Zigbee device UI and I saw the Manage Clusters option. That motivated me to learn a little more about communication with Zigbee devices and I found some threads that helped a bunch (listed at bottom).

It seems the attributes necessary to control Hue device behavior are fairly well-documented, but they just aren’t available in the Home Assistant ZHA integration yet.

For example, if I go to the Home Assistant device page for one of my Hue lights and click on the Manage Clusters link, I can see a cluster list at the top that includes “OnOff (Endpoint id 11, Id: 0x0006, Type: in)” However, there are only 4 attributes listed (0x4000, 0x4002, 0x0000, and 0x4001), and The PowerOn OnOff attribute with id 0x4003 is not among them. Similarly, I didn’t see the ledindication attribute available in the motion sensors’ pages.

I found a workaround, though, and since this is a one-time thing (assuming you don’t unpair your devices), it wasn’t too terrible. Here’s what I did, based on the sum of information in the below threads:

Note: Steps 2-5 are likely only necessary if you have color bulbs and want them to retain their color settings across power failures.

  1. Install deConz software. I put it on my Windows (not HA host) box, but other versions are available, too.
  2. Find the deConz general.xml file.
    • Linux: /usr/share/deCONZ/zcl
    • Windows: C:\Users\<username>\AppData\Local\deCONZ\zcl
  3. Add lines to it as specified in the gist:
  4. Uncomment the 2 lines for Hue manufacturer-specific PowerOn X and Y values, as specified in this post:
  5. Comment the 2 lines for generic PowerOn X and Y values, as specified in this post:
  6. Shut down Home Assistant
  7. Transfer ConBee II stick to Windows PC with deConz
  8. Start up deConz and click Connect to connect to the ConBee II
  9. Once I got a map of my Zigbee network, I looked for the devices with yellow color bars, which indicate they are Routers rather than Endpoints. Within the yellow devices, look for Philips devices - they’ll have a manufacturer code of 0x100b
  10. Follow the instructions to set the necessary values in this post:
  • Attributes to set for each Hue Bulb
    • PowerOn On/Off
      • Cluster: 0x0006 (On/Off)
      • Attribute: 0x4003 (PowerOn OnOff)
      • Default Value: On
      • New Value: Previous
    • PowerOn Level
      • Cluster: 0x0008 (Level Control)
      • Attribute: 0x4000 (PowerOn Level)
      • Default Value: 254 (full brightness)
      • New Value: 255 (interpreted as previous state)
  1. This post has info necessary to preserve color settings across power failures:

I believe the above could also be used to add a 4th option to the PowerOn behavior, in addition to the 3 that are available in the Hue app (on, off, previous state). It’s not something I wanted to do right now, but I think those settings would allow you to specify a specific color/brightness for each bulb after a power failure; e.g. turn lights on to red and 25% brightness.

Until the official ZHA integration has the ability to modify these values, this alternative will at least allow folks to update the values with a little extra effort.


1 Like

is there another way to do this? I’m having the same problem but I can’t solve it with deConz because I have a Silicon Labs EmberZNet based adapter (Sonoff ZBBridge).

I want to set my bedrom light to powerfail so it doesn’t blind me after a power outage.

1 Like

In “Manage Clusters” of the ZHA integration device configuration, I’m able to find the mentioned clusters (0x0006, 0x0008) and the attributes ( 0x4003, 0x4000), however, it doesn’t seems to take effect when I update the change the value or manufacturer code override. It kind of seems to remember it’s brightness percent and sometimes color, but it will not turn off it was previously off before the power toggle.

EDIT: It seems I was not correctly using the UI (although it is possible using the UI). I was able to receive help on the discord server and the following service calls seem to work (zha.set_zigbee_cluster_attribute). I made a script where you can enter the ieees of each light and it will run through and configure the power on state for each hue light provided.

EDIT2: Updated script from 65536 to 65535

This was tested on the following Quirk:

#HA Script
  alias: Reconfig Hue Lights OnOff
  icon: mdi:lightbulb-multiple-outline
  - service: python_script.reconfig_onoff_lights
      ieees: ['XX:XX:XX:XX:XX:XX:XX:XX', 'XX:XX:XX:XX:XX:XX:XX:XX']
  - service: notify.notify
      title: Reconfiguring Lights
      message: Lights Reconfigured
#You'll need to enable python scripts in HA
ieees = data.get("ieees")
for ieee in ieees:
  service_data1 = {
        'ieee': ieee,
        'endpoint_id': 11,
        'cluster_id': 6,
        'cluster_type': 'in',
        'attribute': 16387,
        'value': 255 }'zha', 'set_zigbee_cluster_attribute', service_data1, False)
  service_data2 = {
        'ieee': ieee,
        'endpoint_id': 11,
        'cluster_id': 8,
        'cluster_type': 'in',
        'attribute': 16384,
        'value': 255 }'zha', 'set_zigbee_cluster_attribute', service_data2, False)
  service_data3 = {
        'ieee': ieee,
        'endpoint_id': 11,
        'cluster_id': 768,
        'cluster_type': 'in',
        'attribute': 16400,
        'value': 65535 }'zha', 'set_zigbee_cluster_attribute', service_data3, False)
  service_data4 = {
        'ieee': ieee,
        'endpoint_id': 11,
        'cluster_id': 768,
        'cluster_type': 'in',
        'attribute': 3,
        'value': 65535 }'zha', 'set_zigbee_cluster_attribute', service_data4, False)

Thanks for sharing your knowledge @sgobat - would you happen to know how can I set it to "last state”?

Edit: It seems that I have successfully changed to LastState by sending 0xff as the new value through the UI, but the lamp still goes on full brightness and ignoring color.

I couldn’t figure out the UI (maybe you can leave some examples here for others who want to use it). But I noticed that it has to stay in a specific state for a bit of time before it commits it to memory. Try leaving the light off (but powered on) for like 10 minutes and then try a power cycle. Also, make sure all the necessary cluster attributes were set.

If not you could try my script, as I know that it worked for me.

So I managed to get this to work through the ZHA UI, in my case I needed to change these settings to revert to last state on power on:

OnOff cluster 0x0006, PowerOn OnOff attribute 0x4003 → 0xff
Level Control cluster 0x0008, PowerOn Level attribute 0x4000 → 255
Color Control cluster 0x0300, PowerOn Color Temperature → 65535

@sgobat’s script also works perfectly so long as I change 65536 to 65535.

Edit: nevermind. For some reason this only preserves the color on power on. If the lamp was off before power outage it will turn back on.

Edit 2: nevermind the nevermind. What @sgobat said was key:

I noticed that it has to stay in a specific state for a bit of time before it commits it to memory.

If I let the light commit its state (I waited around 3 minutes), then upon Power on from outage the light will restore its state. The above values for each cluster should work, now I only wonder why I have to do 65535 and not 65536…maybe it has to do with the bulb/light’s model? (I have the latest firmware AFAIK)


I think 65535 is correct. I updated my script to reflect that! Thanks!

1 Like

Great to hear that.

I’ve made some modifications to your script that checks these attributes and verifies they have the desired values after the script runs, and if not - write an error log. I saw there are some silent failures and I think it’s important to verify the power on state. I’ll post my version of it once I do some refactoring.

The value is likely a 16-bit number, and the max value for a 16-bit number that starts with 0 is (2^16 - 1), which is 65535 in decimal.

Sometimes programmers will use the largest value in a range (e.g., 255 for an 8-bit number) to indicate special meanings (like last state vs. a specific color). That makes sense in this case, since the max usable color temperature would be well under 60,000.

… and nice script, @sgobat!

Hi @sgobat @erikg @sk229 - do any of you know, if its possible to get the same functionality on ZHA that you have with HUE Bridge, where you can quickly switch on/off twice for 100% and then back to stored brightness?

If you just use the hue bridge, you can configure it using the Hue App I believe

Are you talking about turning the bulb itself off/on with a wall switch? i.e. killing power to the bulb and then restoring it? Or are you talking about turning it off/on with the app?

The customizable power-on behavior (on/off/previous-setting) for when you kill the power to the bulb with a switch/breaker is a function of the bulb itself, not the hub, so it will work with both the Hue hub and with the ZHA integration using a different hub. I’ve tried both with mine.

If you’re interested in having scene-toggling functionality, you can get that with a Hue Switch (e.g., RLW020). By default, the Dim/Brighten/Off buttons work as you’d expect. The On button initially turns the lights on to their previous setting, but if you press it again, it cycles through Relax, Read, Concentrate, and Energize scenes. You can customize this behavior in the Hue app. If you’re using ZHA instead of the Hue bridge/app, you could implement this behavior via automations. I’ve done that in my setup, but with Lutron pico remotes, as they fit into a standard (US) rectangular switch wallplate.

@sgobat , thank you for response.
I have du Hue bridge right now and it works, but would like to ditch that bridge and blue have ZHA network :+1:

Okay nice! I was talking about killing the bulb power. But how do you achieve that behavior then - switching between 100% and last set brightness?

I misunderstood your post, sorry! When you power cycle twice, I think it’s not really setting it to 100% brightness, but maybe just forgets the power/color states and 100% white is the default? With that setting enabled on the hue app or zha, it acts the same way where the lights need some time to “save” the state it is in and if you turn it off and on too quickly, it goes to 100% white

@sgobat, well I actually think you are right in some way, as the bulb cannot get any inputs from the bridge in such a short period of time. But there are indeed to power-on settings then…check my attached video of my bedroom - I power cycle from dimmed > 100% > dimmed…

and it is definitely within the bulb itself and not the bridge, but how do we/I configurer that behavior from ZHA. :thinking:

So I’ve been trying this out. I started to try changing it via gut but didn’t get it to work. I have 20+ hue lamps so the script seemed like a nice solution.

When trying to run it I get error in log like " * [0x465a:11:0x0008] 16384 is not a valid attribute id".

I guess different lamp types have different clusters? which lamp modell did you use it for?

Can there also be a problem if lamps dont have the latest firmware?

Anyone who can direct me to find the latest files for hue lamps?

Thanks in advance!