mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2026-06-15 04:16:27 +03:00
brand_to_cstr()
This commit is contained in:
@@ -105,8 +105,12 @@ const char * EMSdevice::uom_to_string(uint8_t uom) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string EMSdevice::brand_to_char() {
|
std::string EMSdevice::brand_to_char() {
|
||||||
|
return std::string{brand_to_cstr()};
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * EMSdevice::brand_to_cstr() const {
|
||||||
if (!custom_brand().empty()) {
|
if (!custom_brand().empty()) {
|
||||||
return custom_brand();
|
return custom_brand().c_str();
|
||||||
}
|
}
|
||||||
switch (brand_) {
|
switch (brand_) {
|
||||||
case EMSdevice::Brand::BOSCH:
|
case EMSdevice::Brand::BOSCH:
|
||||||
@@ -2160,7 +2164,7 @@ void EMSdevice::mqtt_ha_entity_config_create() {
|
|||||||
if (!dv.has_state(DeviceValueState::DV_HA_CONFIG_CREATED) && dv.has_state(DeviceValueState::DV_ACTIVE)
|
if (!dv.has_state(DeviceValueState::DV_HA_CONFIG_CREATED) && dv.has_state(DeviceValueState::DV_ACTIVE)
|
||||||
&& !dv.has_state(DeviceValueState::DV_API_MQTT_EXCLUDE)) {
|
&& !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
|
// 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().c_str(), to_string_version().c_str(), false, create_device_config)) {
|
if (Mqtt::publish_ha_sensor_config_dv(dv, name().c_str(), brand_to_cstr(), to_string_version().c_str(), false, create_device_config)) {
|
||||||
dv.add_state(DeviceValueState::DV_HA_CONFIG_CREATED);
|
dv.add_state(DeviceValueState::DV_HA_CONFIG_CREATED);
|
||||||
create_device_config = false; // only create the main config once
|
create_device_config = false; // only create the main config once
|
||||||
count++;
|
count++;
|
||||||
@@ -2224,7 +2228,7 @@ bool EMSdevice::has_telegram_id(uint16_t id) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// return the name of the telegram type
|
// return the name of the telegram type
|
||||||
const char * EMSdevice::telegram_type_name(std::shared_ptr<const Telegram> telegram) {
|
const char * EMSdevice::telegram_type_name(const std::shared_ptr<const Telegram> & telegram) {
|
||||||
// see if it's one of the common ones, like Version
|
// see if it's one of the common ones, like Version
|
||||||
if (telegram->type_id == EMS_TYPE_VERSION) {
|
if (telegram->type_id == EMS_TYPE_VERSION) {
|
||||||
return "Version";
|
return "Version";
|
||||||
@@ -2243,7 +2247,7 @@ const char * EMSdevice::telegram_type_name(std::shared_ptr<const Telegram> teleg
|
|||||||
|
|
||||||
// take a telegram_type_id and call the matching handler
|
// take a telegram_type_id and call the matching handler
|
||||||
// return true if match found
|
// return true if match found
|
||||||
bool EMSdevice::handle_telegram(std::shared_ptr<const Telegram> telegram) {
|
bool EMSdevice::handle_telegram(const std::shared_ptr<const Telegram> & telegram) {
|
||||||
for (auto & tf : telegram_functions_) {
|
for (auto & tf : telegram_functions_) {
|
||||||
if (tf.telegram_type_id_ == telegram->type_id) {
|
if (tf.telegram_type_id_ == telegram->type_id) {
|
||||||
// for telegram destination only read telegram
|
// for telegram destination only read telegram
|
||||||
|
|||||||
@@ -2535,7 +2535,7 @@ bool System::command_info(const char * value, const int8_t id, JsonObject output
|
|||||||
obj["name"] = emsdevice->name(); // custom name
|
obj["name"] = emsdevice->name(); // custom name
|
||||||
obj["deviceID"] = Helpers::hextoa(emsdevice->device_id());
|
obj["deviceID"] = Helpers::hextoa(emsdevice->device_id());
|
||||||
obj["productID"] = emsdevice->product_id();
|
obj["productID"] = emsdevice->product_id();
|
||||||
obj["brand"] = emsdevice->brand_to_char();
|
obj["brand"] = emsdevice->brand_to_cstr();
|
||||||
obj["version"] = emsdevice->version();
|
obj["version"] = emsdevice->version();
|
||||||
obj["entities"] = emsdevice->count_entities();
|
obj["entities"] = emsdevice->count_entities();
|
||||||
char result[1000];
|
char result[1000];
|
||||||
|
|||||||
Reference in New Issue
Block a user