Upgrading Hue dimmer with ZHA OTA

It makes sense, and it is a shame that Hue does not publicly release Otas.

But until it does, I really think it makes sense to update the documentation with that part concerning making the service calls etc.

And even if a clever guy could automate the step of pulling the newest available hue firmwares and make the service call for you, that would be a great QoL improvement. Even if some of the Hue bulbs can ask for themselves, I assume it leaves out a lot.

1 Like

Can’t do it with Philips Hue SML002 Outdoor PIR
I’m receiving some weird errors from zigpy.ota.provider
File is downloaded to OTA folder
Firmware for SML002 is same that’s used for SML001


http://fds.dc1.philips.com/firmware/ZGB_100B_010D/1107323831/Sensor-ATmega_6.1.1.27575_0012.sbl-ota

BTW IKEA bulbs has been updated without problems, also from OTA folder.
Their servers provide bad responses for direct web update

2020-11-17 15:06:58 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0x3E01](SML002): Issued cluster command: cluster_id: 25 command: 0 command_type: client args: (0, 100) cluster_id: out manufacturer: 4107 endpoint_id: 2
2020-11-17 15:06:58 DEBUG (MainThread) [homeassistant.components.zha.api] Issued command for: cluster_id: [25] cluster_type: [out] endpoint_id: [2] command: [0] command_type: [client] args: [0, 100] manufacturer: [4107] response: EmberStatus.SUCCESS
2020-11-17 15:06:58 DEBUG (MainThread) [zigpy.zdo] [0x3e01:zdo] ZDO request ZDOCmd.IEEE_addr_req: [0x0000, 0, 0]
2020-11-17 15:06:59 DEBUG (MainThread) [zigpy.zcl] [0x3e01:2:0x0019] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=CLUSTER_COMMAND manufacturer_specific=False is_reply=False disable_default_response=False> manufacturer=None tsn=74 command_id=1>
2020-11-17 15:06:59 DEBUG (MainThread) [zigpy.zcl] [0x3e01:2:0x0019] ZCL request 0x0001: [0, 4107, 269, 1107321517, None]
2020-11-17 15:06:59 DEBUG (MainThread) [zigpy.zcl] [0x3e01:2:0x0019] OTA query_next_image handler for 'Philips SML002': field_control=0, manufacture_id=4107, image_type=269, current_file_version=1107321517, hardware_version=None
2020-11-17 15:06:59 DEBUG (SyncWorker_5) [zigpy.ota.provider] Couldn't load '/config/ota/Sensor-ATmega_6.1.1.27575_0012.sbl-ota' OTA image
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/zigpy/ota/provider.py", line 335, in _fetch_image
img = OTAImage.deserialize(data[offset:])[0]
File "/usr/local/lib/python3.8/site-packages/zigpy/ota/image.py", line 158, in deserialize
element, element_data = SubElement.deserialize(element_data)
File "/usr/local/lib/python3.8/site-packages/zigpy/ota/image.py", line 131, in deserialize
raise ValueError("Data is too short for {}".format(cls.__name__))
ValueError: Data is too short for SubElement
2020-11-17 15:06:59 DEBUG (MainThread) [zigpy.zcl] [0x3e01:2:0x0019] No OTA image is available

Yeah, some images from Philips Hue are marked as “invalid” by zigpy. (The images don’t follow any spec really). (Mostly the case with end devices: remotes, sensors, …) One of the devs was already talking about how there could be a special case or just some validation stripped out or something. At the moment, you could try updating it with deCONZ or zigbee2mqtt (or just use the Hue Bridge if you have one).

1 Like

Probably better would be to buy Conbee2 instead of Hue Bridge for one sensor.
I’m using IKEA white bulbs and Sonoff SNZB’s
My gate is Sonoff ZBBridge programmed to newest Tasmota - works great, BTW.

Thank you for sharing. This worked for my LWB014 Bulbs. The instructions are great.

Doesn’t work for my RWL020 Hue dimmer switch, but as you indicated, this is because the format of the OTA file isn’t currently handled by zigpy.

Edit: Looks like updating RWL020 will be possible soon once zigpy incorporates this merge request: https://github.com/zigpy/zigpy/pull/597

Edit 2: I manually merged the changes and now my RWL020 was successfully upgraded OTA!

2 Likes

@juched OT, but on a Blueprint thread (ZHA - Philips Hue Dimmer Switch (individual buttons with long presses)) for the Hue Dimmer, I am in a bit of a confusing situation you may have better insight on. The author has a zha_event for the dimmer that has long-release/hold functionality. My “new” Hue remote does, too. My three old ones do not and have a simpler structure (on, off_with_effect, step). The firmware shows 0x420045b6 on ALL four remotes – even though they have different zha_event structures. Device model numbers are all the same, too.

When you’ve upgraded your remotes recently, have you taken a look at the zha_event data for button presses? Trying to sort out if older firmware on these is actually more featureful or not.

