From 81fd47abedd43e8eb92c0082a864bc4b69ec95a0 Mon Sep 17 00:00:00 2001 From: markus7017 Date: Sat, 7 Jun 2025 16:01:04 -0400 Subject: [PATCH 1/6] Fix Shelly Plug US: This is a Gen2 device, but the service name is missing the "plus" - shellyplugus instead of shellyplusplugus. As a result the thing uses the Gen1 API, which does not work. Signed-off-by: Markus Michels --- .../internal/discovery/ShellyThingCreator.java | 7 ++++++- .../main/resources/OH-INF/i18n/shelly.properties | 3 ++- .../resources/OH-INF/thing/shellyGen2_relay.xml | 14 ++++++++++++++ .../internal/discovery/ShellyThingCreatorTest.java | 1 + 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/discovery/ShellyThingCreator.java b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/discovery/ShellyThingCreator.java index 65956bbd93bd4..e49ed901403be 100644 --- a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/discovery/ShellyThingCreator.java +++ b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/discovery/ShellyThingCreator.java @@ -201,6 +201,7 @@ public class ShellyThingCreator { public static final String THING_TYPE_SHELLYPLUSSMOKE_STR = "shellyplussmoke"; public static final String THING_TYPE_SHELLYPLUSUNI_STR = "shellyplusuni"; public static final String THING_TYPE_SHELLYPLUSPLUGS_STR = "shellyplusplug"; + public static final String SVC_TYPE_SHELLYPLUSPLUGUS_STR = "shellyplugus"; public static final String THING_TYPE_SHELLYPLUSPLUGUS_STR = "shellyplusplugus"; public static final String THING_TYPE_SHELLYPLUSDIMMERUS_STR = "shellypluswdus"; public static final String THING_TYPE_SHELLYPLUSDIMMER10V_STR = "shellyplus10v"; @@ -515,6 +516,7 @@ public class ShellyThingCreator { Map.entry(THING_TYPE_SHELLYPLUS1PMG4_STR, THING_TYPE_SHELLYPLUS1PM_STR), Map.entry(THING_TYPE_SHELLYPLUS2PM_RELAY_STR, THING_TYPE_SHELLYPLUS2PM_RELAY_STR), Map.entry(THING_TYPE_SHELLYPLUS2PM_ROLLER_STR, THING_TYPE_SHELLYPLUS2PM_ROLLER_STR), + Map.entry(SVC_TYPE_SHELLYPLUSPLUGUS_STR, THING_TYPE_SHELLYPLUSPLUGUS_STR), Map.entry(THING_TYPE_SHELLYPLUSPLUGS_STR, THING_TYPE_SHELLYPLUSPLUGS_STR), Map.entry(THING_TYPE_SHELLYPLUSPLUGUS_STR, THING_TYPE_SHELLYPLUSPLUGUS_STR), Map.entry(THING_TYPE_SHELLYPLUSI4_STR, THING_TYPE_SHELLYPLUSI4_STR), @@ -604,7 +606,10 @@ private static String getThingTypeID(String serviceName, String deviceType, Stri if (serviceNameLowerCase.startsWith(THING_TYPE_SHELLY2_PREFIX)) { // Shelly v2 return getRelayOrRollerType(THING_TYPE_SHELLY2_RELAY_STR, THING_TYPE_SHELLY2_ROLLER_STR, mode); } - if (serviceNameLowerCase.startsWith(THING_TYPE_SHELLYPLUG_STR)) { + if (serviceNameLowerCase.contains("plugus")) { + int i = 1; + } + if (serviceNameLowerCase.startsWith(THING_TYPE_SHELLYPLUG_STR) && !serviceNameLowerCase.contains("plugus")) { // shellyplug-s needs to be mapped to shellyplugs to follow the schema // for the thing types: - if (serviceNameLowerCase.startsWith(THING_TYPE_SHELLYPLUGS_STR) || serviceNameLowerCase.contains("-s")) { diff --git a/bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/i18n/shelly.properties b/bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/i18n/shelly.properties index 0a868d54cb146..995b6d7ae7aef 100644 --- a/bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/i18n/shelly.properties +++ b/bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/i18n/shelly.properties @@ -94,7 +94,8 @@ thing-type.shelly.shellyplus1.description = Shelly Plus 1 (Single Relay Switch) thing-type.shelly.shellyplus1pm.description = Shelly Plus 1PM - Single Relay Switch with Power Meter thing-type.shelly.shellyplus2-relay.description = Shelly Plus 2PM - Dual Relay Switch with Power Meter thing-type.shelly.shellyplus2pm-roller.description = Shelly Plus 2PM - Roller Control with Power Meter -thing-type.shelly.shellyplusplug.description = Shelly Plus Plug S/IT/UK/US . Outlet with Power Meter +thing-type.shelly.shellyplusplug.description = Shelly Plus Plug S/IT/UK. Outlet with Power Meter +thing-type.shelly.shellyplusplugus.description = Shelly Plus Plug US . Outlet with Power Meter thing-type.shelly.shellyplusi4.description = Shelly Plus i4 - 4xInput Device thing-type.shelly.shellyplusi4dc.description = Shelly Plus i4DC - 4xDC Input Device thing-type.shelly.shellyplusuni.description = Shelly Plus UNI - Universal Module diff --git a/bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/thing/shellyGen2_relay.xml b/bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/thing/shellyGen2_relay.xml index 88a65c41e5e07..46d7a2070182b 100644 --- a/bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/thing/shellyGen2_relay.xml +++ b/bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/thing/shellyGen2_relay.xml @@ -87,6 +87,20 @@ + + + @text/thing-type.shelly.shellyplusplugus.description + PowerOutlet + PowerOutlet + + + + + + + serviceName + + diff --git a/bundles/org.openhab.binding.shelly/src/test/java/org/openhab/binding/shelly/internal/discovery/ShellyThingCreatorTest.java b/bundles/org.openhab.binding.shelly/src/test/java/org/openhab/binding/shelly/internal/discovery/ShellyThingCreatorTest.java index 94a9bab45387b..9b08344e5f27d 100644 --- a/bundles/org.openhab.binding.shelly/src/test/java/org/openhab/binding/shelly/internal/discovery/ShellyThingCreatorTest.java +++ b/bundles/org.openhab.binding.shelly/src/test/java/org/openhab/binding/shelly/internal/discovery/ShellyThingCreatorTest.java @@ -89,6 +89,7 @@ private static Stream provideTestCasesForGetThingUIDReturnsThingUidAc Arguments.of("shellyplug-su1-" + DEVICE_ID, "", "", THING_TYPE_SHELLYPLUGS_STR), // Arguments.of("shellyplugu1-" + DEVICE_ID, "", "", THING_TYPE_SHELLYPLUGU1_STR), // Arguments.of("shellyplugu12-" + DEVICE_ID, "", "", THING_TYPE_SHELLYPLUGU1_STR), // + Arguments.of("shellyplugus-" + DEVICE_ID, "", "", THING_TYPE_SHELLYPLUSPLUGUS_STR), // Arguments.of("shellyrgbw2-" + DEVICE_ID, "", "color", THING_TYPE_SHELLYRGBW2_COLOR_STR), // Arguments.of("shellyrgbw2-" + DEVICE_ID, "", "", THING_TYPE_SHELLYRGBW2_WHITE_STR), // Arguments.of("shellyrgbw2-" + DEVICE_ID, "", "colour", THING_TYPE_SHELLYRGBW2_WHITE_STR), // From 432b329380871933ca384d3140cf110f08ef0c76 Mon Sep 17 00:00:00 2001 From: markus7017 Date: Sat, 7 Jun 2025 16:02:56 -0400 Subject: [PATCH 2/6] cleanup Signed-off-by: Markus Michels --- .../binding/shelly/internal/discovery/ShellyThingCreator.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/discovery/ShellyThingCreator.java b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/discovery/ShellyThingCreator.java index e49ed901403be..7dca98ce383f2 100644 --- a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/discovery/ShellyThingCreator.java +++ b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/discovery/ShellyThingCreator.java @@ -606,9 +606,6 @@ private static String getThingTypeID(String serviceName, String deviceType, Stri if (serviceNameLowerCase.startsWith(THING_TYPE_SHELLY2_PREFIX)) { // Shelly v2 return getRelayOrRollerType(THING_TYPE_SHELLY2_RELAY_STR, THING_TYPE_SHELLY2_ROLLER_STR, mode); } - if (serviceNameLowerCase.contains("plugus")) { - int i = 1; - } if (serviceNameLowerCase.startsWith(THING_TYPE_SHELLYPLUG_STR) && !serviceNameLowerCase.contains("plugus")) { // shellyplug-s needs to be mapped to shellyplugs to follow the schema // for the thing types: - From 769aa6f9abd0d520b965fed9f5b2352353e8a7fe Mon Sep 17 00:00:00 2001 From: markus7017 Date: Sat, 7 Jun 2025 16:05:23 -0400 Subject: [PATCH 3/6] README updated Signed-off-by: Markus Michels --- bundles/org.openhab.binding.shelly/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.shelly/README.md b/bundles/org.openhab.binding.shelly/README.md index bb07e7b72bdc2..72ef0bb808a7c 100644 --- a/bundles/org.openhab.binding.shelly/README.md +++ b/bundles/org.openhab.binding.shelly/README.md @@ -727,7 +727,7 @@ The Shelly 4Pro provides 4 relays and 4 power meters. | meter3 | | | | See group meter1 for Shelly 2 | | meter4 | | | | See group meter1 for Shelly 2 | -### Shelly Plug-S (thing-type: shellyplugs) +### Shelly Plug-S (thing-type: shellyplugs, shellyplugus) | Group | Channel | Type | read-only | Description | | ----- | ------- | ---- | --------- | ----------------------------- | From 0ead38f8e5f591f6555a33cf917950cb78dbfba2 Mon Sep 17 00:00:00 2001 From: markus7017 Date: Sat, 7 Jun 2025 16:07:25 -0400 Subject: [PATCH 4/6] README updated Signed-off-by: Markus Michels --- bundles/org.openhab.binding.shelly/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bundles/org.openhab.binding.shelly/README.md b/bundles/org.openhab.binding.shelly/README.md index 72ef0bb808a7c..92577ac898e3f 100644 --- a/bundles/org.openhab.binding.shelly/README.md +++ b/bundles/org.openhab.binding.shelly/README.md @@ -727,7 +727,7 @@ The Shelly 4Pro provides 4 relays and 4 power meters. | meter3 | | | | See group meter1 for Shelly 2 | | meter4 | | | | See group meter1 for Shelly 2 | -### Shelly Plug-S (thing-type: shellyplugs, shellyplugus) +### Shelly Plug-S (thing-type: shellyplugs) | Group | Channel | Type | read-only | Description | | ----- | ------- | ---- | --------- | ----------------------------- | @@ -1226,7 +1226,7 @@ If the Shelly Add-On is installed: The roller positioning calibration has to be performed using the Shelly Web UI or App before the position can be set in percent. Refer to [Smartify Roller Shutters with openHAB and Shelly](doc/UseCaseSmartRoller.md) for more information on roller integration. -### Shelly Plus Plug-S/IT/UK/US (thing-type: shellyplusplug) +### Shelly Plus Plug-S/IT/UK/US (thing-type: shellyplusplug, shellyplusplugus) | Group | Channel | Type | read-only | Description | | ----- | ------------ | -------- | --------- | --------------------------------------------------------------------------------- | From 057dedfbc3822b5d5d7c77c2ebe5bf79bb12f097 Mon Sep 17 00:00:00 2001 From: markus7017 Date: Mon, 9 Jun 2025 10:13:51 -0400 Subject: [PATCH 5/6] apply review changes Signed-off-by: Markus Michels --- .../src/main/resources/OH-INF/i18n/shelly.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/i18n/shelly.properties b/bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/i18n/shelly.properties index 995b6d7ae7aef..c20a2eaff5f3c 100644 --- a/bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/i18n/shelly.properties +++ b/bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/i18n/shelly.properties @@ -95,7 +95,7 @@ thing-type.shelly.shellyplus1pm.description = Shelly Plus 1PM - Single Relay Sw thing-type.shelly.shellyplus2-relay.description = Shelly Plus 2PM - Dual Relay Switch with Power Meter thing-type.shelly.shellyplus2pm-roller.description = Shelly Plus 2PM - Roller Control with Power Meter thing-type.shelly.shellyplusplug.description = Shelly Plus Plug S/IT/UK. Outlet with Power Meter -thing-type.shelly.shellyplusplugus.description = Shelly Plus Plug US . Outlet with Power Meter +thing-type.shelly.shellyplusplugus.description = Shelly Plus Plug US. Outlet with Power Meter thing-type.shelly.shellyplusi4.description = Shelly Plus i4 - 4xInput Device thing-type.shelly.shellyplusi4dc.description = Shelly Plus i4DC - 4xDC Input Device thing-type.shelly.shellyplusuni.description = Shelly Plus UNI - Universal Module From 23be848c3b886e76ae86f8acbc8b0b95536e3c94 Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Thu, 12 Jun 2025 20:56:55 +0200 Subject: [PATCH 6/6] Add test coverage Signed-off-by: Jacob Laursen --- .../binding/shelly/internal/api/ShellyDeviceProfileTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/bundles/org.openhab.binding.shelly/src/test/java/org/openhab/binding/shelly/internal/api/ShellyDeviceProfileTest.java b/bundles/org.openhab.binding.shelly/src/test/java/org/openhab/binding/shelly/internal/api/ShellyDeviceProfileTest.java index 4be4198cea70e..a6a6dfcfc934d 100644 --- a/bundles/org.openhab.binding.shelly/src/test/java/org/openhab/binding/shelly/internal/api/ShellyDeviceProfileTest.java +++ b/bundles/org.openhab.binding.shelly/src/test/java/org/openhab/binding/shelly/internal/api/ShellyDeviceProfileTest.java @@ -91,6 +91,7 @@ private static Stream provideTestCasesForApiDetermination() { Arguments.of(THING_TYPE_SHELLYPLUS2PM_RELAY_STR, true, false), // Arguments.of(THING_TYPE_SHELLYPLUS2PM_ROLLER_STR, true, false), // Arguments.of(THING_TYPE_SHELLYPLUSPLUGS_STR, true, false), // + Arguments.of(THING_TYPE_SHELLYPLUSPLUGUS_STR, true, false), // Arguments.of(THING_TYPE_SHELLYPLUSI4_STR, true, false), // Arguments.of(THING_TYPE_SHELLYPLUSI4DC_STR, true, false), // Arguments.of(THING_TYPE_SHELLY1MINI_STR, true, false), //