Merge pull request #2824 from MichaelDvP/dev

some more fixes
This commit is contained in:
Proddy
2025-12-18 11:23:37 +01:00
committed by GitHub
4 changed files with 11 additions and 15 deletions

View File

@@ -650,7 +650,7 @@ void AnalogSensor::remove_ha_topic(const int8_t type, const uint8_t gpio) const
snprintf(topic, sizeof(topic), "number/%s/%s_%02d/config", Mqtt::basename().c_str(), F_(analogsensor), gpio);
} else if (type >= AnalogType::PWM_0 && type <= AnalogType::PWM_2) {
snprintf(topic, sizeof(topic), "number/%s/%s_%02d/config", Mqtt::basename().c_str(), F_(analogsensor), gpio);
} else if (type >= AnalogType::RGB) {
} else if (type == AnalogType::RGB) {
snprintf(topic, sizeof(topic), "number/%s/%s_%02d/config", Mqtt::basename().c_str(), F_(analogsensor), gpio);
} else if (type == AnalogType::DIGITAL_IN) {
snprintf(topic, sizeof(topic), "binary_sensor/%s/%s_%02d/config", Mqtt::basename().c_str(), F_(analogsensor), gpio);
@@ -682,7 +682,7 @@ void AnalogSensor::publish_values(const bool force) {
if (Mqtt::is_nested()) {
char s[10];
JsonObject dataSensor = obj[Helpers::smallitoa(s, sensor.gpio())].to<JsonObject>();
dataSensor["name"] = sensor.name();
dataSensor["name"] = (const char *)sensor.name();
#if CONFIG_IDF_TARGET_ESP32
if (sensor.type() == AnalogType::PULSE || (sensor.type() == AnalogType::DIGITAL_OUT && sensor.gpio() != 25 && sensor.gpio() != 26)) {
#else
@@ -739,7 +739,7 @@ void AnalogSensor::publish_values(const bool force) {
config["~"] = Mqtt::base();
config["uniq_id"] = uniq_s;
config["name"] = sensor.name();
config["name"] = (const char *)sensor.name();
if (sensor.uom() != DeviceValueUOM::NONE && sensor.type() != AnalogType::DIGITAL_OUT) {
config["unit_of_meas"] = EMSdevice::uom_to_string(sensor.uom());
@@ -856,8 +856,8 @@ bool AnalogSensor::get_value_info(JsonObject output, const char * cmd, const int
// note we don't add the device and state classes here, as we do in the custom entity service
void AnalogSensor::get_value_json(JsonObject output, const Sensor & sensor) {
output["name"] = sensor.name();
output["fullname"] = sensor.name();
output["name"] = (const char *)sensor.name();
output["fullname"] = (const char *)sensor.name();
output["gpio"] = sensor.gpio();
output["type"] = F_(number);
output["analog"] = FL_(list_sensortype)[sensor.type()];

View File

@@ -418,8 +418,8 @@ bool TemperatureSensor::get_value_info(JsonObject output, const char * cmd, cons
// note we don't add the device and state classes here, as we do in the custom entity service
void TemperatureSensor::get_value_json(JsonObject output, const Sensor & sensor) {
output["id"] = sensor.id();
output["name"] = sensor.name();
output["fullname"] = sensor.name();
output["name"] = (const char *)sensor.name();
output["fullname"] = (const char *)sensor.name();
if (Helpers::hasValue(sensor.temperature_c)) {
char val[10];
output["value"] = serialized(Helpers::render_value(val, sensor.temperature_c, 10, EMSESP::system_.fahrenheit() ? 2 : 0));
@@ -488,7 +488,7 @@ void TemperatureSensor::publish_values(const bool force) {
char val[10];
if (Mqtt::is_nested()) {
JsonObject dataSensor = doc[sensor.id()].to<JsonObject>();
dataSensor["name"] = sensor.name();
dataSensor["name"] = (const char *)sensor.name();
dataSensor["temp"] = serialized(Helpers::render_value(val, sensor.temperature_c, 10, EMSESP::system_.fahrenheit() ? 2 : 0));
} else {
doc[sensor.name()] = serialized(Helpers::render_value(val, sensor.temperature_c, 10, EMSESP::system_.fahrenheit() ? 2 : 0));
@@ -542,7 +542,7 @@ void TemperatureSensor::publish_values(const bool force) {
config["uniq_id"] = uniq_s;
config["def_ent_id"] = (std::string) "sensor." + uniq_s;
config["name"] = sensor.name();
config["name"] = (const char *)sensor.name();
// dev section with model is only created on the 1st sensor
Mqtt::add_ha_dev_section(config.as<JsonObject>(), "Temperature Sensors", nullptr, "EMS-ESP", EMSESP_APP_VERSION, !ha_dev_created);

View File

@@ -465,9 +465,7 @@ void WebCustomEntityService::publish(const bool force) {
Mqtt::add_ha_classes(config.as<JsonObject>(), EMSdevice::DeviceType::SYSTEM, entityItem.value_type, entityItem.uom);
if (!ha_created) {
Mqtt::add_ha_dev_section(config.as<JsonObject>(), "Custom Entities", nullptr, "EMS-ESP", EMSESP_APP_VERSION, true);
}
Mqtt::add_ha_dev_section(config.as<JsonObject>(), "Custom Entities", nullptr, "EMS-ESP", EMSESP_APP_VERSION, !ha_created);
Mqtt::add_ha_avty_section(config.as<JsonObject>(), stat_t, val_cond);
ha_created |= Mqtt::queue_ha(topic, config.as<JsonObject>());

View File

@@ -276,9 +276,7 @@ void WebSchedulerService::publish(const bool force) {
config["cmd_t"] = command_topic;
Mqtt::add_ha_bool(config.as<JsonObject>());
if (!ha_created) {
Mqtt::add_ha_dev_section(config.as<JsonObject>(), F_(scheduler), nullptr, "EMS-ESP", EMSESP_APP_VERSION, true);
}
Mqtt::add_ha_dev_section(config.as<JsonObject>(), F_(scheduler), nullptr, "EMS-ESP", EMSESP_APP_VERSION, !ha_created);
Mqtt::add_ha_avty_section(config.as<JsonObject>(), stat_t, val_cond);
ha_created |= Mqtt::queue_ha(topic, config.as<JsonObject>());