values: Include boot count in state messages
This should be useful for diagnostic purposes. It's not brought out into a proper sensor in HA, but it can be seen using the MQTT message viewer in the HA device configuration tool.master
parent
6c1757b43d
commit
38df5d00c4
|
@ -52,6 +52,7 @@ void setup() {
|
||||||
reboot();
|
reboot();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
values.boot_count = boot_count;
|
||||||
if (!values.read(&ss)) {
|
if (!values.read(&ss)) {
|
||||||
auto msg = "Failed to get sensor values";
|
auto msg = "Failed to get sensor values";
|
||||||
Serial.println(msg);
|
Serial.println(msg);
|
||||||
|
@ -63,6 +64,7 @@ void setup() {
|
||||||
Serial.printf(" Temperature: %.02f\n", values.temperature);
|
Serial.printf(" Temperature: %.02f\n", values.temperature);
|
||||||
Serial.printf(" Battery: %.02f\n", values.battery);
|
Serial.printf(" Battery: %.02f\n", values.battery);
|
||||||
Serial.printf(" RSSI: %d\n", values.rssi);
|
Serial.printf(" RSSI: %d\n", values.rssi);
|
||||||
|
Serial.printf(" Boot Count: %d\n", values.boot_count);
|
||||||
if (!values.send(&mqtt, TOPIC_STATE)) {
|
if (!values.send(&mqtt, TOPIC_STATE)) {
|
||||||
Serial.println("Failed to send sensor values");
|
Serial.println("Failed to send sensor values");
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,11 +16,12 @@ bool Values::read(Adafruit_seesaw* ss) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Values::send(PubSubClient* mqtt, const char* topic) {
|
bool Values::send(PubSubClient* mqtt, const char* topic) {
|
||||||
StaticJsonDocument<64> doc;
|
StaticJsonDocument<96> doc;
|
||||||
doc["moisture"] = moisture;
|
doc["moisture"] = moisture;
|
||||||
doc["temperature"] = round2(temperature);
|
doc["temperature"] = round2(temperature);
|
||||||
doc["battery_level"] = round2(battery);
|
doc["battery_level"] = round2(battery);
|
||||||
doc["rssi"] = rssi;
|
doc["rssi"] = rssi;
|
||||||
|
doc["boot_count"] = boot_count;
|
||||||
|
|
||||||
String msg;
|
String msg;
|
||||||
serializeJson(doc, msg);
|
serializeJson(doc, msg);
|
||||||
|
|
|
@ -7,6 +7,7 @@ class Values {
|
||||||
float temperature;
|
float temperature;
|
||||||
float battery;
|
float battery;
|
||||||
int8_t rssi;
|
int8_t rssi;
|
||||||
|
uint32_t boot_count;
|
||||||
|
|
||||||
Values() {};
|
Values() {};
|
||||||
~Values() {};
|
~Values() {};
|
||||||
|
|
Loading…
Reference in New Issue