mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-08 00:39:50 +03:00
This commit is contained in:
@@ -1202,11 +1202,11 @@ void EMSdevice::getCustomizationEntities(std::vector<std::string> & entity_ids)
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(EMSESP_STANDALONE)
|
||||
// dumps all entity values in native English
|
||||
// the code is intended to run only once standalone, outside the ESP32 so not optimized for memory efficiency
|
||||
// pipe symbols (|) are escaped so they can be converted to Markdown in the Wiki
|
||||
// format is: device name,device type,product id,shortname,fullname,type [options...] \\| (min/max),uom,writeable,discovery entityid v3.4, discovery entityid
|
||||
#if defined(EMSESP_STANDALONE)
|
||||
void EMSdevice::dump_value_info() {
|
||||
for (auto & dv : devicevalues_) {
|
||||
if (dv.fullname != nullptr) {
|
||||
@@ -1375,6 +1375,16 @@ void EMSdevice::dump_value_info() {
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// dumps all telegram details to a new vector
|
||||
#if defined(EMSESP_STANDALONE)
|
||||
void EMSdevice::dump_telegram_info(std::vector<TelegramFunctionDump> & telegram_functions_dump) {
|
||||
for (auto & tf : telegram_functions_) {
|
||||
telegram_functions_dump.emplace_back(tf.telegram_type_id_, tf.telegram_type_name_, tf.fetch_, tf.received_, tf.process_function_ != nullptr);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// builds json for a specific device value / entity
|
||||
// cmd is the endpoint or name of the device entity
|
||||
// returns false if failed, otherwise true
|
||||
|
||||
@@ -457,6 +457,21 @@ class EMSdevice {
|
||||
*/
|
||||
|
||||
#if defined(EMSESP_STANDALONE)
|
||||
struct TelegramFunctionDump {
|
||||
uint16_t type_id_;
|
||||
const char * name_;
|
||||
bool fetch_;
|
||||
bool received_;
|
||||
bool cmd_;
|
||||
TelegramFunctionDump(uint16_t type_id, const char * name, bool fetch, bool received, bool cmd)
|
||||
: type_id_(type_id)
|
||||
, name_(name)
|
||||
, fetch_(fetch)
|
||||
, received_(received)
|
||||
, cmd_(cmd) {
|
||||
}
|
||||
};
|
||||
void dump_telegram_info(std::vector<TelegramFunctionDump> & telegram_functions_dump);
|
||||
void dump_value_info();
|
||||
#endif
|
||||
|
||||
|
||||
@@ -332,9 +332,8 @@ void EMSESP::show_ems(uuid::console::Shell & shell) {
|
||||
void EMSESP::dump_all_values(uuid::console::Shell & shell) {
|
||||
Serial.println("---- CSV START ----"); // marker use by py script
|
||||
// add header for CSV
|
||||
Serial.print(
|
||||
Serial.println(
|
||||
"device name,device type,product id,shortname,fullname,type [options...] \\| (min/max),uom,writeable,discovery entityid v3.4, discovery entityid");
|
||||
Serial.println();
|
||||
|
||||
for (const auto & device_class : EMSFactory::device_handlers()) {
|
||||
// go through each device type so they are sorted
|
||||
@@ -356,12 +355,10 @@ void EMSESP::dump_all_values(uuid::console::Shell & shell) {
|
||||
}
|
||||
|
||||
// add the device and print out all the entities
|
||||
|
||||
// if (device.product_id == 69) { // only for testing mixer
|
||||
// for testing the mixer use ... if (device.product_id == 69) {
|
||||
emsdevices.push_back(
|
||||
EMSFactory::add(device.device_type, device_id, device.product_id, "1.0", device.name, device.flags, EMSdevice::Brand::NO_BRAND));
|
||||
emsdevices.back()->dump_value_info();
|
||||
// } // only for testing mixer
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -370,6 +367,80 @@ void EMSESP::dump_all_values(uuid::console::Shell & shell) {
|
||||
}
|
||||
#endif
|
||||
|
||||
// Dump all telegrams to Serial out
|
||||
// this is intended to run within the OS with lots of available memory!
|
||||
#if defined(EMSESP_STANDALONE)
|
||||
void EMSESP::dump_all_telegrams(uuid::console::Shell & shell) {
|
||||
std::vector<EMSdevice::TelegramFunctionDump> telegram_functions_dump;
|
||||
|
||||
Serial.println("---- CSV START ----"); // marker use by py script
|
||||
// add header for CSV
|
||||
Serial.println("telegram_type_id,name,is_fetched,is_received,is_cmd");
|
||||
|
||||
for (const auto & device_class : EMSFactory::device_handlers()) {
|
||||
// go through each device type so they are sorted
|
||||
for (const auto & device : device_library_) {
|
||||
if (device_class.first == device.device_type) {
|
||||
uint8_t device_id = 0;
|
||||
// Mixer class looks at device_id to determine type and the tag
|
||||
// so fixing to 0x28 which will give all the settings except flowSetTemp
|
||||
if (device.device_type == DeviceType::MIXER) {
|
||||
if (device.flags == EMSdevice::EMS_DEVICE_FLAG_MMPLUS) {
|
||||
if (device.product_id == 160) { // MM100
|
||||
device_id = 0x28; // dhw
|
||||
} else {
|
||||
device_id = 0x20; // hc
|
||||
}
|
||||
} else {
|
||||
device_id = 0x20; // should cover all the other device types
|
||||
}
|
||||
}
|
||||
|
||||
// add the device and print out all the entities
|
||||
emsdevices.push_back(
|
||||
EMSFactory::add(device.device_type, device_id, device.product_id, "1.0", device.name, device.flags, EMSdevice::Brand::NO_BRAND));
|
||||
// add to our vector list
|
||||
emsdevices.back()->dump_telegram_info(telegram_functions_dump);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto num_entries = telegram_functions_dump.size();
|
||||
|
||||
// sort based on typeID
|
||||
std::sort(telegram_functions_dump.begin(),
|
||||
telegram_functions_dump.end(),
|
||||
[](const EMSdevice::TelegramFunctionDump & a, const EMSdevice::TelegramFunctionDump & b) { return a.type_id_ < b.type_id_; });
|
||||
|
||||
// Get the iterator for the modified vector
|
||||
auto it = std::unique(telegram_functions_dump.begin(),
|
||||
telegram_functions_dump.end(),
|
||||
[](const EMSdevice::TelegramFunctionDump & a, const EMSdevice::TelegramFunctionDump & b) { return a.type_id_ == b.type_id_; });
|
||||
|
||||
// Use erase method to remove all the duplicates from the vector
|
||||
telegram_functions_dump.erase(it, telegram_functions_dump.end());
|
||||
|
||||
|
||||
for (const auto & tf : telegram_functions_dump) {
|
||||
Serial.printf(Helpers::hextoa(tf.type_id_, true).c_str());
|
||||
Serial.print(',');
|
||||
Serial.print(tf.name_);
|
||||
Serial.print(',');
|
||||
Serial.print(tf.fetch_ ? "fetched" : "");
|
||||
Serial.print(',');
|
||||
Serial.print(tf.received_ ? "received" : "");
|
||||
Serial.print(',');
|
||||
Serial.print(tf.cmd_ ? "cmd" : "");
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
Serial.println("---- CSV END ----"); // marker used by py script
|
||||
|
||||
Serial.printf("Total telegrams = %d, total unique telegrams = %d", num_entries, telegram_functions_dump.size());
|
||||
Serial.println();
|
||||
}
|
||||
#endif
|
||||
|
||||
// show EMS device values to the shell console
|
||||
void EMSESP::show_device_values(uuid::console::Shell & shell) {
|
||||
if (emsdevices.empty()) {
|
||||
@@ -647,7 +718,7 @@ void EMSESP::publish_response(std::shared_ptr<const Telegram> telegram) {
|
||||
strlcat(buffer, Helpers::data_to_hex(telegram->message_data, telegram->message_length).c_str(), 768);
|
||||
if (response_id_ != 0) {
|
||||
strlcat(buffer, " ", 768);
|
||||
return;
|
||||
return; // do not delete buffer
|
||||
}
|
||||
JsonDocument doc;
|
||||
char s[10];
|
||||
|
||||
@@ -131,6 +131,7 @@ class EMSESP {
|
||||
static void show_device_values(uuid::console::Shell & shell);
|
||||
static void show_sensor_values(uuid::console::Shell & shell);
|
||||
static void dump_all_values(uuid::console::Shell & shell);
|
||||
static void dump_all_telegrams(uuid::console::Shell & shell);
|
||||
|
||||
static void show_devices(uuid::console::Shell & shell);
|
||||
static void show_ems(uuid::console::Shell & shell);
|
||||
|
||||
@@ -422,12 +422,17 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
|
||||
// all tests with EMSESP_STANDALONE
|
||||
|
||||
if (command == "entity_dump") {
|
||||
shell.printfln("Adding all devices and entities...");
|
||||
System::test_set_all_active(true);
|
||||
EMSESP::dump_all_values(shell);
|
||||
ok = true;
|
||||
}
|
||||
|
||||
if (command == "telegram_dump") {
|
||||
System::test_set_all_active(true);
|
||||
EMSESP::dump_all_telegrams(shell);
|
||||
ok = true;
|
||||
}
|
||||
|
||||
if (command == "modes") {
|
||||
shell.printfln("Testing thermostat modes...");
|
||||
test("general");
|
||||
|
||||
@@ -52,6 +52,7 @@ namespace emsesp {
|
||||
// #define EMSESP_DEBUG_DEFAULT "api_wwmode"
|
||||
// #define EMSESP_DEBUG_DEFAULT "customization"
|
||||
// #define EMSESP_DEBUG_DEFAULT "entity_dump"
|
||||
// #define EMSESP_DEBUG_DEFAULT "telegram_dump"
|
||||
// #define EMSESP_DEBUG_DEFAULT "memory"
|
||||
// #define EMSESP_DEBUG_DEFAULT "coldshot"
|
||||
// #define EMSESP_DEBUG_DEFAULT "custom"
|
||||
|
||||
@@ -1 +1 @@
|
||||
#define EMSESP_APP_VERSION "3.7.0-dev.6"
|
||||
#define EMSESP_APP_VERSION "3.7.0-dev.7"
|
||||
|
||||
Reference in New Issue
Block a user