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()));
|
return (!(dallassensor_.sensors().empty()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint32_t sensor_reads() {
|
||||||
|
return dallassensor_.reads();
|
||||||
|
}
|
||||||
|
|
||||||
static uint32_t sensor_fails() {
|
static uint32_t sensor_fails() {
|
||||||
return dallassensor_.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
|
return; // invalid topic name
|
||||||
}
|
}
|
||||||
cmd_only++; // skip the /
|
cmd_only++; // skip the /
|
||||||
int8_t id = -1;
|
// LOG_INFO(F("devicetype= %d, topic = %s, cmd = %s, message = %s), mf.device_type_, topic, cmd_only, message);
|
||||||
// check for hcx/ prefix, commented out, this is now in command::call
|
if (!Command::call(mf.device_type_, cmd_only, message)) {
|
||||||
// if (cmd_only[0] == 'h' && cmd_only[1] == 'c' && cmd_only[3] == '/') {
|
LOG_ERROR(F("No matching cmd (%s) in topic %s, or invalid data"), cmd_only, topic);
|
||||||
// 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);
|
|
||||||
Mqtt::publish(F_(response), "unknown");
|
Mqtt::publish(F_(response), "unknown");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -145,6 +145,10 @@ class Mqtt {
|
|||||||
return mqtt_base_;
|
return mqtt_base_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint16_t publish_count() {
|
||||||
|
return mqtt_message_id_;
|
||||||
|
}
|
||||||
|
|
||||||
static uint32_t publish_fails() {
|
static uint32_t publish_fails() {
|
||||||
return mqtt_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
|
// export status information including some basic settings
|
||||||
// e.g. http://ems-esp/api?device=system&cmd=info
|
// e.g. http://ems-esp/api?device=system&cmd=info
|
||||||
bool System::command_info(const char * value, const int8_t id, JsonObject & json) {
|
bool System::command_info(const char * value, const int8_t id, JsonObject & json) {
|
||||||
if (id == 0) {
|
|
||||||
return EMSESP::system_.heartbeat_json(json);
|
|
||||||
}
|
|
||||||
|
|
||||||
JsonObject node;
|
JsonObject node;
|
||||||
|
|
||||||
node = json.createNestedObject("System");
|
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["rx line quality"] = EMSESP::rxservice_.quality();
|
||||||
node["tx line quality"] = EMSESP::txservice_.quality();
|
node["tx line quality"] = EMSESP::txservice_.quality();
|
||||||
if (Mqtt::enabled()) {
|
if (Mqtt::enabled()) {
|
||||||
|
node["#MQTT publishes"] = Mqtt::publish_count();
|
||||||
node["#MQTT publish fails"] = Mqtt::publish_fails();
|
node["#MQTT publish fails"] = Mqtt::publish_fails();
|
||||||
}
|
}
|
||||||
if (EMSESP::dallas_enabled()) {
|
if (EMSESP::dallas_enabled()) {
|
||||||
node["#dallas sensors"] = EMSESP::sensor_devices().size();
|
node["#dallas sensors"] = EMSESP::sensor_devices().size();
|
||||||
|
node["#dallas reads"] = EMSESP::sensor_reads();
|
||||||
node["#dallas fails"] = EMSESP::sensor_fails();
|
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()) {
|
if (EMSESP::sensor_devices().size()) {
|
||||||
JsonObject obj = devices2.createNestedObject();
|
JsonObject obj = devices2.createNestedObject();
|
||||||
obj["type"] = F("Dallassensor");
|
obj["type"] = F_(Dallassensor);
|
||||||
obj["name"] = F("Dallassensor");
|
obj["name"] = F_(Dallassensor);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user