publish announces to log topic (#3101)

* publish announces to log topic

* publish announces to log topic #test fix

* Update controller.js

* Update controller.test.js

* Update deviceAvailability.test.js

Co-authored-by: Andrey Sergeew <avsergeev@neoflex.ru>
Co-authored-by: Koen Kanters <koenkanters94@gmail.com>
This commit is contained in:
nightdeveloper
2020-03-11 18:21:06 +01:00
committed by GitHub
co-authored by Andrey Sergeew Koen Kanters
parent 785079a712
commit b59d761ca6
3 changed files with 2 additions and 1 deletions
+1
View File
@@ -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') {
+1
View File
@@ -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 () => {
-1
View File
@@ -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 () => {