use (const char *) for PSRAM-stored sensor.name in ArduinoJson

This commit is contained in:
MichaelDvP
2025-12-17 16:42:38 +01:00
parent c4297e2996
commit 45ae6d802c
4 changed files with 122 additions and 122 deletions

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));
@@ -487,7 +487,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));
@@ -541,7 +541,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();
// see if we need to create the [devs] discovery section, as this needs only to be done once for all sensors
if (std::none_of(sensors_.begin(), sensors_.end(), [](const auto & sensor) { return sensor.ha_registered; })) {