From c4e7747fd1aa90ad1c94030e382c2ab9de59c215 Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Sat, 24 Apr 2021 09:55:33 +0200 Subject: [PATCH] check devicename lowercase --- src/emsdevice.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/emsdevice.cpp b/src/emsdevice.cpp index 13f91e249..0e532bd18 100644 --- a/src/emsdevice.cpp +++ b/src/emsdevice.cpp @@ -211,31 +211,38 @@ std::string EMSdevice::device_type_2_device_name(const uint8_t device_type) { // returns device_type from a string uint8_t EMSdevice::device_name_2_device_type(const char * topic) { - if (!strcmp_P(topic, reinterpret_cast(F_(boiler)))) { + // convert topic to lowercase and compare + char lowtopic[20]; + strlcpy(lowtopic, topic, sizeof(lowtopic)); + for (char * p = lowtopic; *p; p++) { + *p = tolower(*p); + } + + if (!strcmp_P(lowtopic, reinterpret_cast(F_(boiler)))) { return DeviceType::BOILER; } - if (!strcmp_P(topic, reinterpret_cast(F_(thermostat)))) { + if (!strcmp_P(lowtopic, reinterpret_cast(F_(thermostat)))) { return DeviceType::THERMOSTAT; } - if (!strcmp_P(topic, reinterpret_cast(F_(system)))) { + if (!strcmp_P(lowtopic, reinterpret_cast(F_(system)))) { return DeviceType::SYSTEM; } - if (!strcmp_P(topic, reinterpret_cast(F_(heatpump)))) { + if (!strcmp_P(lowtopic, reinterpret_cast(F_(heatpump)))) { return DeviceType::HEATPUMP; } - if (!strcmp_P(topic, reinterpret_cast(F_(solar)))) { + if (!strcmp_P(lowtopic, reinterpret_cast(F_(solar)))) { return DeviceType::SOLAR; } - if (!strcmp_P(topic, reinterpret_cast(F_(mixer)))) { + if (!strcmp_P(lowtopic, reinterpret_cast(F_(mixer)))) { return DeviceType::MIXER; } - if (!strcmp_P(topic, reinterpret_cast(F_(dallassensor)))) { + if (!strcmp_P(lowtopic, reinterpret_cast(F_(dallassensor)))) { return DeviceType::DALLASSENSOR; }