mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2026-01-26 16:49:11 +03:00
use (const char *) for PSRAM-stored sensor.name in ArduinoJson
This commit is contained in:
@@ -681,7 +681,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
|
||||
@@ -738,7 +738,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());
|
||||
@@ -857,8 +857,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()];
|
||||
|
||||
@@ -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; })) {
|
||||
|
||||
Reference in New Issue
Block a user