From 5bda018d25dcd610e592d8e5091d78fb9077ea09 Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Mon, 14 Nov 2022 12:22:12 +0100 Subject: [PATCH] En-tag for HA-entity --- src/emsdevice.cpp | 4 ++-- src/emsdevice.h | 2 +- src/mqtt.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/emsdevice.cpp b/src/emsdevice.cpp index c7352134e..a7711a36b 100644 --- a/src/emsdevice.cpp +++ b/src/emsdevice.cpp @@ -43,8 +43,8 @@ bool EMSdevice::has_entities() const { return false; } -std::string EMSdevice::tag_to_string(uint8_t tag) { - return (Helpers::translated_word(DeviceValue::DeviceValueTAG_s[tag])); +std::string EMSdevice::tag_to_string(uint8_t tag, const bool translate) { + return (translate ? Helpers::translated_word(DeviceValue::DeviceValueTAG_s[tag]) : DeviceValue::DeviceValueTAG_s[tag][0]); } std::string EMSdevice::tag_to_mqtt(uint8_t tag) { diff --git a/src/emsdevice.h b/src/emsdevice.h index 6a582e982..9268d8aa2 100644 --- a/src/emsdevice.h +++ b/src/emsdevice.h @@ -49,7 +49,7 @@ class EMSdevice { static const char * device_type_2_device_name(const uint8_t device_type); static uint8_t device_name_2_device_type(const char * topic); static std::string uom_to_string(uint8_t uom); - static std::string tag_to_string(uint8_t tag); + static std::string tag_to_string(uint8_t tag, const bool translate = true); static std::string tag_to_mqtt(uint8_t tag); bool has_tag(const uint8_t tag) const; diff --git a/src/mqtt.cpp b/src/mqtt.cpp index 91ed56e6f..5d189006d 100644 --- a/src/mqtt.cpp +++ b/src/mqtt.cpp @@ -1091,7 +1091,7 @@ void Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdevice // keep it compatible to v3.4, use english fullname, no prefix (basename prefix commented out) char object_id[130]; if (have_tag) { - snprintf(object_id, sizeof(object_id), "%s_%s_%s", device_name, EMSdevice::tag_to_mqtt(tag).c_str(), en_name); + snprintf(object_id, sizeof(object_id), "%s_%s_%s", device_name, EMSdevice::tag_to_string(tag, false).c_str(), en_name); } else { snprintf(object_id, sizeof(object_id), "%s_%s", device_name, en_name); }