mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
more fixes for Create table of all EMS-ESP entities, by device, shortname/fullname and characteristics #828
This commit is contained in:
@@ -402,6 +402,7 @@ Boiler::Boiler(uint8_t device_type, int8_t device_id, uint8_t product_id, const
|
||||
99);
|
||||
}
|
||||
*/
|
||||
|
||||
// heatpump info
|
||||
if (model() == EMS_DEVICE_FLAG_HEATPUMP) {
|
||||
register_device_value(DeviceValueTAG::TAG_DEVICE_DATA,
|
||||
|
||||
@@ -197,7 +197,7 @@ Thermostat::Thermostat(uint8_t device_type, uint8_t device_id, uint8_t product_i
|
||||
|
||||
#if defined(EMSESP_STANDALONE_DUMP)
|
||||
// if we're just dumping out values, create a single dummy hc
|
||||
register_device_values_hc(std::make_shared<emsesp::Thermostat::HeatingCircuit>(1, 0)); // hc=1, no flags
|
||||
register_device_values_hc(std::make_shared<emsesp::Thermostat::HeatingCircuit>(1, model)); // hc=1
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -1064,7 +1064,9 @@ void EMSdevice::getCustomEntities(std::vector<std::string> & entity_ids) {
|
||||
|
||||
#if defined(EMSESP_STANDALONE_DUMP)
|
||||
// dumps all entity values in native English
|
||||
// device name,device type,product_id,shortname,fullname,type [(enum values) | (min/max)],uom,writeable,discovery_entityid
|
||||
// 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
|
||||
void EMSdevice::dump_value_info() {
|
||||
for (auto & dv : devicevalues_) {
|
||||
if (dv.fullname == nullptr) {
|
||||
@@ -1085,33 +1087,25 @@ void EMSdevice::dump_value_info() {
|
||||
Serial.print(dv.fullname[0]);
|
||||
Serial.print(',');
|
||||
|
||||
// type and optional enum values and min/max
|
||||
// per type
|
||||
switch (dv.type) {
|
||||
case DeviceValueType::ENUM: {
|
||||
case DeviceValueType::ENUM:
|
||||
case DeviceValueType::CMD:
|
||||
if (dv.type == DeviceValueType::ENUM) {
|
||||
Serial.print("enum");
|
||||
Serial.print(" (");
|
||||
for (uint8_t i = 0; i < dv.options_size; i++) {
|
||||
Serial.print(Helpers::translated_word(dv.options[i]));
|
||||
if (i < dv.options_size - 1) {
|
||||
Serial.print('|');
|
||||
}
|
||||
}
|
||||
Serial.print(')');
|
||||
break;
|
||||
} else {
|
||||
Serial.print("cmd");
|
||||
}
|
||||
|
||||
case DeviceValueType::CMD: {
|
||||
Serial.print("cmd");
|
||||
Serial.print(" (");
|
||||
Serial.print(" [");
|
||||
for (uint8_t i = 0; i < dv.options_size; i++) {
|
||||
Serial.print(Helpers::translated_word(dv.options[i]));
|
||||
Serial.print(dv.options[i][0]);
|
||||
if (i < dv.options_size - 1) {
|
||||
Serial.print('|');
|
||||
Serial.print("\\|");
|
||||
}
|
||||
}
|
||||
Serial.print(')');
|
||||
Serial.print(']');
|
||||
break;
|
||||
}
|
||||
|
||||
case DeviceValueType::USHORT:
|
||||
Serial.print("ushort");
|
||||
@@ -1174,22 +1168,36 @@ void EMSdevice::dump_value_info() {
|
||||
Serial.print(dv.has_cmd ? "true" : "false");
|
||||
Serial.print(",");
|
||||
|
||||
// MQTT Discovery entity name, assuming we're using the default v3.5 option
|
||||
char entity_with_tag[50];
|
||||
// MQTT Discovery entity name
|
||||
// do this twice for the old and new formats
|
||||
char entity_with_tag[200];
|
||||
char entityid[500];
|
||||
char entity_name[100];
|
||||
|
||||
for (uint8_t count = 0; count < 2; count++) {
|
||||
if (count) {
|
||||
// new name, comes as last
|
||||
Serial.print(",");
|
||||
strcpy(entity_name, dv.short_name);
|
||||
} else {
|
||||
// old format, comes first
|
||||
char uniq_s[100];
|
||||
strlcpy(uniq_s, dv.fullname[0], sizeof(uniq_s));
|
||||
Helpers::replace_char(uniq_s, ' ', '_');
|
||||
strcpy(entity_name, uniq_s);
|
||||
}
|
||||
|
||||
if (dv.tag >= DeviceValueTAG::TAG_HC1) {
|
||||
snprintf(entity_with_tag,
|
||||
sizeof(entity_with_tag),
|
||||
"%s_%s_%s",
|
||||
device_type_2_device_name(device_type_),
|
||||
EMSdevice::tag_to_mqtt(dv.tag).c_str(),
|
||||
dv.short_name);
|
||||
entity_name);
|
||||
} else {
|
||||
// should really test for which device types have tags (like hc, wwc etc)
|
||||
// snprintf(entity_with_tag, sizeof(entity_with_tag), "%s_[<tag>_]%s", device_type_2_device_name(device_type_), dv.short_name);
|
||||
snprintf(entity_with_tag, sizeof(entity_with_tag), "%s_%s", device_type_2_device_name(device_type_), dv.short_name);
|
||||
snprintf(entity_with_tag, sizeof(entity_with_tag), "%s_%s", device_type_2_device_name(device_type_), entity_name);
|
||||
}
|
||||
|
||||
char entityid[150];
|
||||
if (dv.has_cmd) {
|
||||
switch (dv.type) {
|
||||
case DeviceValueType::INT:
|
||||
@@ -1218,6 +1226,7 @@ void EMSdevice::dump_value_info() {
|
||||
}
|
||||
|
||||
Serial.print(entityid);
|
||||
}
|
||||
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
@@ -313,7 +313,7 @@ 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("device name,device type,product_id,shortname,fullname,type [(enum values) | (min/max)],uom,writeable,discovery_entityid");
|
||||
Serial.print("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()) {
|
||||
@@ -323,7 +323,12 @@ void EMSESP::dump_all_values(uuid::console::Shell & shell) {
|
||||
uint8_t device_id = 0;
|
||||
// Mixer class looks at device_id to determine type, so fixing to 0x28 which will give all the settings except flowSetTemp
|
||||
if ((device.device_type == DeviceType::MIXER) && (device.flags == EMSdevice::EMS_DEVICE_FLAG_MMPLUS)) {
|
||||
device_id = 0x28; // hard code
|
||||
// pick one as hc and the other as having wwc
|
||||
if (device.product_id == 160) { // MM100
|
||||
device_id = 0x28; // wwc
|
||||
} else {
|
||||
device_id = 0x20; // hc
|
||||
}
|
||||
}
|
||||
|
||||
emsdevices.push_back(
|
||||
|
||||
Reference in New Issue
Block a user