Skip to content

Commit

Permalink
fix: Ignore cache when re-interviewing device (#23328)
Browse files Browse the repository at this point in the history
* fix: Ignore cache when re-interviewing device

* updates
  • Loading branch information
Koenkk authored Jul 12, 2024
1 parent 00661fa commit e3fa0bf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions lib/extension/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -534,14 +534,16 @@ export default class Bridge extends Extension {
logger.info(`Interviewing '${device.name}'`);

try {
await device.zh.interview();
await device.zh.interview(true);
logger.info(`Successfully interviewed '${device.name}'`);
} catch (error) {
throw new Error(`interview of '${device.name}' (${device.ieeeAddr}) failed: ${error}`, {cause: error});
}

// publish devices so that the front-end has up-to-date info.
await this.publishDevices();
// A re-interview can for example result in a different modelId, therefore reconsider the definition.
await device.resolveDefinition(true);
this.eventBus.emitDevicesChanged();
this.eventBus.emitExposesChanged({device});

return utils.getResponse(message, {id: message.id}, null);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/model/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export default class Device {
}
}

async resolveDefinition(): Promise<void> {
if (!this.zh.interviewing && (!this.definition || this._definitionModelID !== this.zh.modelID)) {
async resolveDefinition(ignoreCache = false): Promise<void> {
if (!this.zh.interviewing && (!this.definition || this._definitionModelID !== this.zh.modelID || ignoreCache)) {
this.definition = await zhc.findByDevice(this.zh, true);
this._definitionModelID = this.zh.modelID;
}
Expand Down

0 comments on commit e3fa0bf

Please sign in to comment.