consistent sorting of values in console

This commit is contained in:
proddy
2020-06-06 21:42:51 +02:00
parent 6d8baab669
commit 34d782a58a

View File

@@ -177,10 +177,13 @@ void EMSESP::show_values(uuid::console::Shell & shell) {
} }
// show EMS device values // show EMS device values
for (const auto & emsdevice : emsdevices) { // do this in the order of factory classes to keep a consistent order when displaying
if (emsdevice) { for (const auto & device_class : EMSFactory::device_handlers()) {
emsdevice->show_values(shell); for (const auto & emsdevice : emsdevices) {
shell.println(); if ((emsdevice) && (emsdevice->device_type() == device_class.first)) {
emsdevice->show_values(shell);
shell.println();
}
} }
} }
@@ -454,17 +457,6 @@ void EMSESP::add_context_menus() {
// for each associated EMS device go and get its system information // for each associated EMS device go and get its system information
void EMSESP::show_devices(uuid::console::Shell & shell) { void EMSESP::show_devices(uuid::console::Shell & shell) {
#ifdef EMSESP_DEBUG
// for debugging ony
// prints out DeviceType (UNKNOWN = 0, SERVICEKEY, BOILER, THERMOSTAT, MIXING, SOLAR, HEATPUMP, GATEWAY, SWITCH, CONTROLLER, CONNECT)
// from emsdevice.h
shell.printf(F("(debug) Registered EMS device handlers:"));
for (const auto & pair : EMSFactory::device_handlers()) {
shell.printf(F(" %d"), pair.first);
}
shell.println();
#endif
if (emsdevices.empty()) { if (emsdevices.empty()) {
shell.printfln(F("No EMS devices detected. Try scanning using the 'scan devices' command.")); shell.printfln(F("No EMS devices detected. Try scanning using the 'scan devices' command."));
return; return;
@@ -472,16 +464,22 @@ void EMSESP::show_devices(uuid::console::Shell & shell) {
shell.printfln(F("These EMS devices are currently active:")); shell.printfln(F("These EMS devices are currently active:"));
shell.println(); shell.println();
for (const auto & emsdevice : emsdevices) {
if (emsdevice) { // for all device objects from emsdevice.h (UNKNOWN, SERVICEKEY, BOILER, THERMOSTAT, MIXING, SOLAR, HEATPUMP, GATEWAY, SWITCH, CONTROLLER, CONNECT)
shell.printf(F("%s: %s"), emsdevice->device_type_name().c_str(), emsdevice->to_string().c_str()); // so we keep a consistent order
if ((emsdevice->device_type() == EMSdevice::DeviceType::THERMOSTAT) && (emsdevice->device_id() == actual_master_thermostat())) { for (const auto & device_class : EMSFactory::device_handlers()) {
shell.printf(F(" ** master device **")); // shell.printf(F("[factory ID: %d] "), device_class.first);
for (const auto & emsdevice : emsdevices) {
if ((emsdevice) && (emsdevice->device_type() == device_class.first)) {
shell.printf(F("%s: %s"), emsdevice->device_type_name().c_str(), emsdevice->to_string().c_str());
if ((emsdevice->device_type() == EMSdevice::DeviceType::THERMOSTAT) && (emsdevice->device_id() == actual_master_thermostat())) {
shell.printf(F(" ** master device **"));
}
shell.println();
emsdevice->show_telegram_handlers(shell);
emsdevice->show_mqtt_handlers(shell);
shell.println();
} }
shell.println();
emsdevice->show_telegram_handlers(shell);
emsdevice->show_mqtt_handlers(shell);
shell.println();
} }
} }
} }