mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-10-22 05:52:20 +00:00
Don't discover sensor_click when legacy: false is set. https://github.com/Koenkk/zigbee-herdsman-converters/issues/1393
This commit is contained in:
1 parent
992ebafc63
commit
00f836fce6
2 files changed
+23
-2
No files matched your search
@@ -1955,7 +1955,7 @@ class HomeAssistant extends Extension {
|
||||
}
|
||||
}
|
||||
|
||||
getConfigs(mappedModel) {
|
||||
getConfigs(mappedModel, deviceSettings=null) {
|
||||
let configs = mapping[mappedModel.model].slice();
|
||||
configs.push(cfg.sensor_linkquality);
|
||||
|
||||
@@ -1963,6 +1963,10 @@ class HomeAssistant extends Extension {
|
||||
configs.push(cfg.binary_sensor_update_available);
|
||||
}
|
||||
|
||||
if (deviceSettings && deviceSettings.hasOwnProperty('legacy') && !deviceSettings.legacy) {
|
||||
configs = configs.filter((c) => c !== cfg.sensor_click);
|
||||
}
|
||||
|
||||
if (!settings.get().advanced.homeassistant_legacy_triggers) {
|
||||
configs = configs.filter((c) => c !== cfg.sensor_action && c !== cfg.sensor_click);
|
||||
}
|
||||
@@ -1981,7 +1985,7 @@ class HomeAssistant extends Extension {
|
||||
}
|
||||
|
||||
const friendlyName = deviceSettings.friendlyName;
|
||||
this.getConfigs(definition).forEach((config) => {
|
||||
this.getConfigs(definition, deviceSettings).forEach((config) => {
|
||||
const topic = this.getDiscoveryTopic(config, device);
|
||||
const payload = {...config.discovery_payload};
|
||||
let stateTopic = `${settings.get().mqtt.base_topic}/${deviceSettings.friendlyName}`;
|
||||
|
||||
@@ -884,6 +884,23 @@ describe('HomeAssistant extension', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('Should not discover sensor_click when legacy: false is set', async () => {
|
||||
settings.set(['devices', '0x0017880104e45520'], {
|
||||
legacy: false,
|
||||
friendly_name: 'weather_sensor',
|
||||
retain: false,
|
||||
})
|
||||
controller = new Controller(false);
|
||||
await controller.start();
|
||||
await flushPromises();
|
||||
|
||||
const discovered = MQTT.publish.mock.calls.filter((c) => c[0].includes('0x0017880104e45520')).map((c) => c[0]);
|
||||
expect(discovered.length).toBe(3);
|
||||
expect(discovered).toContain('homeassistant/sensor/0x0017880104e45520/action/config');
|
||||
expect(discovered).toContain('homeassistant/sensor/0x0017880104e45520/battery/config');
|
||||
expect(discovered).toContain('homeassistant/sensor/0x0017880104e45520/linkquality/config');
|
||||
});
|
||||
|
||||
it('Should disable Home Assistant legacy triggers', async () => {
|
||||
settings.set(['advanced', 'homeassistant_legacy_triggers'], false);
|
||||
controller = new Controller(false);
|
||||
|
||||
Reference in new issue
Block a user