mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
some refactoring
This commit is contained in:
@@ -438,7 +438,7 @@ void EMSdevice::register_telegram_type(const uint16_t telegram_type_id, const __
|
||||
// type: one of DeviceValueType
|
||||
// options: options for enum or a divider for int (e.g. F("10"))
|
||||
// short_name: used in Mqtt as keys
|
||||
// full name: used in Web and Console unless empty (nullptr)
|
||||
// full_name: used in Web and Console unless empty (nullptr)
|
||||
// uom: unit of measure from DeviceValueUOM
|
||||
void EMSdevice::register_device_value(uint8_t tag,
|
||||
void * value_p,
|
||||
@@ -480,6 +480,7 @@ void EMSdevice::register_device_value(uint8_t tag,
|
||||
}
|
||||
|
||||
// function with min and max values
|
||||
// adds a new command to the command list
|
||||
void EMSdevice::register_device_value(uint8_t tag,
|
||||
void * value_p,
|
||||
uint8_t type,
|
||||
@@ -490,14 +491,18 @@ void EMSdevice::register_device_value(uint8_t tag,
|
||||
int32_t min,
|
||||
uint32_t max) {
|
||||
register_device_value(tag, value_p, type, options, name[0], name[1], uom, (f != nullptr), min, max);
|
||||
if (f != nullptr) {
|
||||
if (tag >= TAG_HC1 && tag <= TAG_HC4) {
|
||||
Command::add(device_type_, name[0], f, name[1], FLAG_HC);
|
||||
} else if (tag >= TAG_WWC1 && tag <= TAG_WWC4) {
|
||||
Command::add(device_type_, name[0], f, name[1], FLAG_WWC);
|
||||
} else {
|
||||
Command::add(device_type_, name[0], f, name[1], 0);
|
||||
}
|
||||
|
||||
// add a new command if it has a function attached
|
||||
if (f == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (tag >= TAG_HC1 && tag <= TAG_HC4) {
|
||||
Command::add(device_type_, name[0], f, name[1], CommandFlag::MQTT_SUB_FLAG_HC | CommandFlag::ADMIN_ONLY);
|
||||
} else if (tag >= TAG_WWC1 && tag <= TAG_WWC4) {
|
||||
Command::add(device_type_, name[0], f, name[1], CommandFlag::MQTT_SUB_FLAG_WWC | CommandFlag::ADMIN_ONLY);
|
||||
} else {
|
||||
Command::add(device_type_, name[0], f, name[1], CommandFlag::MQTT_SUB_FLAG_NORMAL | CommandFlag::ADMIN_ONLY);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user