44import pathlib
55
66import click
7- from zigpy .ota .image import ElementTagId , parse_ota_image
7+ from zigpy .ota .image import ElementTagId , HueSBLOTAImage , parse_ota_image
88from zigpy .ota .validators import validate_ota_image
99
1010from zigpy_cli .cli import cli
@@ -33,8 +33,12 @@ def info(files):
3333 if rest :
3434 LOGGER .warning ("Image has trailing data %s: %r" , f , rest )
3535
36+ print (f )
37+ print (f"Type: { type (image )} " )
3638 print (f"Header: { image .header } " )
37- print (f"Number of subelements: { len (image .subelements )} " )
39+
40+ if hasattr (image , "subelements" ):
41+ print (f"Number of subelements: { len (image .subelements )} " )
3842
3943 try :
4044 result = validate_ota_image (image )
@@ -52,9 +56,12 @@ def info(files):
5256def dump_firmware (input , output ):
5357 image , _ = parse_ota_image (input .read ())
5458
55- for subelement in image .subelements :
56- if subelement .tag_id == ElementTagId .UPGRADE_IMAGE :
57- output .write (subelement .data )
58- break
59+ if isinstance (image , HueSBLOTAImage ):
60+ output .write (image .data )
5961 else :
60- LOGGER .warning ("Image has no UPGRADE_IMAGE subelements" )
62+ for subelement in image .subelements :
63+ if subelement .tag_id == ElementTagId .UPGRADE_IMAGE :
64+ output .write (subelement .data )
65+ break
66+ else :
67+ LOGGER .warning ("Image has no UPGRADE_IMAGE subelements" )
0 commit comments