mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2024-11-16 10:28:33 -07:00
Fix disabling discovery of specific Home Assistant sensor not working. #5597
This commit is contained in:
parent
4c95265d5e
commit
2cf9657bd4
@ -586,8 +586,10 @@ class HomeAssistant extends Extension {
|
||||
configs = JSON.parse(JSON.stringify(configs));
|
||||
|
||||
if (resolvedEntity.settings.homeassistant) {
|
||||
const s = resolvedEntity.settings.homeassistant;
|
||||
configs = configs.filter((config) => !s.hasOwnProperty(config.object_id) || s[config.object_id] != null);
|
||||
configs.forEach((config) => {
|
||||
const configOverride = resolvedEntity.settings.homeassistant[config.object_id];
|
||||
const configOverride = s[config.object_id];
|
||||
if (configOverride) {
|
||||
config.object_id = configOverride.object_id || config.object_id;
|
||||
config.type = configOverride.type || config.type;
|
||||
|
@ -529,6 +529,24 @@ describe('HomeAssistant extension', () => {
|
||||
expect(topics).not.toContain('homeassistant/sensor/0x0017880104e45522/temperature/config')
|
||||
});
|
||||
|
||||
it('Shouldnt discover sensor when set to null', async () => {
|
||||
logger.error.mockClear();
|
||||
settings.set(['devices', '0x0017880104e45522'], {
|
||||
homeassistant: {humidity: 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).toContain('homeassistant/sensor/0x0017880104e45522/temperature/config')
|
||||
});
|
||||
|
||||
it('Should discover devices with fan', async () => {
|
||||
controller = new Controller(false);
|
||||
await controller.start();
|
||||
|
Loading…
Reference in New Issue
Block a user