mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-08-22 10:39:58 +00:00
Allow to disable Home Assistant device discovery. https://github.com/Koenkk/zigbee2mqtt/issues/2089
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user