4
4
from glob import glob
5
5
6
6
import aiohttp
7
+ import zigpy
7
8
8
9
from . import DEFAULT_OTAU
9
10
from . import utils as u
@@ -155,6 +156,25 @@ async def download_sonoff_ota(listener, ota_dir):
155
156
LOGGER .warning ("Exception getting '%s': %s" , url , e )
156
157
157
158
159
+ async def download_zigpy_ota (app , listener ):
160
+ LOGGER .debug ("Zigpy download procedure starting" )
161
+ for _ , (ota , _ ) in app .ota ._listeners .items ():
162
+ if isinstance (ota , zigpy .ota .provider .FileStore ):
163
+ # Skip files provider
164
+ continue
165
+ await ota .refresh_firmware_list ()
166
+ for image_key , image in ota ._cache .items ():
167
+ url = getattr (image , "url" , None )
168
+ LOGGER .error ("Try getting %r, %r, %r" , image_key , url , image )
169
+ try :
170
+ img = await app .ota .get_ota_image (
171
+ image_key .manufacturer_id , image_key .image_type , model = None
172
+ )
173
+ LOGGER .info ("Got image %r" , getattr (img , "header" , None ))
174
+ except Exception as e :
175
+ LOGGER .error ("%r while getting %r - %s" , e , image_key , url )
176
+
177
+
158
178
async def ota_update_images (
159
179
app , listener , ieee , cmd , data , service , params , event_data
160
180
):
@@ -165,20 +185,21 @@ async def ota_update_images(
165
185
async def ota_notify (
166
186
app , listener , ieee , cmd , data , service , params , event_data
167
187
):
188
+ LOGGER .error ("OTA_notify" )
168
189
event_data ["PAR" ] = params
169
190
if params [p .DOWNLOAD ]:
170
- # Download FW from koenkk's list
171
191
if params [p .PATH ]:
172
192
ota_dir = params [p .PATH ]
173
193
else :
174
194
ota_dir = DEFAULT_OTAU
175
195
176
196
LOGGER .debug (
177
- "OTA image download requested - default:%s, effective: %s" ,
178
- DEFAULT_OTAU ,
197
+ "OTA image download to '%s' (Default dir is:'%s')" ,
179
198
ota_dir ,
199
+ DEFAULT_OTAU ,
180
200
)
181
201
202
+ await download_zigpy_ota (app , listener )
182
203
await download_koenkk_ota (listener , ota_dir )
183
204
await download_sonoff_ota (listener , ota_dir )
184
205
0 commit comments