|
@@ -6,97 +6,89 @@ int currHum_lastPublished;
|
|
|
|
|
|
void publishCurrentSensorValues(bool force = false)
|
|
|
{
|
|
|
- if (sensor_DHT_lastUpdate != 0 && (millis() - sensor_DHT_lastUpdate) < 120000)
|
|
|
- { // ensure values are not too old
|
|
|
- char _tmp_topic_out[50];
|
|
|
- char _temp_chararr[6];
|
|
|
- char _hum_chararr[4];
|
|
|
-
|
|
|
- #ifdef ENABLE_SENSOR_DHT22
|
|
|
-
|
|
|
- dtostrf(sensor_DHT_currTemp, 1, 1, _temp_chararr);
|
|
|
- sprintf(_hum_chararr, "%2i", sensor_DHT_currHum);
|
|
|
-
|
|
|
- // if (serialdebug)
|
|
|
- // {
|
|
|
- // Serial.print(F("sensors: {"));
|
|
|
- // Serial.print("'temp':");
|
|
|
- // Serial.print(_temp_chararr);
|
|
|
- // }
|
|
|
-
|
|
|
- if (force || sensor_DHT_currTemp != currTemp_lastPublished)
|
|
|
- {
|
|
|
- snprintf(_tmp_topic_out, 50, "%s/%s", confMqtt.mqtt_topic_out, "temp");
|
|
|
- mqttclient.publish(_tmp_topic_out, _temp_chararr, confMqtt.mqtt_outRetain_sensors);
|
|
|
- currTemp_lastPublished = sensor_DHT_currTemp;
|
|
|
- yield();
|
|
|
- }
|
|
|
-
|
|
|
- // if (serialdebug)
|
|
|
- // {
|
|
|
- // Serial.print(F(",'hum':"));
|
|
|
- // Serial.print(sensor_DHT_currHum);
|
|
|
- // }
|
|
|
-
|
|
|
- if (force || sensor_DHT_currHum != currHum_lastPublished)
|
|
|
- {
|
|
|
- snprintf(_tmp_topic_out, 50, "%s/%s", confMqtt.mqtt_topic_out, "hum");
|
|
|
- mqttclient.publish(_tmp_topic_out, _hum_chararr, confMqtt.mqtt_outRetain_sensors);
|
|
|
- yield();
|
|
|
- }
|
|
|
-
|
|
|
- dtostrf(sensor_DHT_currTemp_raw, 1, 1, _temp_chararr);
|
|
|
- sprintf(_hum_chararr, "%2i", sensor_DHT_currHum_raw);
|
|
|
+ char _tmp_topic_out[50];
|
|
|
+ char _temp_chararr[6];
|
|
|
+ char _hum_chararr[4];
|
|
|
|
|
|
- // if (serialdebug)
|
|
|
- // {
|
|
|
- // Serial.print(F(",'temp_raw':"));
|
|
|
- // Serial.print(_temp_chararr);
|
|
|
- // }
|
|
|
- snprintf(_tmp_topic_out, 50, "%s/%s", confMqtt.mqtt_topic_out, "temp_raw");
|
|
|
- mqttclient.publish(_tmp_topic_out, _temp_chararr);
|
|
|
- yield();
|
|
|
- // if (serialdebug)
|
|
|
- // {
|
|
|
- // Serial.print(F(",'hum_raw':"));
|
|
|
- // Serial.print(sensor_DHT_currHum_raw);
|
|
|
- // }
|
|
|
- snprintf(_tmp_topic_out, 50, "%s/%s", confMqtt.mqtt_topic_out, "hum_raw");
|
|
|
- mqttclient.publish(_tmp_topic_out, _hum_chararr);
|
|
|
- yield();
|
|
|
- #endif // ENABLE_SENSOR_DHT22
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- #ifdef ENABLE_SENSORS_ONEWIRE
|
|
|
-
|
|
|
- if (owTemp_feed > -50) {
|
|
|
- snprintf(_tmp_topic_out, 50, "%s/%s", confMqtt.mqtt_topic_out, "temp_feed");
|
|
|
- dtostrf(owTemp_feed, 1, 0, _temp_chararr);
|
|
|
+ #ifdef ENABLE_SENSOR_DHT22
|
|
|
+ if (confSens.DHT_enable && sensor_DHT_lastUpdate != 0 && (millis() - sensor_DHT_lastUpdate) < 120000)
|
|
|
+ { // ensure values are not too old
|
|
|
+ dtostrf(sensor_DHT_currTemp, 1, 1, _temp_chararr);
|
|
|
+ sprintf(_hum_chararr, "%2i", sensor_DHT_currHum);
|
|
|
+
|
|
|
+ // if (serialdebug)
|
|
|
+ // {
|
|
|
+ // Serial.print(F("sensors: {"));
|
|
|
+ // Serial.print("'temp':");
|
|
|
+ // Serial.print(_temp_chararr);
|
|
|
+ // }
|
|
|
+
|
|
|
+ if (force || sensor_DHT_currTemp != currTemp_lastPublished)
|
|
|
+ {
|
|
|
+ snprintf(_tmp_topic_out, 50, "%s/%s", confMqtt.mqtt_topic_out, "temp");
|
|
|
+ mqttclient.publish(_tmp_topic_out, _temp_chararr, confMqtt.mqtt_outRetain_sensors);
|
|
|
+ currTemp_lastPublished = sensor_DHT_currTemp;
|
|
|
+ yield();
|
|
|
+ }
|
|
|
+
|
|
|
+ // if (serialdebug)
|
|
|
+ // {
|
|
|
+ // Serial.print(F(",'hum':"));
|
|
|
+ // Serial.print(sensor_DHT_currHum);
|
|
|
+ // }
|
|
|
+
|
|
|
+ if (force || sensor_DHT_currHum != currHum_lastPublished)
|
|
|
+ {
|
|
|
+ snprintf(_tmp_topic_out, 50, "%s/%s", confMqtt.mqtt_topic_out, "hum");
|
|
|
+ mqttclient.publish(_tmp_topic_out, _hum_chararr, confMqtt.mqtt_outRetain_sensors);
|
|
|
+ yield();
|
|
|
+ }
|
|
|
+
|
|
|
+ dtostrf(sensor_DHT_currTemp_raw, 1, 1, _temp_chararr);
|
|
|
+ sprintf(_hum_chararr, "%2i", sensor_DHT_currHum_raw);
|
|
|
+
|
|
|
+ // if (serialdebug)
|
|
|
+ // {
|
|
|
+ // Serial.print(F(",'temp_raw':"));
|
|
|
+ // Serial.print(_temp_chararr);
|
|
|
+ // }
|
|
|
+ snprintf(_tmp_topic_out, 50, "%s/%s", confMqtt.mqtt_topic_out, "temp_raw");
|
|
|
mqttclient.publish(_tmp_topic_out, _temp_chararr);
|
|
|
yield();
|
|
|
- }
|
|
|
-
|
|
|
- if (owTemp_return > -50) {
|
|
|
- snprintf(_tmp_topic_out, 50, "%s/%s", confMqtt.mqtt_topic_out, "temp_return");
|
|
|
- dtostrf(owTemp_return, 1, 0, _temp_chararr);
|
|
|
- mqttclient.publish(_tmp_topic_out, _temp_chararr);
|
|
|
+ // if (serialdebug)
|
|
|
+ // {
|
|
|
+ // Serial.print(F(",'hum_raw':"));
|
|
|
+ // Serial.print(sensor_DHT_currHum_raw);
|
|
|
+ // }
|
|
|
+ snprintf(_tmp_topic_out, 50, "%s/%s", confMqtt.mqtt_topic_out, "hum_raw");
|
|
|
+ mqttclient.publish(_tmp_topic_out, _hum_chararr);
|
|
|
yield();
|
|
|
- }
|
|
|
+ }
|
|
|
+ #endif // ENABLE_SENSOR_DHT22
|
|
|
|
|
|
- if (owTemp_out > -50) {
|
|
|
- snprintf(_tmp_topic_out, 50, "%s/%s", confMqtt.mqtt_topic_out, "temp_out");
|
|
|
- dtostrf(owTemp_out, 1, 0, _temp_chararr);
|
|
|
- mqttclient.publish(_tmp_topic_out, _temp_chararr);
|
|
|
- yield();
|
|
|
- }
|
|
|
|
|
|
- #endif // ENABLE_SENSORS_ONEWIRE
|
|
|
+ #ifdef ENABLE_SENSORS_ONEWIRE
|
|
|
+ if (owTemp_feed > -50.0) {
|
|
|
+ snprintf(_tmp_topic_out, 50, "%s/%s", confMqtt.mqtt_topic_out, "temp_feed");
|
|
|
+ dtostrf(owTemp_feed, 1, 1, _temp_chararr);
|
|
|
+ mqttclient.publish(_tmp_topic_out, _temp_chararr);
|
|
|
+ yield();
|
|
|
+ }
|
|
|
|
|
|
+ if (owTemp_return > -50.0) {
|
|
|
+ snprintf(_tmp_topic_out, 50, "%s/%s", confMqtt.mqtt_topic_out, "temp_return");
|
|
|
+ dtostrf(owTemp_return, 1, 1, _temp_chararr);
|
|
|
+ mqttclient.publish(_tmp_topic_out, _temp_chararr);
|
|
|
+ yield();
|
|
|
+ }
|
|
|
|
|
|
- // if (serialdebug)
|
|
|
- // Serial.println("}");
|
|
|
- }
|
|
|
+ if (owTemp_out > -50.0) {
|
|
|
+ snprintf(_tmp_topic_out, 50, "%s/%s", confMqtt.mqtt_topic_out, "temp_out");
|
|
|
+ dtostrf(owTemp_out, 1, 1, _temp_chararr);
|
|
|
+ mqttclient.publish(_tmp_topic_out, _temp_chararr);
|
|
|
+ yield();
|
|
|
+ }
|
|
|
+ #endif // ENABLE_SENSORS_ONEWIRE
|
|
|
}
|
|
|
|
|
|
void publishCurrentPIRValue()
|