En-tag for HA-entity

This commit is contained in:
MichaelDvP
2022-11-14 12:22:12 +01:00
parent b12729a874
commit 5bda018d25
3 changed files with 4 additions and 4 deletions

View File

@@ -43,8 +43,8 @@ bool EMSdevice::has_entities() const {
return false; return false;
} }
std::string EMSdevice::tag_to_string(uint8_t tag) { std::string EMSdevice::tag_to_string(uint8_t tag, const bool translate) {
return (Helpers::translated_word(DeviceValue::DeviceValueTAG_s[tag])); return (translate ? Helpers::translated_word(DeviceValue::DeviceValueTAG_s[tag]) : DeviceValue::DeviceValueTAG_s[tag][0]);
} }
std::string EMSdevice::tag_to_mqtt(uint8_t tag) { std::string EMSdevice::tag_to_mqtt(uint8_t tag) {

View File

@@ -49,7 +49,7 @@ class EMSdevice {
static const char * device_type_2_device_name(const uint8_t device_type); 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 uint8_t device_name_2_device_type(const char * topic);
static std::string uom_to_string(uint8_t uom); 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); static std::string tag_to_mqtt(uint8_t tag);
bool has_tag(const uint8_t tag) const; bool has_tag(const uint8_t tag) const;

View File

@@ -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) // keep it compatible to v3.4, use english fullname, no prefix (basename prefix commented out)
char object_id[130]; char object_id[130];
if (have_tag) { 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 { } else {
snprintf(object_id, sizeof(object_id), "%s_%s", device_name, en_name); snprintf(object_id, sizeof(object_id), "%s_%s", device_name, en_name);
} }