From e2fbd8f799b959894075dda2ce925ecd83ca76a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Ha=C3=9Fel?= Date: Fri, 14 Feb 2025 13:31:44 +0100 Subject: [PATCH] use unit constants --- src/bme680.h | 12 ++++++------ src/tsl2561.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/bme680.h b/src/bme680.h index d394d87..8f32b42 100644 --- a/src/bme680.h +++ b/src/bme680.h @@ -45,12 +45,12 @@ public: if (bme.remainingReadingMillis() == 0) { if (bme.endReading()) { const auto humidityAbsolute = calculateHumidityAbsolute(bme.temperature, bme.humidity); - mqttPublish(name + "/temperature", bme.temperature, "\xB0""C"); - mqttPublish(name + "/pressure", bme.pressure / 100.0, "hPa"); - mqttPublish(name + "/humidity/relative", bme.humidity, "%"); - mqttPublish(name + "/humidity/absolute", humidityAbsolute, "mg/L"); - mqttPublish(name + "/gas", bme.gas_resistance / 1000.0, "KOhms"); - mqttPublish(name + "/altitude", bme.readAltitude(1013.25), "m"); + mqttPublish(name + "/temperature", bme.temperature, "TEMPERATURE_CELSIUS"); + mqttPublish(name + "/pressure", bme.pressure / 100.0, "PRESSURE_HPA"); + mqttPublish(name + "/humidity/relative", bme.humidity, "HUMIDITY_RELATIVE_PERCENT"); + mqttPublish(name + "/humidity/absolute", humidityAbsolute, "HUMIDITY_ABSOLUTE_MGL"); + mqttPublish(name + "/gas", bme.gas_resistance, "RESISTANCE_OHMS"); + mqttPublish(name + "/altitude", bme.readAltitude(1013.25), "ALTITUDE_M"); } else { Log.printf("BME680 \"%s\": Failed to complete reading\n", name.c_str()); setup(); diff --git a/src/tsl2561.h b/src/tsl2561.h index 837c306..f97f9f0 100644 --- a/src/tsl2561.h +++ b/src/tsl2561.h @@ -48,7 +48,7 @@ private: Log.printf("TSL2561 \"%s\": Failed to read.\n", name.c_str()); setup(); } else { - mqttPublish(name + "/illuminance", illuminance, "lux"); + mqttPublish(name + "/illuminance", illuminance, "ILLUMINANCE_LUX"); } }