@@ -150,30 +150,28 @@ export default class OTAUpdate extends Extension {
150150 const deviceLastChecked = this . #lastChecked. get ( data . device . ieeeAddr ) ;
151151 const check = deviceLastChecked !== undefined ? Date . now ( ) - deviceLastChecked > updateCheckInterval : true ;
152152
153- if ( ! check ) {
154- return ;
155- }
156-
157- this . #inProgress. add ( data . device . ieeeAddr ) ;
158- this . #lastChecked. set ( data . device . ieeeAddr , Date . now ( ) ) ;
159- let availableResult : OtaUpdateAvailableResult | undefined ;
153+ if ( check ) {
154+ this . #inProgress. add ( data . device . ieeeAddr ) ;
155+ this . #lastChecked. set ( data . device . ieeeAddr , Date . now ( ) ) ;
156+ let availableResult : OtaUpdateAvailableResult | undefined ;
160157
161- try {
162- // auto-check defaults to zigbee-OTA + potential local index, and never `downgrade`
163- availableResult = await data . device . zh . checkOta (
164- { downgrade : false } ,
165- data . data as Zcl . ClustersTypes . TClusterCommandPayload < "genOta" , "queryNextImageRequest" > ,
166- data . device . otaExtraMetas ,
167- data . endpoint ,
168- ) ;
169- } catch ( error ) {
170- logger . debug ( `Failed to check if OTA update available for '${ data . device . name } ' (${ error } )` ) ;
171- }
158+ try {
159+ // auto-check defaults to zigbee-OTA + potential local index, and never `downgrade`
160+ availableResult = await data . device . zh . checkOta (
161+ { downgrade : false } ,
162+ data . data as Zcl . ClustersTypes . TClusterCommandPayload < "genOta" , "queryNextImageRequest" > ,
163+ data . device . otaExtraMetas ,
164+ data . endpoint ,
165+ ) ;
166+ } catch ( error ) {
167+ logger . debug ( `Failed to check if OTA update available for '${ data . device . name } ' (${ error } )` ) ;
168+ }
172169
173- await this . publishEntityState ( data . device , this . #getEntityPublishPayload( data . device , availableResult ?? "idle" ) ) ;
170+ await this . publishEntityState ( data . device , this . #getEntityPublishPayload( data . device , availableResult ?? "idle" ) ) ;
174171
175- if ( availableResult ?. available ) {
176- logger . info ( `OTA update available for '${ data . device . name } '` ) ;
172+ if ( availableResult ?. available ) {
173+ logger . info ( `OTA update available for '${ data . device . name } '` ) ;
174+ }
177175 }
178176 }
179177 }
0 commit comments