mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-08-28 05:24:29 +00:00
Respond with ABORT when device checks for OTA. https://github.com/Koenkk/zigbee2mqtt/issues/3019
This commit is contained in:
@@ -20,7 +20,8 @@ class OTAUpdate extends BaseExtension {
|
||||
async onZigbeeEvent(type, data, mappedDevice, settingsDevice) {
|
||||
if (data.type !== 'commandQueryNextImageRequest') return;
|
||||
|
||||
if (mappedDevice.hasOwnProperty('ota')) {
|
||||
const supportsOTA = mappedDevice.hasOwnProperty('ota');
|
||||
if (supportsOTA) {
|
||||
// When a device does a next image request, it will usually do it a few times after each other
|
||||
// with only 10 - 60 seconds inbetween. It doesn' make sense to check for a new update
|
||||
// each time.
|
||||
@@ -37,11 +38,13 @@ class OTAUpdate extends BaseExtension {
|
||||
logger.info(message);
|
||||
this.mqtt.log('ota_update', message, {status: 'available', device: settingsDevice.friendly_name});
|
||||
}
|
||||
} else {
|
||||
// In case we don't support OTA for this device, response with status 0x98 (= NO_IMAGE_AVAILABLE)
|
||||
const endpoint = data.device.endpoints.find((e) => e.supportsOutputCluster('genOta'));
|
||||
await endpoint.commandResponse('genOta', 'queryNextImageResponse', {status: 0x98});
|
||||
}
|
||||
|
||||
// Respond to the OTA request:
|
||||
// - In case we don't support OTA: respond with NO_IMAGE_AVAILABLE (0x98) (so the client stops requesting OTAs)
|
||||
// - In case we do support OTA: respond with ABORT (0x95) as we don't want to update now.
|
||||
const endpoint = data.device.endpoints.find((e) => e.supportsOutputCluster('genOta'));
|
||||
await endpoint.commandResponse('genOta', 'queryNextImageResponse', {status: supportsOTA ? 0x95 : 0x98});
|
||||
}
|
||||
|
||||
async readSoftwareBuildIDAndDateCode(device, update) {
|
||||
|
||||
@@ -174,7 +174,9 @@ describe('OTA update', () => {
|
||||
await flushPromises();
|
||||
expect(mapped.ota.isUpdateAvailable).toHaveBeenCalledTimes(1);
|
||||
expect(mapped.ota.isUpdateAvailable).toHaveBeenCalledWith(device, logger, {"imageType": 12382});
|
||||
expect(logger.info).toHaveBeenCalledWith(`Update available for 'bulb'`)
|
||||
expect(logger.info).toHaveBeenCalledWith(`Update available for 'bulb'`);
|
||||
expect(device.endpoints[0].commandResponse).toHaveBeenCalledTimes(1);
|
||||
expect(device.endpoints[0].commandResponse).toHaveBeenCalledWith("genOta", "queryNextImageResponse", {"status": 0x95});
|
||||
|
||||
// Should not request again when device asks again after a short time
|
||||
await zigbeeHerdsman.events.message(payload);
|
||||
|
||||
Reference in New Issue
Block a user