mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-08 08:49:52 +03:00
more commands in ems menu
This commit is contained in:
@@ -98,7 +98,7 @@ void EMSESPShell::add_console_commands() {
|
|||||||
CommandFlags::USER,
|
CommandFlags::USER,
|
||||||
flash_string_vector{F_(refresh)},
|
flash_string_vector{F_(refresh)},
|
||||||
[&](Shell & shell, const std::vector<std::string> & arguments __attribute__((unused))) {
|
[&](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;
|
_console_commands_loaded = false;
|
||||||
add_console_commands();
|
add_console_commands();
|
||||||
EMSESP::fetch_device_values();
|
EMSESP::fetch_device_values();
|
||||||
|
|||||||
@@ -168,15 +168,20 @@ void EMSESP::show_emsbus(uuid::console::Shell & shell) {
|
|||||||
shell.println();
|
shell.println();
|
||||||
}
|
}
|
||||||
|
|
||||||
// display in the console all system stats
|
// display in the console all the data we have from ems devices and external sensors
|
||||||
// and for each associated EMS device go and request data values
|
|
||||||
void EMSESP::show_values(uuid::console::Shell & shell) {
|
void EMSESP::show_values(uuid::console::Shell & shell) {
|
||||||
if (sensor_devices().empty() && emsdevices.empty()) {
|
show_device_values(shell);
|
||||||
shell.printfln(F("No data collected from EMS devices. Try 'refresh'."));
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// show EMS device values
|
|
||||||
// do this in the order of factory classes to keep a consistent order when displaying
|
// 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 & device_class : EMSFactory::device_handlers()) {
|
||||||
for (const auto & emsdevice : emsdevices) {
|
for (const auto & emsdevice : emsdevices) {
|
||||||
@@ -186,17 +191,20 @@ void EMSESP::show_values(uuid::console::Shell & shell) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
shell.println();
|
||||||
|
}
|
||||||
|
|
||||||
// Dallas sensors (if available)
|
// show Dallas sensors
|
||||||
char valuestr[8] = {0}; // for formatting temp
|
void EMSESP::show_sensor_values(uuid::console::Shell & shell) {
|
||||||
if (!sensor_devices().empty()) {
|
if (sensor_devices().empty()) {
|
||||||
shell.printfln(F("External temperature sensors:"));
|
return;
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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();
|
shell.println();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -671,6 +679,21 @@ void EMSESP::console_commands(Shell & shell, unsigned int context) {
|
|||||||
show_emsbus(shell);
|
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(
|
EMSESPShell::commands->add_command(
|
||||||
ShellContext::EMS,
|
ShellContext::EMS,
|
||||||
CommandFlags::ADMIN,
|
CommandFlags::ADMIN,
|
||||||
|
|||||||
@@ -86,6 +86,9 @@ class EMSESP {
|
|||||||
static void actual_master_thermostat(const uint8_t device_id);
|
static void actual_master_thermostat(const uint8_t device_id);
|
||||||
|
|
||||||
static void show_values(uuid::console::Shell & shell);
|
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_devices(uuid::console::Shell & shell);
|
||||||
static void show_emsbus(uuid::console::Shell & shell);
|
static void show_emsbus(uuid::console::Shell & shell);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user