The “new events” come from a ZHA quirk.
Please open an issue on zha-device-handlers (zha-quirks repo) and post both signatures (old and new ones from the dimmer switches).

Interesting! So based on that I went ahead and performed a Zigbee Remove and then used the remote setup button to add it again. Now at least my first “old” remote is showing the extra button meta data. So seems that because my devices had been paired prior to some quirks update, it never leveraged the new functionality? Will try my last two remotes, but this seems very promising. Thanks, @TheJulianJES!

It should do it fine without requiring a re-pair. Can you post the signatures of the dimmer switch here maybe?

I actually looked at my new remote vs. my three existing remotes and the Zigbee signature details were 1-for-1 the same content. I’ve now successfully removed and re-setup all three remotes and they each work as desired with the complete meta data I was missing prior. I’ve probably had this HA setup for 2.5-3 years now and those remotes have always existed, so a little unsure what else to narrow down since they work after a re-add perfectly.

Here’s a signature, though:

{
  "node_descriptor": "NodeDescriptor(byte1=2, byte2=64, mac_capability_flags=128, manufacturer_code=4107, maximum_buffer_size=71, maximum_incoming_transfer_size=45, server_mask=0, maximum_outgoing_transfer_size=45, descriptor_capability_field=0)",
  "endpoints": {
    "1": {
      "profile_id": 49246,
      "device_type": "0x0830",
      "in_clusters": [
        "0x0000"
      ],
      "out_clusters": [
        "0x0000",
        "0x0003",
        "0x0004",
        "0x0005",
        "0x0006",
        "0x0008"
      ]
    },
    "2": {
      "profile_id": 260,
      "device_type": "0x000c",
      "in_clusters": [
        "0x0000",
        "0x0001",
        "0x0003",
        "0x000f",
        "0xfc00"
      ],
      "out_clusters": [
        "0x0019"
      ]
    }
  },
  "manufacturer": "Philips",
  "model": "RWL020",
  "class": "zhaquirks.philips.rwl021.PhilipsRWL021"
}

Thanks. It seems ok. Since each quirk matches at startup (and doesn’t save to which device it belongs to), it checks each signature every start and normally that shouldn’t require re-pairing. Good that it works now at least.

You, sir, are a badass.

Should look like this (note indentation) e.g.

service: zha.issue_zigbee_cluster_command
data:
  ieee: 'xx:xx:xx:xx:xx:xx:xx:xx'
  endpoint_id: 11
  cluster_id: 25
  cluster_type: out
  command: 0
  command_type: client
  args:
    - 0
    - 100

Just upgraded my pair of Philips Hue Play Light Bar LCT024. Got the image from above github link.

One identified as: Philips LCT024 Play Light Bar - this seems to want image type 273
The second one identified as: Philips 440400982841 :man_shrugging: which seems to want image type 270

Not all Hues are made equally, it would seem.

@Adminiuga - can confirm this update procedure works for the Philips Hue stuff - at least for what I own. Perhaps the above command can be triggered occasionally for Philips Hue lamps detected in ZHA HA installs, if Philips Hue (4107 = 0x100B) images are detected in the OTA folder.

4 Likes

I issue the command

service: zha.issue_zigbee_cluster_command
data:
ieee: ‘xx:xx:xx:xx:xx:xx:xx:xx’
endpoint_id: 11
cluster_id: 25
cluster_type: out
command: 0
command_type: client
args:
- 0
- 100

and I get this error

