@@ -72,6 +72,21 @@ const char * EMSdevice::tag_to_mqtt(int8_t tag) {
7272 return (DeviceValue::DeviceValueTAG_mqtt[tag > DeviceValue::NUM_TAGS ? 0 : tag]);
7373}
7474
75+ uint8_t EMSdevice::tag_to_flag (const uint8_t tag) {
76+ if (tag >= DeviceValueTAG::TAG_HC1 && tag <= DeviceValueTAG::TAG_HC8) {
77+ return CommandFlag::CMD_FLAG_HC;
78+ } else if (tag >= DeviceValueTAG::TAG_DHW1 && tag <= DeviceValueTAG::TAG_DHW10) {
79+ return CommandFlag::CMD_FLAG_DHW;
80+ } else if (tag >= DeviceValueTAG::TAG_HS1 && tag <= DeviceValueTAG::TAG_HS16) {
81+ return CommandFlag::CMD_FLAG_HS;
82+ } else if (tag >= DeviceValueTAG::TAG_AHS1 && tag <= DeviceValueTAG::TAG_AHS1) {
83+ return CommandFlag::CMD_FLAG_AHS;
84+ } else if (tag >= DeviceValueTAG::TAG_SRC1 && tag <= DeviceValueTAG::TAG_SRC16) {
85+ return CommandFlag::CMD_FLAG_SRC;
86+ }
87+ return 0 ;
88+ }
89+
7590// convert UOM to a char string - translating only for hours/minutes/seconds
7691const char * EMSdevice::uom_to_string (uint8_t uom) {
7792 switch (uom) {
@@ -90,6 +105,9 @@ const char * EMSdevice::uom_to_string(uint8_t uom) {
90105}
91106
92107const char * EMSdevice::brand_to_char () {
108+ if (!custom_brand ().empty ()) {
109+ return custom_brand ().c_str ();
110+ }
93111 switch (brand_) {
94112 case EMSdevice::Brand::BOSCH:
95113 return F_ (bosch);
@@ -316,7 +334,7 @@ std::string EMSdevice::to_string() {
316334 return std::string (name ()) + " (DeviceID:" + Helpers::hextoa (device_id_) + " )" ;
317335 }
318336
319- if (brand_ == Brand::NO_BRAND) {
337+ if (brand_ == Brand::NO_BRAND && custom_brand (). empty () ) {
320338 return std::string (name ()) + " (DeviceID:" + Helpers::hextoa (device_id_) + " , ProductID:" + Helpers::itoa (product_id_) + " , Version:" + version_ + " )" ;
321339 }
322340
@@ -332,7 +350,7 @@ std::string EMSdevice::to_string_version() {
332350// returns out brand + device name
333351// translated
334352std::string EMSdevice::to_string_short () {
335- if (brand_ == Brand::NO_BRAND) {
353+ if (brand_ == Brand::NO_BRAND && custom_brand (). empty () ) {
336354 return std::string (device_type_2_device_name_translated ()) + " : " + name ();
337355 }
338356
@@ -650,25 +668,21 @@ void EMSdevice::add_device_value(int8_t tag, // to b
650668
651669 // add a new command if it has a function attached
652670 if (has_cmd) {
653- uint8_t flags = CommandFlag::ADMIN_ONLY; // executing commands require admin privileges
654-
655- if (tag >= DeviceValueTAG::TAG_HC1 && tag <= DeviceValueTAG::TAG_HC8) {
656- flags |= CommandFlag::CMD_FLAG_HC;
657- } else if (tag >= DeviceValueTAG::TAG_DHW1 && tag <= DeviceValueTAG::TAG_DHW10) {
658- flags |= CommandFlag::CMD_FLAG_DHW;
659- } else if (tag >= DeviceValueTAG::TAG_HS1 && tag <= DeviceValueTAG::TAG_HS16) {
660- flags |= CommandFlag::CMD_FLAG_HS;
661- } else if (tag >= DeviceValueTAG::TAG_AHS1 && tag <= DeviceValueTAG::TAG_AHS1) {
662- flags |= CommandFlag::CMD_FLAG_AHS;
663- } else if (tag >= DeviceValueTAG::TAG_SRC1 && tag <= DeviceValueTAG::TAG_SRC16) {
664- flags |= CommandFlag::CMD_FLAG_SRC;
665- }
666-
671+ uint8_t flags = CommandFlag::ADMIN_ONLY | tag_to_flag (tag); // executing commands require admin privileges
667672 // add the command to our library
668673 Command::add (device_type_, device_id_, short_name, f, fullname, flags);
669674 }
670675}
671676
677+ void EMSdevice::erase_device_values () {
678+ for (auto & dv : devicevalues_) {
679+ if (dv.has_cmd ) {
680+ Command::erase_command (device_type_, dv.short_name , tag_to_flag (dv.tag ));
681+ }
682+ }
683+ devicevalues_.clear ();
684+ }
685+
672686// single list of options
673687void EMSdevice::register_device_value (int8_t tag,
674688 void * value_p,
0 commit comments