Feature: Allow reset of radio statistics via mqtt
This commit is contained in:
parent
0c012bf62a
commit
181802a76b
@ -50,16 +50,18 @@ private:
|
|||||||
LimitNonPersistentAbsolute,
|
LimitNonPersistentAbsolute,
|
||||||
Power,
|
Power,
|
||||||
Restart,
|
Restart,
|
||||||
|
ResetRfStats,
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr frozen::string _cmdtopic = "+/cmd/";
|
static constexpr frozen::string _cmdtopic = "+/cmd/";
|
||||||
static constexpr frozen::map<frozen::string, Topic, 6> _subscriptions = {
|
static constexpr frozen::map<frozen::string, Topic, 7> _subscriptions = {
|
||||||
{ "limit_persistent_relative", Topic::LimitPersistentRelative },
|
{ "limit_persistent_relative", Topic::LimitPersistentRelative },
|
||||||
{ "limit_persistent_absolute", Topic::LimitPersistentAbsolute },
|
{ "limit_persistent_absolute", Topic::LimitPersistentAbsolute },
|
||||||
{ "limit_nonpersistent_relative", Topic::LimitNonPersistentRelative },
|
{ "limit_nonpersistent_relative", Topic::LimitNonPersistentRelative },
|
||||||
{ "limit_nonpersistent_absolute", Topic::LimitNonPersistentAbsolute },
|
{ "limit_nonpersistent_absolute", Topic::LimitNonPersistentAbsolute },
|
||||||
{ "power", Topic::Power },
|
{ "power", Topic::Power },
|
||||||
{ "restart", Topic::Restart },
|
{ "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);
|
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);
|
||||||
|
|||||||
@ -77,6 +77,7 @@ void MqttHandleHassClass::publishConfig()
|
|||||||
publishInverterButton(inv, "Turn Inverter Off", "mdi:power-plug-off", "config", "", "cmd/power", "0");
|
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, "Turn Inverter On", "mdi:power-plug", "config", "", "cmd/power", "1");
|
||||||
publishInverterButton(inv, "Restart Inverter", "", "config", "restart", "cmd/restart", "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 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);
|
publishInverterNumber(inv, "Limit Persistent Relative", "mdi:speedometer", "config", "cmd/limit_persistent_relative", "status/limit_relative", "%", 0, 100, 0.1);
|
||||||
|
|||||||
@ -229,6 +229,16 @@ void MqttHandleInverterClass::onMqttMessage(Topic t, const espMqttClientTypes::M
|
|||||||
} else {
|
} else {
|
||||||
MessageOutput.println("Ignored because retained or numeric value not '1'");
|
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'");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user