Browse Source

set mqtt sensor data as retained messages

Thomas Buck 1 year ago
parent
commit
382886d3ac
1 changed files with 12 additions and 12 deletions
  1. 12
    12
      src/main.cpp

+ 12
- 12
src/main.cpp View File

620
     }
620
     }
621
 
621
 
622
     if (found_bme1) {
622
     if (found_bme1) {
623
-        mqtt.publish(SENSOR_LOCATION "/temperature", String(bme1_temp()).c_str());
624
-        mqtt.publish(SENSOR_LOCATION "/humidity", String(bme1_humid()).c_str());
625
-        mqtt.publish(SENSOR_LOCATION "/pressure", String(bme1_pressure()).c_str());
623
+        mqtt.publish(SENSOR_LOCATION "/temperature", String(bme1_temp()).c_str(), true);
624
+        mqtt.publish(SENSOR_LOCATION "/humidity", String(bme1_humid()).c_str(), true);
625
+        mqtt.publish(SENSOR_LOCATION "/pressure", String(bme1_pressure()).c_str(), true);
626
     } else if (found_bme2) {
626
     } else if (found_bme2) {
627
-        mqtt.publish(SENSOR_LOCATION "/temperature", String(bme2_temp()).c_str());
628
-        mqtt.publish(SENSOR_LOCATION "/humidity", String(bme2_humid()).c_str());
629
-        mqtt.publish(SENSOR_LOCATION "/pressure", String(bme2_pressure()).c_str());
627
+        mqtt.publish(SENSOR_LOCATION "/temperature", String(bme2_temp()).c_str(), true);
628
+        mqtt.publish(SENSOR_LOCATION "/humidity", String(bme2_humid()).c_str(), true);
629
+        mqtt.publish(SENSOR_LOCATION "/pressure", String(bme2_pressure()).c_str(), true);
630
     } else if (found_sht) {
630
     } else if (found_sht) {
631
-        mqtt.publish(SENSOR_LOCATION "/temperature", String(sht_temp()).c_str());
632
-        mqtt.publish(SENSOR_LOCATION "/humidity", String(sht_humid()).c_str());
631
+        mqtt.publish(SENSOR_LOCATION "/temperature", String(sht_temp()).c_str(), true);
632
+        mqtt.publish(SENSOR_LOCATION "/humidity", String(sht_humid()).c_str(), true);
633
     }
633
     }
634
 
634
 
635
 #ifdef ENABLE_CCS811
635
 #ifdef ENABLE_CCS811
636
     if (found_ccs1) {
636
     if (found_ccs1) {
637
-        mqtt.publish(SENSOR_LOCATION "/eco2", String(ccs1_eco2()).c_str());
638
-        mqtt.publish(SENSOR_LOCATION "/tvoc", String(ccs1_tvoc()).c_str());
637
+        mqtt.publish(SENSOR_LOCATION "/eco2", String(ccs1_eco2()).c_str(), true);
638
+        mqtt.publish(SENSOR_LOCATION "/tvoc", String(ccs1_tvoc()).c_str(), true);
639
     } else if (found_ccs2) {
639
     } else if (found_ccs2) {
640
-        mqtt.publish(SENSOR_LOCATION "/eco2", String(ccs2_eco2()).c_str());
641
-        mqtt.publish(SENSOR_LOCATION "/tvoc", String(ccs2_tvoc()).c_str());
640
+        mqtt.publish(SENSOR_LOCATION "/eco2", String(ccs2_eco2()).c_str(), true);
641
+        mqtt.publish(SENSOR_LOCATION "/tvoc", String(ccs2_tvoc()).c_str(), true);
642
     }
642
     }
643
 #endif // ENABLE_CCS811
643
 #endif // ENABLE_CCS811
644
 }
644
 }

Loading…
Cancel
Save