Allow to disable Home Assistant device discovery. https://github.com/Koenkk/zigbee2mqtt/issues/2089

This commit is contained in:
Koen Kanters
2019-10-07 21:58:35 +02:00
parent a3bbb93f99
commit 997c5d3e44
2 changed files with 19 additions and 1 deletions
+2 -1
View File
@@ -963,7 +963,8 @@ class HomeAssistant extends BaseExtension {
}
const entity = settings.getEntity(entityID);
if (!entity || (entity.type === 'device' && !mapping[mappedModel.model])) {
if (!entity || (entity.type === 'device' && !mapping[mappedModel.model]) ||
(entity.hasOwnProperty('homeassistant') && !entity.homeassistant)) {
return;
}
+17
View File
@@ -340,6 +340,23 @@ describe('HomeAssistant extension', () => {
);
});
it('Shouldnt discover devices when homeassistant null is set in device options', async () => {
settings.set(['devices', '0x0017880104e45522'], {
homeassistant: null,
friendly_name: 'weather_sensor',
retain: false,
})
controller = new Controller(false);
await controller.start();
await flushPromises();
const topics = MQTT.publish.mock.calls.map((c) => c[0]);
expect(topics).not.toContain('homeassistant/sensor/0x0017880104e45522/humidity/config')
expect(topics).not.toContain('homeassistant/sensor/0x0017880104e45522/temperature/config')
});
it('Should discover devices with fan', async () => {
controller = new Controller(false);
await controller.start();