diff --git a/lib/extension/bridge.js b/lib/extension/bridge.js index 3c0573e5..9ee5c0a9 100644 --- a/lib/extension/bridge.js +++ b/lib/extension/bridge.js @@ -143,8 +143,8 @@ class Bridge extends Extension { ); } - if ('deviceLeave' === type || ('deviceInterview' === type && data.status !== 'started') || - 'deviceNetworkAddressChanged' === type) { + if (['deviceLeave', 'deviceInterview', 'deviceNetworkAddressChanged', + 'deviceJoined', 'deviceAnnounce'].includes(type)) { await this.publishDevices(); } } diff --git a/test/bridge.test.js b/test/bridge.test.js index e6def8cb..b695049b 100644 --- a/test/bridge.test.js +++ b/test/bridge.test.js @@ -139,7 +139,7 @@ describe('Bridge', () => { MQTT.publish.mockClear(); await zigbeeHerdsman.events.deviceAnnounce({device: zigbeeHerdsman.devices.bulb}); await flushPromises(); - expect(MQTT.publish).toHaveBeenCalledTimes(1); + expect(MQTT.publish).toHaveBeenCalledTimes(2); expect(MQTT.publish).toHaveBeenCalledWith( 'zigbee2mqtt/bridge/event', stringify({"type":"device_announce","data":{"friendly_name":"bulb","ieee_address":"0x000b57fffec6a5b2"}}), @@ -152,7 +152,7 @@ describe('Bridge', () => { MQTT.publish.mockClear(); await zigbeeHerdsman.events.deviceInterview({device: zigbeeHerdsman.devices.bulb, status: 'started'}); await flushPromises(); - expect(MQTT.publish).toHaveBeenCalledTimes(1); + expect(MQTT.publish).toHaveBeenCalledTimes(2); expect(MQTT.publish).toHaveBeenCalledWith( 'zigbee2mqtt/bridge/event', stringify({"type":"device_interview","data":{"friendly_name":"bulb","status":"started","ieee_address":"0x000b57fffec6a5b2"}}),