mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-10-23 06:12:23 +00:00
Fix topic not updated for Home Assistant sensor on rename. #4452
This commit is contained in:
1 parent
cb5418e9fc
commit
4f6797c365
1 file changed
+6
-6
@@ -2204,16 +2204,16 @@ class HomeAssistant extends Extension {
|
||||
}
|
||||
|
||||
onDeviceRenamed(device, homeAssisantRename) {
|
||||
if (!homeAssisantRename) return;
|
||||
|
||||
logger.debug(`Refreshing Home Assistant discovery topic for '${device.ieeeAddr}'`);
|
||||
|
||||
// Clear before rename so Home Assistant uses new friendly_name
|
||||
// https://github.com/Koenkk/zigbee2mqtt/issues/4096#issuecomment-674044916
|
||||
const resolvedEntity = this.zigbee.resolveEntity(device);
|
||||
for (const config of this.getConfigs(resolvedEntity)) {
|
||||
const topic = this.getDiscoveryTopic(config, device);
|
||||
this.mqtt.publish(topic, null, {retain: true, qos: 0}, this.discoveryTopic);
|
||||
if (homeAssisantRename) {
|
||||
const resolvedEntity = this.zigbee.resolveEntity(device);
|
||||
for (const config of this.getConfigs(resolvedEntity)) {
|
||||
const topic = this.getDiscoveryTopic(config, device);
|
||||
this.mqtt.publish(topic, null, {retain: true, qos: 0}, this.discoveryTopic);
|
||||
}
|
||||
}
|
||||
|
||||
this.discover(resolvedEntity, true);
|
||||
|
||||
Reference in new issue
Block a user