]> git.basschouten.com Git - openhab-addons.git/commitdiff
[shelly] Revise fix for Gen1 initialization problem for manually created Things ...
authorMarkus Michels <markus7017@gmail.com>
Tue, 9 Jul 2024 05:36:21 +0000 (07:36 +0200)
committerGitHub <noreply@github.com>
Tue, 9 Jul 2024 05:36:21 +0000 (07:36 +0200)
* Fixes #16990 - Gen1 nbo longer initializes when defined in .things

Signed-off-by: Markus Michels <markus7017@gmail.com>
Co-authored-by: Jacob Laursen <jacob-github@vindvejr.dk>
bundles/org.openhab.binding.shelly/README.md
bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/api/ShellyDeviceProfile.java
bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/api2/Shelly2ApiRpc.java
bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/handler/ShellyBaseHandler.java

index 4f3aa479d0fc7692c77d53d17364df661c2dbd5e..1be0b89c9abf501c82a0dd8f7b785c1a5ed52334 100644 (file)
@@ -74,7 +74,6 @@ The binding provides the same feature set across all devices as good as possible
 | shellybutton2     | Shelly Button 2                                        | SHBTN-2             |
 | shellysense       | Shelly Motion and IR Controller                        | SHSEN-1             |
 | shellytrv         | Shelly TRV                                             | SHTRV-01            |
-| shellydevice      | A password protected Shelly device or an unknown type  |                     |
 
 ### Generation 2 Plus series
 
@@ -87,7 +86,7 @@ The binding provides the same feature set across all devices as good as possible
 | shellyplusplug       | Shelly Plug-S                                            | SNPL-00112EU                 |
 | shellyplusplug       | Shelly Plug-IT                                           | SNPL-00110IT                 |
 | shellyplusplug       | Shelly Plug-UK                                           | SNPL-00112UK                 |
-| shellyplusplug       | Shelly Plug-US                                           | SNPL-00116US                 |
+| shellyplusplugus     | Shelly Plug-US                                           | SNPL-00116US                 |
 | shellyplusi4         | Shelly Plus i4 with 4x AC input                          | SNSN-0024X                   |
 | shellyplusi4dc       | Shelly Plus i4 with 4x DC input                          | SNSN-0D24X                   |
 | shellyplusht         | Shelly Plus HT with temperature + humidity sensor        | SNSN-0013A                   |
@@ -95,6 +94,7 @@ The binding provides the same feature set across all devices as good as possible
 | shellyplussmoke      | Shelly Plus Smoke sensor                                 | SNSN-0031Z                   |
 | shellypluswdus       | Shelly Plus Wall Dimmer US                               | SNDM-0013US                  |
 | shellywalldisplay    | Shelly Plus Wall Display                                 | SAWD-0A1XX10EU1              |
+| shellyblugw          | SHelly BLU Gateway                                       | SNGW-BT01                    |
 
 ### Generation 2 Plus Mini series (incl. Gen 3)
 
@@ -115,6 +115,7 @@ The binding provides the same feature set across all devices as good as possible
 | shellypro2pm-roller | Shelly Pro 2 PM with 2x relay + power meter, roller mode | SPSW-002PE16EU, SPSW-102PE16EU, SPSW-202PE16EU |
 | shellypro3          | Shelly Pro 3 with 3x relay (dry contacts)                | SPSW-003XE16EU                                 |
 | shellypro3em        | Shelly Pro 3 with 3 integrated power meters              | SPEM-003CEBEU                                  |
+| shellyproem50       | Shelly Pro EM50 with 3 integrated power meters           | SPEM-002CEBEU50                                |
 | shellypro4pm        | Shelly Pro 4 PM with 4x relay + power meter              | SPSW-004PE16EU, SPSW-104PE16EU                 |
 
 ### Shelly BLU
@@ -126,6 +127,13 @@ The binding provides the same feature set across all devices as good as possible
 | shellyblumotion   | Shelly BLU Motion                                      | SBMO      |
 | shellybluht       | Shelly BLU H&T                                         | SBMO      |
 
+### Special Thing Types
+
+| thing-type        | Model                                                  | Vendor ID |
+| ----------------- | ------------------------------------------------------ | --------- |
+| shellydevice      | A password protected Shelly device or an unknown type  |           |
+| shellyunknown     | An unknown Shelly device / model has been detected     |           |
+
 ## Binding Configuration
 
 The binding has the following configuration options:
@@ -1551,6 +1559,10 @@ See notes on discovery of Shelly BLU devices above.
 | battery | batteryLevel  | Number   | yes       | Battery Level in %                                      |
 |         | lowBattery    | Switch   | yes       | Low battery alert (< 20%)                               |
 
+## Shelly BLU Gateway (thing-type: shellyblugw)
+
+There are no additional channels beside the device group.
+
 ## Shelly Wall Displays
 
 | Group   | Channel     | Type     | read-only | Description                                                                       |
index 3149bac5aa4c787c8a0cdfb9cd87de77499bd5eb..162b85e04611b41375f14e43896cd68c5f0a5d72 100644 (file)
@@ -405,7 +405,8 @@ public class ShellyDeviceProfile {
 
     public static boolean isGeneration2(String thingType) {
         return thingType.startsWith("shellyplus") || thingType.startsWith("shellypro") || thingType.contains("mini")
-                || (thingType.startsWith("shelly") && thingType.contains("g3")) || isBluSeries(thingType);
+                || thingType.startsWith("shellywall") || (thingType.startsWith("shelly") && thingType.contains("g3"))
+                || isBluSeries(thingType);
     }
 
     public static boolean isBluSeries(String thingType) {
index 3b440dbe63b7c9bfcab411ad0074a66459cb1644..c9b854f7857804829f3bf8e917382e2676bc1037 100644 (file)
@@ -205,7 +205,6 @@ public class Shelly2ApiRpc extends Shelly2ApiClient implements ShellyApiInterfac
         }
 
         ShellySettingsDevice device = profile.device;
-        profile.isGen2 = device.gen == 2;
         if (config.serviceName.isEmpty()) {
             config.serviceName = getString(profile.device.hostname);
         }
index a8ab8cfe03ed02b80ca8ce6cdcc95911c870bccb..d83fa16278bcf48bf09f61f4f0ea896d7c2cf984 100755 (executable)
@@ -153,13 +153,17 @@ public abstract class ShellyBaseHandler extends BaseThingHandler
         this.config = getConfigAs(ShellyThingConfiguration.class);
         this.httpClient = httpClient;
 
-        Map<String, String> properties = thing.getProperties();
-        String gen = getString(properties.get(PROPERTY_DEV_GEN));
+        // Create thing handler depending on device generation
         String thingType = getThingType();
         blu = ShellyDeviceProfile.isBluSeries(thingType);
-        gen2 = "2".equals(gen) || "3".equals(gen) || blu || ShellyDeviceProfile.isGeneration2(thingType);
-        this.api = !blu ? !gen2 ? new Shelly1HttpApi(thingName, this) : new Shelly2ApiRpc(thingName, thingTable, this)
-                : new ShellyBluApi(thingName, thingTable, this);
+        gen2 = ShellyDeviceProfile.isGeneration2(thingType);
+        if (blu) {
+            this.api = new ShellyBluApi(thingName, thingTable, this);
+        } else if (gen2) {
+            this.api = new Shelly2ApiRpc(thingName, thingTable, this);
+        } else {
+            this.api = new Shelly1HttpApi(thingName, this);
+        }
         if (gen2) {
             config.eventsCoIoT = false;
         }