]> git.basschouten.com Git - openhab-addons.git/commitdiff
[shelly] Adaption to OH3, Shelly Plug US, minor fixes (#8642)
authorMarkus Michels <markus7017@gmail.com>
Sun, 4 Oct 2020 16:39:59 +0000 (18:39 +0200)
committerGitHub <noreply@github.com>
Sun, 4 Oct 2020 16:39:59 +0000 (09:39 -0700)
* OH3 adaption - fixes small issues when running on OH3
* #8612: Fix total consumption for RGW2+Roller
* #8492: Shelly Plug US
* 2 more immediate = true catched and removed
* spotless applied

Signed-off-by: Markus Michels <markus7017@gmail.com>
13 files changed:
bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/ShellyBindingConstants.java [changed mode: 0644->0755]
bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/ShellyHandlerFactory.java [changed mode: 0644->0755]
bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/coap/ShellyCoapHandler.java
bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/config/ShellyThingConfiguration.java [changed mode: 0644->0755]
bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/discovery/ShellyDiscoveryParticipant.java [changed mode: 0644->0755]
bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/discovery/ShellyThingCreator.java
bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/handler/ShellyBaseHandler.java [changed mode: 0644->0755]
bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/handler/ShellyComponents.java
bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/i18n/shelly_de.properties
bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/thing/lights.xml
bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/thing/relay.xml
bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/thing/sensor.xml
bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/thing/unknown.xml

old mode 100644 (file)
new mode 100755 (executable)
index eb2ddfe..36a4ec5
@@ -47,6 +47,7 @@ public class ShellyBindingConstants {
     public static final String THING_TYPE_SHELLY4PRO_STR = "shelly4pro";
     public static final String THING_TYPE_SHELLYPLUG_STR = "shellyplug";
     public static final String THING_TYPE_SHELLYPLUGS_STR = "shellyplugs";
+    public static final String THING_TYPE_SHELLYPLUGU1_STR = "shellyplugu1"; // Shely Plug US
     public static final String THING_TYPE_SHELLYDIMMER_STR = "shellydimmer";
     public static final String THING_TYPE_SHELLYDIMMER2_STR = "shellydimmer2";
     public static final String THING_TYPE_SHELLYIX3_STR = "shellyix3";
@@ -73,6 +74,7 @@ public class ShellyBindingConstants {
     public static final String SHELLYDT_1PM = "SHSW-PM";
     public static final String SHELLYDT_SHPLG = "SHPLG-1";
     public static final String SHELLYDT_SHPLG_S = "SHPLG-S";
+    public static final String SHELLYDT_SHPLG_U1 = "SHPLG-U1";
     public static final String SHELLYDT_SHELLY2 = "SHSW-21";
     public static final String SHELLYDT_SHELLY25 = "SHSW-25";
     public static final String SHELLYDT_SHPRO = "SHSW-44";
@@ -108,6 +110,8 @@ public class ShellyBindingConstants {
     public static final ThingTypeUID THING_TYPE_SHELLY4PRO = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLY4PRO_STR);
     public static final ThingTypeUID THING_TYPE_SHELLYPLUG = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYPLUG_STR);
     public static final ThingTypeUID THING_TYPE_SHELLYPLUGS = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYPLUGS_STR);
+    public static final ThingTypeUID THING_TYPE_SHELLYPLUGU1 = new ThingTypeUID(BINDING_ID,
+            THING_TYPE_SHELLYPLUGU1_STR);
     public static final ThingTypeUID THING_TYPE_SHELLYDIMMER = new ThingTypeUID(BINDING_ID,
             THING_TYPE_SHELLYDIMMER_STR);
     public static final ThingTypeUID THING_TYPE_SHELLYDIMMER2 = new ThingTypeUID(BINDING_ID,
@@ -138,18 +142,16 @@ public class ShellyBindingConstants {
     public static final ThingTypeUID THING_TYPE_SHELLYUNKNOWN = new ThingTypeUID(BINDING_ID,
             THING_TYPE_SHELLYUNKNOWN_STR);
 
-    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections
-            .unmodifiableSet(Stream
-                    .of(THING_TYPE_SHELLY1, THING_TYPE_SHELLY1PM, THING_TYPE_SHELLYEM, THING_TYPE_SHELLY3EM,
-                            THING_TYPE_SHELLY2_RELAY, THING_TYPE_SHELLY2_ROLLER, THING_TYPE_SHELLY25_RELAY,
-                            THING_TYPE_SHELLY25_ROLLER, THING_TYPE_SHELLY4PRO, THING_TYPE_SHELLYPLUG,
-                            THING_TYPE_SHELLYPLUGS, THING_TYPE_SHELLYDIMMER, THING_TYPE_SHELLYDIMMER2,
-                            THING_TYPE_SHELLYIX3, THING_TYPE_SHELLYBULB, THING_TYPE_SHELLYDUO, THING_TYPE_SHELLYVINTAGE,
-                            THING_TYPE_SHELLYRGBW2_COLOR, THING_TYPE_SHELLYRGBW2_WHITE, THING_TYPE_SHELLYHT,
-                            THING_TYPE_SHELLYSENSE, THING_TYPE_SHELLYEYE, THING_TYPE_SHELLYSMOKE, THING_TYPE_SHELLYGAS,
-                            THING_TYPE_SHELLYFLOOD, THING_TYPE_SHELLYDOORWIN, THING_TYPE_SHELLYDOORWIN2,
-                            THING_TYPE_SHELLYBUTTON1, THING_TYPE_SHELLYPROTECTED, THING_TYPE_SHELLYUNKNOWN)
-                    .collect(Collectors.toSet()));
+    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.unmodifiableSet(
+            Stream.of(THING_TYPE_SHELLY1, THING_TYPE_SHELLY1PM, THING_TYPE_SHELLYEM, THING_TYPE_SHELLY3EM,
+                    THING_TYPE_SHELLY2_RELAY, THING_TYPE_SHELLY2_ROLLER, THING_TYPE_SHELLY25_RELAY,
+                    THING_TYPE_SHELLY25_ROLLER, THING_TYPE_SHELLY4PRO, THING_TYPE_SHELLYPLUG, THING_TYPE_SHELLYPLUGS,
+                    THING_TYPE_SHELLYPLUGU1, THING_TYPE_SHELLYDIMMER, THING_TYPE_SHELLYDIMMER2, THING_TYPE_SHELLYIX3,
+                    THING_TYPE_SHELLYBULB, THING_TYPE_SHELLYDUO, THING_TYPE_SHELLYVINTAGE, THING_TYPE_SHELLYRGBW2_COLOR,
+                    THING_TYPE_SHELLYRGBW2_WHITE, THING_TYPE_SHELLYHT, THING_TYPE_SHELLYSENSE, THING_TYPE_SHELLYEYE,
+                    THING_TYPE_SHELLYSMOKE, THING_TYPE_SHELLYGAS, THING_TYPE_SHELLYFLOOD, THING_TYPE_SHELLYDOORWIN,
+                    THING_TYPE_SHELLYDOORWIN2, THING_TYPE_SHELLYBUTTON1, THING_TYPE_SHELLYPROTECTED,
+                    THING_TYPE_SHELLYUNKNOWN).collect(Collectors.toSet()));
 
     // Thing Configuration Properties
     public static final String CONFIG_DEVICEIP = "deviceIp";
index 66416db0a19ac336b8620e0aae9bac8f6605a170..574f2938e6e401d36cfc7c381a56d0bd2520b90f 100644 (file)
@@ -237,7 +237,7 @@ public class ShellyCoapHandler implements ShellyCoapListener {
                 reqStatus = sendRequest(reqStatus, config.deviceIp, COLOIT_URI_DEVSTATUS, Type.NON);
                 discovering = true;
             }
-        } catch (IllegalArgumentException | NullPointerException e) {
+        } catch (JsonSyntaxException | IllegalArgumentException | NullPointerException e) {
             logger.debug("{}: Unable to process CoIoT Message for payload={}", thingName, payload, e);
             resetSerial();
         }
old mode 100644 (file)
new mode 100755 (executable)
index 620576e..5f7010c
@@ -186,7 +186,7 @@ public class ShellyDiscoveryParticipant implements MDNSDiscoveryParticipant {
                 String thingLabel = deviceName.isEmpty() ? name + " - " + address
                         : deviceName + " (" + name + "@" + address + ")";
                 return DiscoveryResultBuilder.create(thingUID).withProperties(properties).withLabel(thingLabel)
-                        .withRepresentationProperty(name).build();
+                        .withRepresentationProperty(PROPERTY_DEV_NAME).build();
             }
         } catch (IOException | NullPointerException e) {
             // maybe some format description was buggy
index abeb9d7e32464e8133cb4c815d22dbf7ae8bb4d0..2f23146344321b4b00774769078e33fb9039de77 100644 (file)
@@ -32,11 +32,13 @@ import org.openhab.core.thing.ThingUID;
 public class ShellyThingCreator {
     private static final Map<String, String> THING_TYPE_MAPPING = new LinkedHashMap<>();
     static {
-        // mapping by thing type
+        // mapping by device type id
         THING_TYPE_MAPPING.put(SHELLYDT_1PM, THING_TYPE_SHELLY1PM_STR);
         THING_TYPE_MAPPING.put(SHELLYDT_1, THING_TYPE_SHELLY1_STR);
         THING_TYPE_MAPPING.put(SHELLYDT_3EM, THING_TYPE_SHELLY3EM_STR);
         THING_TYPE_MAPPING.put(SHELLYDT_EM, THING_TYPE_SHELLYEM_STR);
+        THING_TYPE_MAPPING.put(SHELLYDT_SHPLG_S, THING_TYPE_SHELLYPLUGS_STR);
+        THING_TYPE_MAPPING.put(SHELLYDT_SHPLG_U1, THING_TYPE_SHELLYPLUGU1_STR);
         THING_TYPE_MAPPING.put(SHELLYDT_GAS, THING_TYPE_SHELLYGAS_STR);
         THING_TYPE_MAPPING.put(SHELLYDT_DW, THING_TYPE_SHELLYDOORWIN_STR);
         THING_TYPE_MAPPING.put(SHELLYDT_DW2, THING_TYPE_SHELLYDOORWIN2_STR);
@@ -112,6 +114,9 @@ public class ShellyThingCreator {
             if (name.startsWith(THING_TYPE_SHELLYPLUGS_STR) || name.contains("-s")) {
                 return THING_TYPE_SHELLYPLUGS_STR;
             }
+            if (name.startsWith(THING_TYPE_SHELLYPLUGU1_STR)) {
+                return THING_TYPE_SHELLYPLUGU1_STR;
+            }
             return THING_TYPE_SHELLYPLUG_STR;
         }
         if (name.startsWith(THING_TYPE_SHELLYRGBW2_PREFIX)) {
index 796067fb061a3b29e76e8b12b7d16b4b41e82016..5345b5325bb202d81b938c6b7ada9ad4c400641a 100644 (file)
@@ -207,7 +207,7 @@ public class ShellyComponents {
                         toQuantityType(getDouble(lastMin1), DIGITS_WATT, SmartHomeUnits.WATT));
 
                 // convert totalWatts into kw/h
-                totalWatts = totalWatts / (60.0 * 10000.0);
+                totalWatts = totalWatts / (60.0 * 1000.0);
                 updated |= thingHandler.updateChannel(groupName, CHANNEL_METER_CURRENTWATTS,
                         toQuantityType(getDouble(currentWatts), DIGITS_WATT, SmartHomeUnits.WATT));
                 updated |= thingHandler.updateChannel(groupName, CHANNEL_METER_TOTALKWH,
index 100022069bec45a9d7cf7bba85d6c420357fe2a4..3d3890cfdaa46f5ee81cbf8ff61ac7ecdcc2bba3 100644 (file)
@@ -465,7 +465,7 @@ channel-type.shelly.colorEffectRGBW2.option.1 = Meteoritenregen
 channel-type.shelly.colorEffectRGBW2.option.2 = Farbverlauf
 channel-type.shelly.colorEffectRGBW2.option.3 = Blitzen
 channel-type.shelly.sensorTemp.label = Temperatur
-channel-type.shelly.sensorTemp.description = Aktuelle Temperatur des Sensors in C
+channel-type.shelly.sensorTemp.description = Aktuelle Temperatur des Sensors in °C
 channel-type.shelly.sensorExtTemp.label = Temperatur
 channel-type.shelly.sensorExtTemp.description = Aktuelle Temperatur des externen Sensors in ∞C
 channel-type.shelly.sensorExtHum.label = Luftfeuchtigkeit
index 09bc887f94a791e9994d49f728a86df2f75fdb1d..b3daaf21b0ae9aefded92b476787a1c4a1e318b7 100644 (file)
@@ -14,6 +14,7 @@
                        <channel-group id="device" typeId="deviceStatus"/>
                </channel-groups>
 
+               <representation-property>deviceName</representation-property>
                <config-description-ref uri="thing-type:shelly:light"/>
        </thing-type>
 
@@ -27,6 +28,7 @@
                        <channel-group id="device" typeId="deviceStatus"/>
                </channel-groups>
 
+               <representation-property>deviceName</representation-property>
                <config-description-ref uri="thing-type:shelly:light"/>
        </thing-type>
 
@@ -40,6 +42,7 @@
                        <channel-group id="device" typeId="deviceStatus"/>
                </channel-groups>
 
+               <representation-property>deviceName</representation-property>
                <config-description-ref uri="thing-type:shelly:light"/>
        </thing-type>
 
@@ -54,6 +57,7 @@
                        <channel-group id="device" typeId="deviceStatus"/>
                </channel-groups>
 
+               <representation-property>deviceName</representation-property>
                <config-description-ref uri="thing-type:shelly:rgbw2"/>
        </thing-type>
 
@@ -78,6 +82,7 @@
                        <channel-group id="device" typeId="deviceStatus"/>
                </channel-groups>
 
+               <representation-property>deviceName</representation-property>
                <config-description-ref uri="thing-type:shelly:rgbw2"/>
        </thing-type>
 
index 6ebd13869f6e142480980eaa3385cd6d1dba5c75..649d1093864ca0e1e2f97eaa18bf55c65ecd5c3b 100644 (file)
@@ -13,6 +13,7 @@
                        <channel-group id="device" typeId="deviceStatus"/>
                </channel-groups>
 
+               <representation-property>deviceName</representation-property>
                <config-description-ref uri="thing-type:shelly:relay"/>
        </thing-type>
 
@@ -26,6 +27,7 @@
                        <channel-group id="device" typeId="deviceStatus"/>
                </channel-groups>
 
+               <representation-property>deviceName</representation-property>
                <config-description-ref uri="thing-type:shelly:relay"/>
        </thing-type>
 
@@ -43,6 +45,7 @@
                        <channel-group id="device" typeId="deviceStatus"/>
                </channel-groups>
 
+               <representation-property>deviceName</representation-property>
                <config-description-ref uri="thing-type:shelly:relay"/>
        </thing-type>
 
@@ -64,6 +67,7 @@
                        <channel-group id="device" typeId="deviceStatus"/>
                </channel-groups>
 
+               <representation-property>deviceName</representation-property>
                <config-description-ref uri="thing-type:shelly:relay"/>
        </thing-type>
 
                        <channel-group id="device" typeId="deviceStatus"/>
                </channel-groups>
 
+               <representation-property>deviceName</representation-property>
                <config-description-ref uri="thing-type:shelly:relay"/>
        </thing-type>
+
        <thing-type id="shelly2-roller">
                <label>Shelly2 Roller (SHSW-21)</label>
                <description>Shelly2 in Roller Mode</description>
                        <channel-group id="device" typeId="deviceStatus"/>
                </channel-groups>
 
+               <representation-property>deviceName</representation-property>
                <config-description-ref uri="thing-type:shelly:roller"/>
        </thing-type>
 
                        <channel-group id="device" typeId="deviceStatus"/>
                </channel-groups>
 
+               <representation-property>deviceName</representation-property>
                <config-description-ref uri="thing-type:shelly:relay"/>
        </thing-type>
+
        <thing-type id="shelly25-roller">
                <label>Shelly2.5 Roller (SHSW-25)</label>
                <description>Shelly2 in Roller Mode</description>
                        <channel-group id="device" typeId="deviceStatus"/>
                </channel-groups>
 
+               <representation-property>deviceName</representation-property>
                <config-description-ref uri="thing-type:shelly:roller"/>
        </thing-type>
 
                        <channel-group id="device" typeId="deviceStatus"/>
                </channel-groups>
 
+               <representation-property>deviceName</representation-property>
                <config-description-ref uri="thing-type:shelly:relay"/>
        </thing-type>
 
                        <channel-group id="device" typeId="deviceStatus"/>
                </channel-groups>
 
+               <representation-property>deviceName</representation-property>
                <config-description-ref uri="thing-type:shelly:relay"/>
        </thing-type>
 
                        <channel-group id="device" typeId="deviceStatus"/>
                </channel-groups>
 
+               <representation-property>deviceName</representation-property>
+               <config-description-ref uri="thing-type:shelly:relay"/>
+       </thing-type>
+
+       <thing-type id="shellyplugu1">
+               <label>Shelly Plug US (SHPLG-U1)</label>
+               <description>Shelly Plug US with relay and meter</description>
+
+               <channel-groups>
+                       <channel-group id="relay" typeId="relayChannelPlug"/>
+                       <channel-group id="meter" typeId="meter"/>
+                       <channel-group id="device" typeId="deviceStatus"/>
+               </channel-groups>
+
+               <representation-property>deviceName</representation-property>
                <config-description-ref uri="thing-type:shelly:relay"/>
        </thing-type>
 
                        <channel-group id="device" typeId="deviceStatus"/>
                </channel-groups>
 
+               <representation-property>deviceName</representation-property>
                <config-description-ref uri="thing-type:shelly:dimmer"/>
        </thing-type>
 
                        <channel-group id="device" typeId="deviceStatus"/>
                </channel-groups>
 
+               <representation-property>deviceName</representation-property>
                <config-description-ref uri="thing-type:shelly:dimmer"/>
        </thing-type>
 
                        <channel-group id="device" typeId="deviceStatus"/>
                </channel-groups>
 
+               <representation-property>deviceName</representation-property>
                <config-description-ref uri="thing-type:shelly:relay"/>
        </thing-type>
 
index 3131955efc76ec745811780af59d18614d4c644a..d877c0c694ce5daaa35ae037cd837ed51890df9f 100644 (file)
@@ -14,6 +14,7 @@
                        <channel-group id="device" typeId="deviceStatus"/>
                </channel-groups>
 
+               <representation-property>deviceName</representation-property>
                <config-description-ref uri="thing-type:shelly:battery"/>
        </thing-type>
 
@@ -27,6 +28,7 @@
                        <channel-group id="device" typeId="deviceStatus"/>
                </channel-groups>
 
+               <representation-property>deviceName</representation-property>
                <config-description-ref uri="thing-type:shelly:battery"/>
        </thing-type>
 
@@ -39,6 +41,7 @@
                        <channel-group id="device" typeId="deviceStatus"/>
                </channel-groups>
 
+               <representation-property>deviceName</representation-property>
                <config-description-ref uri="thing-type:shelly:basic"/>
        </thing-type>
 
@@ -51,6 +54,7 @@
                        <channel-group id="device" typeId="deviceStatus"/>
                </channel-groups>
 
+               <representation-property>deviceName</representation-property>
                <config-description-ref uri="thing-type:shelly:battery"/>
        </thing-type>
 
@@ -64,6 +68,7 @@
                        <channel-group id="device" typeId="deviceStatus"/>
                </channel-groups>
 
+               <representation-property>deviceName</representation-property>
                <config-description-ref uri="thing-type:shelly:battery"/>
        </thing-type>
 
@@ -77,6 +82,7 @@
                        <channel-group id="device" typeId="deviceStatus"/>
                </channel-groups>
 
+               <representation-property>deviceName</representation-property>
                <config-description-ref uri="thing-type:shelly:battery"/>
        </thing-type>
 
@@ -90,6 +96,7 @@
                        <channel-group id="device" typeId="deviceStatus"/>
                </channel-groups>
 
+               <representation-property>deviceName</representation-property>
                <config-description-ref uri="thing-type:shelly:battery"/>
        </thing-type>
 
                        <channel-group id="device" typeId="deviceStatus"/>
                </channel-groups>
 
+               <representation-property>deviceName</representation-property>
                <config-description-ref uri="thing-type:shelly:battery"/>
        </thing-type>
 
index 03a20ca8c083d28e74ec9a2efe30033abd2655a1..7555e75eccf3f554d41ad949df4235ccf48a94bd 100644 (file)
@@ -8,6 +8,7 @@
                <label>Shelly Device</label>
                <description>A password protected or unknown device.</description>
 
+               <representation-property>deviceName</representation-property>
                <config-description>
                        <parameter name="userId" type="text" required="true">
                                <label>UserID</label>
@@ -30,6 +31,7 @@
        <thing-type id="shellyunknown">
                <label>Unknown Shelly Device</label>
                <description>This device is currently not supported</description>
+               <representation-property>deviceName</representation-property>
        </thing-type>
 
 </thing:thing-descriptions>