show ems device details in MQTT HA screen

This commit is contained in:
proddy
2025-07-08 22:05:45 +02:00
parent ca8d23ff3a
commit 0a18add447
9 changed files with 38 additions and 15 deletions

View File

@@ -321,6 +321,11 @@ std::string EMSdevice::to_string() {
+ ", Version:" + version_ + ")";
}
// returns string of EMS device version and productID
std::string EMSdevice::to_string_version() {
return "DeviceID:" + Helpers::hextoa(device_id_) + " ProductID:" + Helpers::itoa(product_id_) + " Version:" + version_;
}
// returns out brand + device name
// translated
std::string EMSdevice::to_string_short() {
@@ -1221,7 +1226,7 @@ void EMSdevice::setCustomizationEntity(const std::string & entity_id) {
if (Mqtt::ha_enabled() && (has_custom_name || ((current_mask ^ new_mask) & (DeviceValueState::DV_READONLY >> 4)))) {
// remove ha config on change of dv_readonly flag
dv.remove_state(DeviceValueState::DV_HA_CONFIG_CREATED);
Mqtt::publish_ha_sensor_config_dv(dv, "", "", true); // delete topic (remove = true)
Mqtt::publish_ha_sensor_config_dv(dv, "", "", "", true); // delete topic (remove = true)
}
// always write the mask
@@ -1886,7 +1891,7 @@ void EMSdevice::mqtt_ha_entity_config_create() {
if (!dv.has_state(DeviceValueState::DV_HA_CONFIG_CREATED) && dv.has_state(DeviceValueState::DV_ACTIVE)
&& !dv.has_state(DeviceValueState::DV_API_MQTT_EXCLUDE)) {
// create_device_config is only done once for the EMS device. It can added to any entity, so we take the first
if (Mqtt::publish_ha_sensor_config_dv(dv, name().c_str(), brand_to_char(), false, create_device_config)) {
if (Mqtt::publish_ha_sensor_config_dv(dv, name().c_str(), brand_to_char(), to_string_version().c_str(), false, create_device_config)) {
dv.add_state(DeviceValueState::DV_HA_CONFIG_CREATED);
create_device_config = false; // only create the main config once
count++;