mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-08-27 21:20:03 +00:00
Undiscover ota_update sensor on device remove.
This commit is contained in:
@@ -1266,7 +1266,7 @@ class HomeAssistant extends BaseExtension {
|
||||
const mappedModel = zigbeeHerdsmanConverters.findByZigbeeModel(device.modelID);
|
||||
if (mappedModel) {
|
||||
logger.info(`Clearing Home Assistant discovery topic for '${device.ieeeAddr}'`);
|
||||
mapping[mappedModel.model].forEach((config) => {
|
||||
this.getConfigs(mappedModel).forEach((config) => {
|
||||
const topic = this.getDiscoveryTopic(config, device);
|
||||
this.mqtt.publish(topic, null, {retain: true, qos: 0}, this.discoveryTopic);
|
||||
});
|
||||
@@ -1285,6 +1285,14 @@ class HomeAssistant extends BaseExtension {
|
||||
}
|
||||
}
|
||||
|
||||
getConfigs(mappedModel) {
|
||||
const configs = mapping[mappedModel.model].slice();
|
||||
if (mappedModel.hasOwnProperty('ota')) {
|
||||
configs.push(cfg.binary_sensor_update_available);
|
||||
}
|
||||
return configs;
|
||||
}
|
||||
|
||||
discover(device, mappedModel, force=false) {
|
||||
// Check if already discoverd and check if there are configs.
|
||||
const discover = force || !this.discovered[device.ieeeAddr];
|
||||
@@ -1298,12 +1306,7 @@ class HomeAssistant extends BaseExtension {
|
||||
return;
|
||||
}
|
||||
|
||||
const configs = mapping[mappedModel.model].slice();
|
||||
if (mappedModel.hasOwnProperty('ota')) {
|
||||
configs.push(cfg.binary_sensor_update_available);
|
||||
}
|
||||
|
||||
configs.forEach((config) => {
|
||||
this.getConfigs(mappedModel).forEach((config) => {
|
||||
const topic = this.getDiscoveryTopic(config, device);
|
||||
const payload = {...config.discovery_payload};
|
||||
const stateTopic = `${settings.get().mqtt.base_topic}/${entity.friendlyName}`;
|
||||
|
||||
Reference in New Issue
Block a user