mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
En-tag for HA-entity
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user