4
4
import pathlib
5
5
6
6
import click
7
- from zigpy .ota .image import ElementTagId , parse_ota_image
7
+ from zigpy .ota .image import ElementTagId , HueSBLOTAImage , parse_ota_image
8
8
from zigpy .ota .validators import validate_ota_image
9
9
10
10
from zigpy_cli .cli import cli
@@ -33,8 +33,12 @@ def info(files):
33
33
if rest :
34
34
LOGGER .warning ("Image has trailing data %s: %r" , f , rest )
35
35
36
+ print (f )
37
+ print (f"Type: { type (image )} " )
36
38
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 )} " )
38
42
39
43
try :
40
44
result = validate_ota_image (image )
@@ -52,9 +56,12 @@ def info(files):
52
56
def dump_firmware (input , output ):
53
57
image , _ = parse_ota_image (input .read ())
54
58
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 )
59
61
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