зеркало из
https://github.com/revspace/operame
синхронизирован 2025-12-12 23:46:30 +00:00
Merge pull request #6 from controlco2/bugfix/check-temp-hum-flag
bugfix: check if the user wants to send temperature and humidity via …
Этот коммит содержится в:
коммит
ca29d59c08
1 изменённых файлов: 30 добавлений и 28 удалений
58
operame.ino
58
operame.ino
|
|
@ -610,35 +610,37 @@ void loop() {
|
||||||
serializeJson(doc, message);
|
serializeJson(doc, message);
|
||||||
retain(mqtt_topic, message);
|
retain(mqtt_topic, message);
|
||||||
|
|
||||||
//temperature
|
if(mqtt_temp_hum_enabled) {
|
||||||
if(isnan(t)) {
|
//temperature
|
||||||
Serial.println("Failed to read from DHT sensor, so no MQTT publish");
|
if(isnan(t)) {
|
||||||
}
|
Serial.println("Failed to read from DHT sensor, so no MQTT publish");
|
||||||
else {
|
}
|
||||||
String message;
|
else {
|
||||||
const size_t capacity = JSON_OBJECT_SIZE(3);
|
String message;
|
||||||
DynamicJsonDocument doc(capacity);
|
const size_t capacity = JSON_OBJECT_SIZE(3);
|
||||||
doc["variable"] = "temperature";
|
DynamicJsonDocument doc(capacity);
|
||||||
doc["value"] = t;
|
doc["variable"] = "temperature";
|
||||||
doc["unit"] = "C";
|
doc["value"] = t;
|
||||||
serializeJson(doc, message);
|
doc["unit"] = "C";
|
||||||
retain(mqtt_topic, message);
|
serializeJson(doc, message);
|
||||||
}
|
retain(mqtt_topic, message);
|
||||||
|
}
|
||||||
|
|
||||||
//humidity
|
//humidity
|
||||||
if(isnan(h)) {
|
if(isnan(h)) {
|
||||||
Serial.println("Failed to read from DHT sensor, so no MQTT publish");
|
Serial.println("Failed to read from DHT sensor, so no MQTT publish");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
String message;
|
String message;
|
||||||
const size_t capacity = JSON_OBJECT_SIZE(3);
|
const size_t capacity = JSON_OBJECT_SIZE(3);
|
||||||
DynamicJsonDocument doc(capacity);
|
DynamicJsonDocument doc(capacity);
|
||||||
doc["variable"] = "humidity";
|
doc["variable"] = "humidity";
|
||||||
doc["value"] = h;
|
doc["value"] = h;
|
||||||
doc["unit"] = "%R.H.";
|
doc["unit"] = "%R.H.";
|
||||||
serializeJson(doc, message);
|
serializeJson(doc, message);
|
||||||
retain(mqtt_topic, message);
|
retain(mqtt_topic, message);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Загрузка…
Создание таблицы
Сослаться в новой задаче