This commit is contained in:
Koen Kanters
2020-09-15 22:13:30 +02:00
parent 6234e2f40e
commit 8db16cca3d
5 changed files with 10 additions and 3 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ const allowedEvents = [
'stateChange', // Entity changes its state
'groupMembersChanged', // Members of a group has been changed
'reportingDisabled', // Reporting is disabled for a device
'deviceBindingsChanged', // Device bindings changed
'devicesChanged', // Devices changed
];
class EventBus extends events.EventEmitter {
+1 -1
View File
@@ -158,7 +158,7 @@ class Bind extends Extension {
if (error) {
logger.error(error);
} else {
this.eventBus.emit(`deviceBindingsChanged`);
this.eventBus.emit(`devicesChanged`);
}
}
}
+1 -1
View File
@@ -41,7 +41,7 @@ class Bridge extends Extension {
this.coordinatorVersion = await this.zigbee.getCoordinatorVersion();
this.eventBus.on(`groupMembersChanged`, () => this.publishGroups());
this.eventBus.on(`deviceBindingsChanged`, () => this.publishDevices());
this.eventBus.on(`devicesChanged`, () => this.publishDevices());
this.mqtt.subscribe(`${settings.get().mqtt.base_topic}/bridge/request/#`);
await this.publishInfo();
await this.publishDevices();
+1
View File
@@ -238,6 +238,7 @@ class OTAUpdate extends Extension {
this.publishEntityState(resolvedEntity.device.ieeeAddr, payload);
responseData.from = from_ ? utils.toSnakeCase(from_) : null;
responseData.to = to ? utils.toSnakeCase(to) : null;
this.eventBus.emit(`devicesChanged`);
/* istanbul ignore else */
if (settings.get().advanced.legacy_api) {
+6
View File
@@ -83,6 +83,12 @@ describe('OTA update', () => {
stringify({"data":{"id": "bulb","from":{"software_build_id":1,"date_code":"20190101"},"to":{"software_build_id":2,"date_code":"20190102"}},"status":"ok"}),
{retain: false, qos: 0}, expect.any(Function)
);
expect(MQTT.publish).toHaveBeenCalledWith(
'zigbee2mqtt/bridge/devices',
expect.any(String),
{ retain: true, qos: 0 },
expect.any(Function)
);
});
it('Should handle when OTA update fails', async () => {