more commands in ems menu

This commit is contained in:
proddy
2020-06-07 18:01:23 +02:00
parent 34d782a58a
commit 3bd5be2de6
3 changed files with 40 additions and 14 deletions

View File

@@ -98,7 +98,7 @@ void EMSESPShell::add_console_commands() {
CommandFlags::USER,
flash_string_vector{F_(refresh)},
[&](Shell & shell, const std::vector<std::string> & arguments __attribute__((unused))) {
shell.printfln(F("Refreshing console and fetching device data"));
shell.printfln(F("Requesting data from EMS devices"));
_console_commands_loaded = false;
add_console_commands();
EMSESP::fetch_device_values();

View File

@@ -168,15 +168,20 @@ void EMSESP::show_emsbus(uuid::console::Shell & shell) {
shell.println();
}
// display in the console all system stats
// and for each associated EMS device go and request data values
// display in the console all the data we have from ems devices and external sensors
void EMSESP::show_values(uuid::console::Shell & shell) {
if (sensor_devices().empty() && emsdevices.empty()) {
shell.printfln(F("No data collected from EMS devices. Try 'refresh'."));
show_device_values(shell);
show_sensor_values(shell);
}
// show EMS device values
void EMSESP::show_device_values(uuid::console::Shell & shell) {
if (emsdevices.empty()) {
shell.printfln(F("No EMS devices detected yet. Try 'scan devices' from the ems menu."));
shell.println();
return;
}
// show EMS device values
// do this in the order of factory classes to keep a consistent order when displaying
for (const auto & device_class : EMSFactory::device_handlers()) {
for (const auto & emsdevice : emsdevices) {
@@ -186,17 +191,20 @@ void EMSESP::show_values(uuid::console::Shell & shell) {
}
}
}
shell.println();
}
// Dallas sensors (if available)
char valuestr[8] = {0}; // for formatting temp
if (!sensor_devices().empty()) {
shell.printfln(F("External temperature sensors:"));
for (const auto & device : sensor_devices()) {
shell.printfln(F(" Sensor ID %s: %s°C"), device.to_string().c_str(), Helpers::render_value(valuestr, device.temperature_c_, 2));
}
shell.println();
// show Dallas sensors
void EMSESP::show_sensor_values(uuid::console::Shell & shell) {
if (sensor_devices().empty()) {
return;
}
char valuestr[8] = {0}; // for formatting temp
shell.printfln(F("External temperature sensors:"));
for (const auto & device : sensor_devices()) {
shell.printfln(F(" Sensor ID %s: %s°C"), device.to_string().c_str(), Helpers::render_value(valuestr, device.temperature_c_, 2));
}
shell.println();
}
@@ -671,6 +679,21 @@ void EMSESP::console_commands(Shell & shell, unsigned int context) {
show_emsbus(shell);
});
EMSESPShell::commands->add_command(ShellContext::EMS,
CommandFlags::USER,
flash_string_vector{F_(show), F_(values)},
[](Shell & shell, const std::vector<std::string> & arguments __attribute__((unused))) {
EMSESP::show_device_values(shell);
});
EMSESPShell::commands->add_command(ShellContext::EMS,
CommandFlags::USER,
flash_string_vector{F_(refresh)},
[&](Shell & shell, const std::vector<std::string> & arguments __attribute__((unused))) {
shell.printfln(F("Requesting data from EMS devices"));
EMSESP::fetch_device_values();
});
EMSESPShell::commands->add_command(
ShellContext::EMS,
CommandFlags::ADMIN,

View File

@@ -86,6 +86,9 @@ class EMSESP {
static void actual_master_thermostat(const uint8_t device_id);
static void show_values(uuid::console::Shell & shell);
static void show_device_values(uuid::console::Shell & shell);
static void show_sensor_values(uuid::console::Shell & shell);
static void show_devices(uuid::console::Shell & shell);
static void show_emsbus(uuid::console::Shell & shell);