diff --git a/lib/controller.js b/lib/controller.js index 395fb506d..2c0c805ae 100644 --- a/lib/controller.js +++ b/lib/controller.js @@ -218,6 +218,7 @@ class Controller { } } else if (type === 'deviceAnnounce') { logger.debug(`Device '${name}' announced itself`); + this.mqtt.log('device_announced', 'announce', {friendly_name: name}); } else { /* istanbul ignore else */ if (type === 'deviceLeave') { diff --git a/test/controller.test.js b/test/controller.test.js index 24140becd..27a555d61 100644 --- a/test/controller.test.js +++ b/test/controller.test.js @@ -360,6 +360,7 @@ describe('Controller', () => { await zigbeeHerdsman.events.deviceAnnounce(payload); await flushPromises(); expect(logger.debug).toHaveBeenCalledWith(`Device 'bulb' announced itself`); + expect(MQTT.publish).toHaveBeenCalledWith('zigbee2mqtt/bridge/log', '{"type":"device_announced","message":"announce","meta":{"friendly_name":"bulb"}}', { retain: false, qos: 0}, expect.any(Function)); }); it('On zigbee event device leave (removed from database and settings)', async () => { diff --git a/test/deviceAvailability.test.js b/test/deviceAvailability.test.js index b9505b8cf..a2165dc4d 100644 --- a/test/deviceAvailability.test.js +++ b/test/deviceAvailability.test.js @@ -280,7 +280,6 @@ describe('Device availability', () => { expect(device.ping).toHaveBeenCalledTimes(0); MQTT.publish.mockClear(); await zigbeeHerdsman.events.deviceAnnounce({device}); - expect(MQTT.publish).toHaveBeenCalledTimes(0); }); it('Should not read when device has no modelID and reconnects', async () => {