From 717ef62ed3d33b53b3adb5238566ed05f270583a Mon Sep 17 00:00:00 2001 From: Daniel Sadilek Date: Mon, 3 Aug 2026 20:52:39 +0200 Subject: [PATCH 1/3] Add the missing domain prefix to every default_entity_id Home Assistant validates default_entity_id with cv.entity_id, which lowercases the value and then requires the form "domain.object_id". All 15 discovery payloads supplied a bare object id such as "%_charging_power", so every one failed validation and the entity fell back to Home Assistant's placeholder name, producing sensor.unnamed_device, sensor.unnamed_device_2 and so on. Because the integration supplies an entity id at all, Home Assistant also treats these ids as explicitly chosen, so the device page's "Recreate entity IDs" action reports "No renamable entity IDs" and refuses to correct them. The domain is taken from the discovery topic each payload is published to, so the two cannot drift apart. The switch payload for Enable Charging was also missing the underscore separator that every other entity uses; only the default_entity_id is corrected here, its unique_id is deliberately left alone because changing that would orphan the entity for existing installations. Note for existing installations: entity ids are sticky once registered, so this does not rename anything that already exists. Affected users need to delete the MQTT device in Home Assistant and let discovery recreate it. --- src/Components/MQTT/MQTTManager.cpp | 30 ++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Components/MQTT/MQTTManager.cpp b/src/Components/MQTT/MQTTManager.cpp index 17ae965..7fb5624 100644 --- a/src/Components/MQTT/MQTTManager.cpp +++ b/src/Components/MQTT/MQTTManager.cpp @@ -74,7 +74,7 @@ namespace MQTTManager "payload_on":"1", "payload_off":"0", "unique_id":"%_is_vehicle_connected", - "default_entity_id":"%_is_vehicle_connected", + "default_entity_id":"binary_sensor.%_is_vehicle_connected", "device":{"identifiers":["%"],"name":"%","model":"EnergyControl","manufacturer":"Heidelberg"}})"); PublishHomeAssistantDiscoveryTopic( @@ -86,7 +86,7 @@ namespace MQTTManager "payload_on":"1", "payload_off":"0", "unique_id":"%_is_vehicle_charging", - "default_entity_id":"%_is_vehicle_charging", + "default_entity_id":"binary_sensor.%_is_vehicle_charging", "device":{"identifiers":["%"],"name":"%","model":"EnergyControl","manufacturer":"Heidelberg"}})"); PublishHomeAssistantDiscoveryTopic( @@ -97,7 +97,7 @@ namespace MQTTManager "state_class":"measurement", "state_topic":"%/charging_power", "unique_id":"%_charging_power", - "default_entity_id":"%_charging_power", + "default_entity_id":"sensor.%_charging_power", "unit_of_measurement":"W", "device":{"identifiers":["%"],"name":"%","model":"EnergyControl","manufacturer":"Heidelberg"}})"); @@ -109,7 +109,7 @@ namespace MQTTManager "state_class":"measurement", "state_topic":"%/charging_current/phase1", "unique_id":"%_charging_current_phase1", - "default_entity_id":"%_charging_current_phase1", + "default_entity_id":"sensor.%_charging_current_phase1", "unit_of_measurement":"A", "device":{"identifiers":["%"],"name":"%","model":"EnergyControl","manufacturer":"Heidelberg"}})"); @@ -121,7 +121,7 @@ namespace MQTTManager "state_class":"measurement", "state_topic":"%/charging_current/phase2", "unique_id":"%_charging_current_phase2", - "default_entity_id":"%_charging_current_phase2", + "default_entity_id":"sensor.%_charging_current_phase2", "unit_of_measurement":"A", "device":{"identifiers":["%"],"name":"%","model":"EnergyControl","manufacturer":"Heidelberg"}})"); @@ -133,7 +133,7 @@ namespace MQTTManager "state_class":"measurement", "state_topic":"%/charging_current/phase3", "unique_id":"%_charging_current_phase3", - "default_entity_id":"%_charging_current_phase3", + "default_entity_id":"sensor.%_charging_current_phase3", "unit_of_measurement":"A", "device":{"identifiers":["%"],"name":"%","model":"EnergyControl","manufacturer":"Heidelberg"}})"); @@ -145,7 +145,7 @@ namespace MQTTManager "state_class":"measurement", "state_topic":"%/charging_current_limit", "unique_id":"%_charging_current_limit", - "default_entity_id":"%_charging_current_limit", + "default_entity_id":"sensor.%_charging_current_limit", "unit_of_measurement":"A", "device":{"identifiers":["%"],"name":"%","model":"EnergyControl","manufacturer":"Heidelberg"}})"); @@ -157,7 +157,7 @@ namespace MQTTManager "state_topic":"%/energy_meter", "state_class":"total_increasing", "unique_id":"%_energy_meter", - "default_entity_id":"%_energy_meter", + "default_entity_id":"sensor.%_energy_meter", "unit_of_measurement":"kWh", "device":{"identifiers":["%"],"name":"%","model":"EnergyControl","manufacturer":"Heidelberg"}})"); @@ -169,7 +169,7 @@ namespace MQTTManager "state_class":"measurement", "state_topic":"%/temperature", "unique_id":"%_temperature", - "default_entity_id":"%_temperature", + "default_entity_id":"sensor.%_temperature", "unit_of_measurement":"°C", "device":{"identifiers":["%"],"name":"%","model":"EnergyControl","manufacturer":"Heidelberg"}})"); @@ -181,7 +181,7 @@ namespace MQTTManager "state_class":"measurement", "state_topic":"%/charging_voltage/phase1", "unique_id":"%_charging_voltage_phase1", - "default_entity_id":"%_charging_voltage_phase1", + "default_entity_id":"sensor.%_charging_voltage_phase1", "unit_of_measurement":"V", "device":{"identifiers":["%"],"name":"%","model":"EnergyControl","manufacturer":"Heidelberg"}})"); @@ -193,7 +193,7 @@ namespace MQTTManager "state_class":"measurement", "state_topic":"%/charging_voltage/phase2", "unique_id":"%_charging_voltage_phase2", - "default_entity_id":"%_charging_voltage_phase2", + "default_entity_id":"sensor.%_charging_voltage_phase2", "unit_of_measurement":"V", "device":{"identifiers":["%"],"name":"%","model":"EnergyControl","manufacturer":"Heidelberg"}})"); @@ -205,7 +205,7 @@ namespace MQTTManager "state_class":"measurement", "state_topic":"%/charging_voltage/phase3", "unique_id":"%_charging_voltage_phase3", - "default_entity_id":"%_charging_voltage_phase3", + "default_entity_id":"sensor.%_charging_voltage_phase3", "unit_of_measurement":"V", "device":{"identifiers":["%"],"name":"%","model":"EnergyControl","manufacturer":"Heidelberg"}})"); @@ -216,7 +216,7 @@ namespace MQTTManager "state_topic":"%/enable_charging", "command_topic":"%/control/enable_charging", "unique_id":"%control_enable_charging", - "default_entity_id":"%control_enable_charging", + "default_entity_id":"switch.%_control_enable_charging", "payload_on":"ON", "payload_off":"OFF", "device":{"identifiers":["%"],"name":"%","model":"EnergyControl","manufacturer":"Heidelberg"}})"); @@ -228,7 +228,7 @@ namespace MQTTManager "state_topic":"%/standby_enabled", "command_topic":"%/control/standby", "unique_id":"%_control_standby", - "default_entity_id":"%_control_standby", + "default_entity_id":"switch.%_control_standby", "payload_on":"ON", "payload_off":"OFF", "device":{"identifiers":["%"],"name":"%","model":"EnergyControl","manufacturer":"Heidelberg"}})"); @@ -244,7 +244,7 @@ namespace MQTTManager "step":1, "unit_of_measurement":"A", "unique_id":"%_control_charging_current_limit", - "default_entity_id":"%_control_charging_current_limit", + "default_entity_id":"number.%_control_charging_current_limit", "device":{"identifiers":["%"],"name":"%","model":"EnergyControl","manufacturer":"Heidelberg"}})"); } From 961f3c2c8fa4c14841be388f3d200845aaa996c5 Mon Sep 17 00:00:00 2001 From: Daniel Sadilek Date: Mon, 3 Aug 2026 20:53:05 +0200 Subject: [PATCH 2/3] Publish Home Assistant discovery messages retained Discovery is only published from OnMqttConnect, i.e. when this device connects to the broker. Published unretained, the messages are delivered only to subscribers that happen to be listening at that moment, so a Home Assistant instance that restarts afterwards finds nothing under homeassistant/+/+/config. Entities that publish state continuously appear to survive this, but everything with a command_topic (both switches and the number) stays "unavailable" until this device happens to reconnect, which in normal operation may not be for days. Retained discovery is delivered as soon as Home Assistant subscribes. --- src/Components/MQTT/MQTTManager.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Components/MQTT/MQTTManager.cpp b/src/Components/MQTT/MQTTManager.cpp index 7fb5624..be3491d 100644 --- a/src/Components/MQTT/MQTTManager.cpp +++ b/src/Components/MQTT/MQTTManager.cpp @@ -58,7 +58,11 @@ namespace MQTTManager StringUtils::InsertString(topic, TopicBuffer, sizeof(TopicBuffer), '%', Settings::Instance()->DeviceName.c_str()); StringUtils::InsertString(payload, PayloadBuffer, sizeof(PayloadBuffer), '%', Settings::Instance()->DeviceName.c_str()); - gMqttClient.publish(TopicBuffer, 1, false, PayloadBuffer); + // Discovery messages must be retained: they are only published when this + // device connects to the broker, so without the retain flag a Home + // Assistant instance that restarts later finds nothing under + // homeassistant/+/+/config and cannot rebuild the entities. + gMqttClient.publish(TopicBuffer, 1, true, PayloadBuffer); } // Publishes MQTT discovery messages for Home Assistant integration From 919936c56b7537857bf38a65cb37524c1a88eaf8 Mon Sep 17 00:00:00 2001 From: "Brock, Boris" Date: Tue, 4 Aug 2026 06:30:47 +0200 Subject: [PATCH 3/3] Update MQTTManager.cpp --- src/Components/MQTT/MQTTManager.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Components/MQTT/MQTTManager.cpp b/src/Components/MQTT/MQTTManager.cpp index be3491d..301d5c4 100644 --- a/src/Components/MQTT/MQTTManager.cpp +++ b/src/Components/MQTT/MQTTManager.cpp @@ -58,10 +58,6 @@ namespace MQTTManager StringUtils::InsertString(topic, TopicBuffer, sizeof(TopicBuffer), '%', Settings::Instance()->DeviceName.c_str()); StringUtils::InsertString(payload, PayloadBuffer, sizeof(PayloadBuffer), '%', Settings::Instance()->DeviceName.c_str()); - // Discovery messages must be retained: they are only published when this - // device connects to the broker, so without the retain flag a Home - // Assistant instance that restarts later finds nothing under - // homeassistant/+/+/config and cannot rebuild the entities. gMqttClient.publish(TopicBuffer, 1, true, PayloadBuffer); }