UM SHT: Using F() helper on some strings

This commit is contained in:
ezcGman 2022-12-11 22:32:03 +01:00
parent e8edb99bb0
commit 987dd36401

View File

@ -213,29 +213,29 @@ class ShtUsermod : public Usermod
JsonObject user = root["u"]; JsonObject user = root["u"];
if (user.isNull()) user = root.createNestedObject("u"); if (user.isNull()) user = root.createNestedObject("u");
JsonArray jsonTemp = user.createNestedArray("Temperature"); JsonArray jsonTemp = user.createNestedArray(F("Temperature"));
JsonArray jsonHumidity = user.createNestedArray("Humidity"); JsonArray jsonHumidity = user.createNestedArray(F("Humidity"));
if (shtLastTimeUpdated == 0 || !shtReadDataSuccess) { if (shtLastTimeUpdated == 0 || !shtReadDataSuccess) {
jsonTemp.add(0); jsonTemp.add(0);
jsonHumidity.add(0); jsonHumidity.add(0);
if (shtLastTimeUpdated == 0) { if (shtLastTimeUpdated == 0) {
jsonTemp.add(" Not read yet"); jsonTemp.add(F(" Not read yet"));
jsonHumidity.add(" Not read yet"); jsonHumidity.add(F(" Not read yet"));
} }
else { else {
jsonTemp.add(" Error"); jsonTemp.add(F(" Error"));
jsonHumidity.add(" Error"); jsonHumidity.add(F(" Error"));
} }
return; return;
} }
jsonHumidity.add(shtCurrentHumidity); jsonHumidity.add(shtCurrentHumidity);
jsonHumidity.add(" RH"); jsonHumidity.add(F(" RH"));
jsonTemp.add(shtCurrentTemp); jsonTemp.add(shtCurrentTemp);
jsonTemp.add(" °C"); jsonTemp.add(F(" °C"));
} }
void publishTemperatureAndHumidityViaMqtt() { void publishTemperatureAndHumidityViaMqtt() {
@ -288,11 +288,11 @@ class ShtUsermod : public Usermod
void appendDeviceToMqttDiscoveryMessage(JsonDocument& root) { void appendDeviceToMqttDiscoveryMessage(JsonDocument& root) {
JsonObject device = root.createNestedObject("dev"); JsonObject device = root.createNestedObject("dev");
device["ids"] = escapedMac.c_str(); device[F("ids")] = escapedMac.c_str();
device["name"] = serverDescription; device[F("name")] = serverDescription;
device["sw"] = versionString; device[F("sw")] = versionString;
device["mdl"] = ESP.getChipModel(); device[F("mdl")] = ESP.getChipModel();
device["mf"] = "espressif"; device[F("mf")] = F("espressif");
} }
/* /*
@ -307,6 +307,6 @@ class ShtUsermod : public Usermod
// strings to reduce flash memory usage (used more than twice) // strings to reduce flash memory usage (used more than twice)
// Config settings // Config settings
const char ShtUsermod::_name[] PROGMEM = "SHT Temperature & Humidity Sensor"; const char ShtUsermod::_name[] PROGMEM = "SHT Sensor";
const char ShtUsermod::_enabled[] PROGMEM = "Enabled"; const char ShtUsermod::_enabled[] PROGMEM = "Enabled";
const char ShtUsermod::_haMqttDiscovery[] PROGMEM = "Add-To-Home-Assistant-MQTT-Discovery"; const char ShtUsermod::_haMqttDiscovery[] PROGMEM = "Add-To-Home-Assistant-MQTT-Discovery";