2021-04-18 08:58:57 ERROR (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Error executing script. Unexpected error for call_service at pos 1: 11
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 359, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 559, in _async_call_service_step
    await service_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1480, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1515, in _execute_service
    await handler.job.target(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 719, in admin_handler
    await result
  File "/usr/src/homeassistant/homeassistant/components/zha/api.py", line 1002, in issue_zigbee_cluster_command
    response = await zha_device.issue_cluster_command(
  File "/usr/src/homeassistant/homeassistant/components/zha/core/device.py", line 593, in issue_cluster_command
    cluster = self.async_get_cluster(endpoint_id, cluster_id, cluster_type)
  File "/usr/src/homeassistant/homeassistant/components/zha/core/device.py", line 519, in async_get_cluster
    return clusters[endpoint_id][cluster_type][cluster_id]
KeyError: 11
2021-04-18 08:58:57 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [281472532831680] Error handling message: Unknown error
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 18, in _handle_async_response
    await func(hass, connection, msg)
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 439, in handle_execute_script
    await script_obj.async_run(context=context)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1200, in async_run
    await asyncio.shield(run.async_run())
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 341, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 359, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 559, in _async_call_service_step
    await service_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1480, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1515, in _execute_service
    await handler.job.target(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 719, in admin_handler
    await result
  File "/usr/src/homeassistant/homeassistant/components/zha/api.py", line 1002, in issue_zigbee_cluster_command
    response = await zha_device.issue_cluster_command(
  File "/usr/src/homeassistant/homeassistant/components/zha/core/device.py", line 593, in issue_cluster_command
    cluster = self.async_get_cluster(endpoint_id, cluster_id, cluster_type)
  File "/usr/src/homeassistant/homeassistant/components/zha/core/device.py", line 519, in async_get_cluster
    return clusters[endpoint_id][cluster_type][cluster_id]
KeyError: 11

probably missing step…

I ran a diff between mine and @mstanislav’s mine says:

“class”: “zhaquirks.philips.rwlfirstgen.PhilipsRWLFirstGen”

and I don’t have the following in my node_descriptor.

, *allocate_address=True, *complex_descriptor_available=False, *is_alternate_pan_coordinator=False, *is_coordinator=False, *is_end_device=True, *is_full_function_device=False, *is_mains_powered=False, *is_receiver_on_when_idle=False, *is_router=False, *is_security_capable=False, *is_valid=True, *logical_type=<LogicalType.EndDevice: 2>, *user_descriptor_available=False)",

and I do have the ota dir… I downloaded the files

➜  ~ cd /config/zha_ota
➜  zha_ota ls -la -d "$PWD/"*
-rw-r--r--    1 root     root        256632 Jan 20  2020 /config/zha_ota/ModuLum-ATmega_010B_5.130.1.30000_0012.sbl-ota
-rw-r--r--    1 root     root         69694 Apr 16 23:13 /config/zha_ota/index.json

and conf of course

➜  zha_ota tail -5 /config/configuration.yaml
  zigpy_config:
    ota:
      ikea_provider: true
      ledvance_provider: true
      otau_directory: /config/zha_ota

not sure what i’m missing

For the Hue dimmer, change endpoint_id from 11 to 2.
"class”: “zhaquirks.philips.rwlfirstgen.PhilipsRWLFirstGen” is just the new quirk name.

@TheJulianJES I was hitting the same error with my remote as @kdzoha so I tried changing the endpoint to 2 as you suggested. Calling the service no longer errors but I am also not seeing anything in my logs related to the OTA even though I have this in my configuration.yaml:

logger:
  default: info
  logs:
    zigpy.ota: debug

Any idea what I might be missing?

Sorry for the late reply, I somehow missed this.
If you still have the issue, try the following:

  1. Make sure all debug logging related to Home Assistant is on: Zigbee Home Automation - Home Assistant
  2. Immediately after executing the service, press a button on the dimmer, so that it can wake up from sleep.

Hi @systemcrash,
I have a play bar that has been acting odd in ZHA for a while now… Its my only Hue device…No colour control, and it doesnt report on/off status back most of the time. Tried repairing, removing other devices from my zigbee mesh, now wondering if a firmware upgrade will help.

Could you outline all steps required to do this? I can see I have the one that reports model 440400982841 in its device signature.

Not sure what files I need top download etc… is it just the index.json?

Thanks!!

Hello Everybody!

Could anybody help me on Hue update processes?

I tried to update my LTC002 lamp, and RLW021 switch but without success. I set up all debug options, I used endpoint_id: 11 for the lamp and 2 for the switch but I always get…


…error immediately after I call the message.

Details of the error:

2022-04-24 11:32:46 DEBUG (MainThread) [zigpy_znp.api] Received command: AF.IncomingMsg.Callback(GroupId=0x0000, ClusterId=25, SrcAddr=0x06D2, SrcEndpoint=11, DstEndpoint=1, WasBroadcast=<Bool.false: 0>, LQI=51, SecurityUse=<Bool.false: 0>, TimeStamp=3563494, TSN=0, Data=b'\x01\x24\x03\x02\x0B\x10\x0E\x01\x00\x1F\x00\x01\x00\x00\x00\x00\x40\x00\x00', MacSrcAddr=0x06D2, MsgResultRadius=29)
2022-04-24 11:32:46 DEBUG (MainThread) [zigpy.zcl] [0x06D2:11:0x0019] Received ZCL frame: b'\x01\x24\x03\x02\x0B\x10\x0E\x01\x00\x1F\x00\x01\x00\x00\x00\x00\x40\x00\x00'
2022-04-24 11:32:46 DEBUG (MainThread) [zigpy.zcl] [0x06D2:11:0x0019] Decoded ZCL frame header: ZCLHeader(frame_control=FrameControl(frame_type=<FrameType.CLUSTER_COMMAND: 1>, is_manufacturer_specific=0, is_reply=0, disable_default_response=0, reserved=0, *is_cluster=True, *is_general=False), tsn=36, command_id=3, *is_reply=False)
2022-04-24 11:32:46 ERROR (MainThread) [zigpy.device] Failed to parse message (b'012403020b100e01001f000100000000400000') on cluster 25, because Data is too short to contain 1 bytes

Any clue on it?

Will be fixed once Implement OTA frame control fields by puddly · Pull Request #961 · zigpy/zigpy · GitHub makes it into Home Assistant.

2 Likes

Ahhh, so the update process does not totally work yet?! Sorry I did not get it. No problem, in this case I will wait for it, or try the zigpy:dev, or the PR.

Lot of thanks for your fast response!