diff --git a/include/MqttHandleInverter.h b/include/MqttHandleInverter.h index 29511ae14..ea3a6e381 100644 --- a/include/MqttHandleInverter.h +++ b/include/MqttHandleInverter.h @@ -50,16 +50,18 @@ class MqttHandleInverterClass { LimitNonPersistentAbsolute, Power, Restart, + ResetRfStats, }; static constexpr frozen::string _cmdtopic = "+/cmd/"; - static constexpr frozen::map _subscriptions = { + static constexpr frozen::map _subscriptions = { { "limit_persistent_relative", Topic::LimitPersistentRelative }, { "limit_persistent_absolute", Topic::LimitPersistentAbsolute }, { "limit_nonpersistent_relative", Topic::LimitNonPersistentRelative }, { "limit_nonpersistent_absolute", Topic::LimitNonPersistentAbsolute }, { "power", Topic::Power }, { "restart", Topic::Restart }, + { "reset_rf_stats", Topic::ResetRfStats }, }; void onMqttMessage(Topic t, const espMqttClientTypes::MessageProperties& properties, const char* topic, const uint8_t* payload, const size_t len, const size_t index, const size_t total); diff --git a/src/MqttHandleHass.cpp b/src/MqttHandleHass.cpp index 3971a3a67..dd3e93eb2 100644 --- a/src/MqttHandleHass.cpp +++ b/src/MqttHandleHass.cpp @@ -77,6 +77,7 @@ void MqttHandleHassClass::publishConfig() publishInverterButton(inv, "Turn Inverter Off", "mdi:power-plug-off", "config", "", "cmd/power", "0"); publishInverterButton(inv, "Turn Inverter On", "mdi:power-plug", "config", "", "cmd/power", "1"); publishInverterButton(inv, "Restart Inverter", "", "config", "restart", "cmd/restart", "1"); + publishInverterButton(inv, "Reset Radio Statistics", "", "config", "", "cmd/reset_rf_stats", "1"); publishInverterNumber(inv, "Limit NonPersistent Relative", "mdi:speedometer", "config", "cmd/limit_nonpersistent_relative", "status/limit_relative", "%", 0, 100, 0.1); publishInverterNumber(inv, "Limit Persistent Relative", "mdi:speedometer", "config", "cmd/limit_persistent_relative", "status/limit_relative", "%", 0, 100, 0.1); diff --git a/src/MqttHandleInverter.cpp b/src/MqttHandleInverter.cpp index d9dfbedb1..8e7206635 100644 --- a/src/MqttHandleInverter.cpp +++ b/src/MqttHandleInverter.cpp @@ -229,6 +229,16 @@ void MqttHandleInverterClass::onMqttMessage(Topic t, const espMqttClientTypes::M } else { MessageOutput.println("Ignored because retained or numeric value not '1'"); } + break; + + case Topic::ResetRfStats: + // Reset RF Stats + MessageOutput.printf("Reset RF stats\r\n"); + if (!properties.retain && payload_val == 1) { + inv->resetRadioStats(); + } else { + MessageOutput.println("Ignored because retained or numeric value not '1'"); + } } }