mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
show mqtt-count and sensor-reads in info
This commit is contained in:
@@ -131,6 +131,10 @@ class EMSESP {
|
||||
return (!(dallassensor_.sensors().empty()));
|
||||
}
|
||||
|
||||
static uint32_t sensor_reads() {
|
||||
return dallassensor_.reads();
|
||||
}
|
||||
|
||||
static uint32_t sensor_fails() {
|
||||
return dallassensor_.fails();
|
||||
}
|
||||
|
||||
12
src/mqtt.cpp
12
src/mqtt.cpp
@@ -347,15 +347,9 @@ void Mqtt::on_message(const char * fulltopic, const char * payload, size_t len)
|
||||
return; // invalid topic name
|
||||
}
|
||||
cmd_only++; // skip the /
|
||||
int8_t id = -1;
|
||||
// check for hcx/ prefix, commented out, this is now in command::call
|
||||
// if (cmd_only[0] == 'h' && cmd_only[1] == 'c' && cmd_only[3] == '/') {
|
||||
// id = cmd_only[2] - '0';
|
||||
// cmd_only += 4;
|
||||
// }
|
||||
// LOG_INFO(F("devicetype= %d, topic = %s, cmd = %s, message = %s, id = %d"), mf.device_type_, topic, cmd_only, message, id);
|
||||
if (!Command::call(mf.device_type_, cmd_only, message, id)) {
|
||||
LOG_ERROR(F("No matching cmd (%s) in topic %s, id %d, or invalid data"), cmd_only, topic, id);
|
||||
// LOG_INFO(F("devicetype= %d, topic = %s, cmd = %s, message = %s), mf.device_type_, topic, cmd_only, message);
|
||||
if (!Command::call(mf.device_type_, cmd_only, message)) {
|
||||
LOG_ERROR(F("No matching cmd (%s) in topic %s, or invalid data"), cmd_only, topic);
|
||||
Mqtt::publish(F_(response), "unknown");
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -145,6 +145,10 @@ class Mqtt {
|
||||
return mqtt_base_;
|
||||
}
|
||||
|
||||
static uint16_t publish_count() {
|
||||
return mqtt_message_id_;
|
||||
}
|
||||
|
||||
static uint32_t publish_fails() {
|
||||
return mqtt_publish_fails_;
|
||||
}
|
||||
|
||||
@@ -886,10 +886,6 @@ bool System::command_settings(const char * value, const int8_t id, JsonObject &
|
||||
// export status information including some basic settings
|
||||
// e.g. http://ems-esp/api?device=system&cmd=info
|
||||
bool System::command_info(const char * value, const int8_t id, JsonObject & json) {
|
||||
if (id == 0) {
|
||||
return EMSESP::system_.heartbeat_json(json);
|
||||
}
|
||||
|
||||
JsonObject node;
|
||||
|
||||
node = json.createNestedObject("System");
|
||||
@@ -925,10 +921,12 @@ bool System::command_info(const char * value, const int8_t id, JsonObject & json
|
||||
node["rx line quality"] = EMSESP::rxservice_.quality();
|
||||
node["tx line quality"] = EMSESP::txservice_.quality();
|
||||
if (Mqtt::enabled()) {
|
||||
node["#MQTT publishes"] = Mqtt::publish_count();
|
||||
node["#MQTT publish fails"] = Mqtt::publish_fails();
|
||||
}
|
||||
if (EMSESP::dallas_enabled()) {
|
||||
node["#dallas sensors"] = EMSESP::sensor_devices().size();
|
||||
node["#dallas reads"] = EMSESP::sensor_reads();
|
||||
node["#dallas fails"] = EMSESP::sensor_fails();
|
||||
}
|
||||
}
|
||||
@@ -948,8 +946,8 @@ bool System::command_info(const char * value, const int8_t id, JsonObject & json
|
||||
}
|
||||
if (EMSESP::sensor_devices().size()) {
|
||||
JsonObject obj = devices2.createNestedObject();
|
||||
obj["type"] = F("Dallassensor");
|
||||
obj["name"] = F("Dallassensor");
|
||||
obj["type"] = F_(Dallassensor);
|
||||
obj["name"] = F_(Dallassensor);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user