zigpy / zigpy-cli

Command line interface for zigpy
GNU General Public License v3.0
44 stars 12 forks source link

OTA command failing with HueSBLOTAImage #22

Closed TheJulianJES closed 1 year ago

TheJulianJES commented 1 year ago

Running the following command produces an error, as zigpy's HueSBLOTAImage does not have (valid) subelements: zigpy-cli ota info LivingColors-Atmel-Target_0012.sbl-ota

Download link for the OTA image: https://otau.meethue.com/storage/ZGB_100B_0108/55fb9cf3-afb6-4ef5-8887-905699da7ee8/LivingColors-Atmel-Target_0012.sbl-ota

The error is caused here when printing the number of subelements: https://github.com/zigpy/zigpy-cli/blob/62aa9c98a043091b3af88e787cede851ebe1ac48/zigpy_cli/ota.py#L37

Command output:

Header: OTAImageHeader(upgrade_file_id=200208670, header_version=256, header_length=56, field_control=<FieldControl.0: 0>, manufacturer_id=4107, image_type=264, file_version=1124099330, stack_version=2, header_string='', image_size=256696, *device_specific_file=False, *hardware_versions_present=False, *key=ImageKey(manufacturer_id=4107, image_type=264), *security_credential_version_present=False)
Traceback (most recent call last):
  File "/Users/test/GP/zigpy-cli/venv/bin/zigpy", line 33, in <module>
    sys.exit(load_entry_point('zigpy-cli==0.0.1', 'console_scripts', 'zigpy')())
  File "/Users/test/GP/zigpy-cli/venv/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/Users/test/GP/zigpy-cli/venv/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/Users/test/GP/zigpy-cli/venv/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/test/GP/zigpy-cli/venv/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/test/GP/zigpy-cli/venv/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/test/GP/zigpy-cli/venv/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/Users/test/GP/zigpy-cli/venv/lib/python3.10/site-packages/zigpy_cli/ota.py", line 37, in info
    print(f"Number of subelements: {len(image.subelements)}")
AttributeError: 'HueSBLOTAImage' object has no attribute 'subelements'
puddly commented 1 year ago

I think this may also be a bug with zigpy itself. The image validation code expects subelements.