From 530fcd6b68d40c2b6a015eaeff5009996350717d Mon Sep 17 00:00:00 2001 From: Stefan Date: Mon, 13 Nov 2023 20:32:36 +0100 Subject: [PATCH] Shelly: Set discovery insensitive to upper / lower case --- shelly/integrationpluginshelly.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/shelly/integrationpluginshelly.cpp b/shelly/integrationpluginshelly.cpp index 00cce8a6..041f4623 100644 --- a/shelly/integrationpluginshelly.cpp +++ b/shelly/integrationpluginshelly.cpp @@ -86,7 +86,7 @@ void IntegrationPluginShelly::discoverThings(ThingDiscoveryInfo *info) if (info->thingClassId() == shelly1ThingClassId) { namePattern = QRegExp("^shelly1-[0-9A-Z]+$"); } else if (info->thingClassId() == shellyPlus1ThingClassId) { - namePattern = QRegExp("^ShellyPlus1-[0-9A-Z]+$"); + namePattern = QRegExp("^ShellyPlus1-[0-9A-Z]+$", Qt::CaseInsensitive); } else if (info->thingClassId() == shelly1pmThingClassId) { namePattern = QRegExp("^shelly1pm-[0-9A-Z]+$"); } else if (info->thingClassId() == shellyPlus1pmThingClassId) { @@ -96,15 +96,15 @@ void IntegrationPluginShelly::discoverThings(ThingDiscoveryInfo *info) } else if (info->thingClassId() == shellyPlugThingClassId) { namePattern = QRegExp("^shellyplug(-s)?-[0-9A-Z]+$"); } else if (info->thingClassId() == shellyPlusPlugThingClassId) { - namePattern = QRegExp("^(ShellyPlusPlugS|ShellyPlug(US|IT|UK))-[0-9A-Z]+$"); + namePattern = QRegExp("^(ShellyPlusPlugS|ShellyPlug(US|IT|UK))-[0-9A-Z]+$", Qt::CaseInsensitive); } else if (info->thingClassId() == shellyRgbw2ThingClassId) { namePattern = QRegExp("^shellyrgbw2-[0-9A-Z]+$"); } else if (info->thingClassId() == shellyDimmerThingClassId) { - namePattern = QRegExp("^(shellydimmer(2)?|ShellyVintage)-[0-9A-Z]+$"); + namePattern = QRegExp("^(shellydimmer(2)?|ShellyVintage)-[0-9A-Z]+$", Qt::CaseInsensitive); } else if (info->thingClassId() == shelly2ThingClassId) { namePattern = QRegExp("^shellyswitch-[0-9A-Z]+$"); } else if (info->thingClassId() == shelly25ThingClassId) { - namePattern = QRegExp("^(shellyswitch25|ShellyPlus2PM)-[0-9A-Z]+$"); + namePattern = QRegExp("^(shellyswitch25|ShellyPlus2PM)-[0-9A-Z]+$", Qt::CaseInsensitive); } else if (info->thingClassId() == shellyButton1ThingClassId) { namePattern = QRegExp("^shellybutton1-[0-9-A-Z]+$"); } else if (info->thingClassId() == shellyEmThingClassId) { @@ -112,7 +112,7 @@ void IntegrationPluginShelly::discoverThings(ThingDiscoveryInfo *info) } else if (info->thingClassId() == shellyEm3ThingClassId) { namePattern = QRegExp("^shellyem3-[0-9A-Z]+$"); } else if (info->thingClassId() == shellyPro3EMThingClassId) { - namePattern = QRegExp("^ShellyPro3EM-[0-9A-Z]+$"); + namePattern = QRegExp("^ShellyPro3EM-[0-9A-Z]+$", Qt::CaseInsensitive); } else if (info->thingClassId() == shellyHTThingClassId) { namePattern = QRegExp("shellyht-[0-9A-Z]+$"); } else if (info->thingClassId() == shellyI3ThingClassId) { @@ -2044,9 +2044,9 @@ QHostAddress IntegrationPluginShelly::getIP(Thing *thing) const bool IntegrationPluginShelly::isGen2(const QString &shellyId) const { - return shellyId.contains("Plus") - || shellyId.contains("Pro") - || shellyId.startsWith("ShellyPlug") // Plus plug variants don't have Plus in the name, but are camelcased as opposed to 1st gen plugs + return shellyId.contains("Plus", Qt::CaseInsensitive) + || shellyId.contains("Pro", Qt::CaseInsensitive) + || QRegExp("^(ShellyPlusPlugS|ShellyPlug(US|IT|UK))-[0-9A-Z]+$", Qt::CaseInsensitive).exactMatch(shellyId) // Plus plug variants need to be matched quite precisely to not also match the v1 Plug ; }