From ff4d97eb2aeabb61390ce1b2ffe0e93477c131b5 Mon Sep 17 00:00:00 2001
From: Markus Michels <markus7017@gmail.com>
Date: Sun, 4 Oct 2020 18:39:59 +0200
Subject: [PATCH] [shelly] Adaption to OH3, Shelly Plug US, minor fixes (#8642)

* 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>
---
 .../internal/ShellyBindingConstants.java      | 26 ++++++++--------
 .../shelly/internal/ShellyHandlerFactory.java |  0
 .../internal/coap/ShellyCoapHandler.java      |  2 +-
 .../config/ShellyThingConfiguration.java      |  0
 .../discovery/ShellyDiscoveryParticipant.java |  2 +-
 .../discovery/ShellyThingCreator.java         |  7 ++++-
 .../internal/handler/ShellyBaseHandler.java   |  0
 .../internal/handler/ShellyComponents.java    |  2 +-
 .../OH-INF/i18n/shelly_de.properties          |  2 +-
 .../main/resources/OH-INF/thing/lights.xml    |  5 ++++
 .../src/main/resources/OH-INF/thing/relay.xml | 30 +++++++++++++++++++
 .../main/resources/OH-INF/thing/sensor.xml    |  8 +++++
 .../main/resources/OH-INF/thing/unknown.xml   |  2 ++
 13 files changed, 69 insertions(+), 17 deletions(-)
 mode change 100644 => 100755 bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/ShellyBindingConstants.java
 mode change 100644 => 100755 bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/ShellyHandlerFactory.java
 mode change 100644 => 100755 bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/config/ShellyThingConfiguration.java
 mode change 100644 => 100755 bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/discovery/ShellyDiscoveryParticipant.java
 mode change 100644 => 100755 bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/handler/ShellyBaseHandler.java

diff --git a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/ShellyBindingConstants.java b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/ShellyBindingConstants.java
old mode 100644
new mode 100755
index eb2ddfe99..36a4ec547
--- a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/ShellyBindingConstants.java
+++ b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/ShellyBindingConstants.java
@@ -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";
diff --git a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/ShellyHandlerFactory.java b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/ShellyHandlerFactory.java
old mode 100644
new mode 100755
diff --git a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/coap/ShellyCoapHandler.java b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/coap/ShellyCoapHandler.java
index 66416db0a..574f2938e 100644
--- a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/coap/ShellyCoapHandler.java
+++ b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/coap/ShellyCoapHandler.java
@@ -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();
         }
diff --git a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/config/ShellyThingConfiguration.java b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/config/ShellyThingConfiguration.java
old mode 100644
new mode 100755
diff --git a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/discovery/ShellyDiscoveryParticipant.java b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/discovery/ShellyDiscoveryParticipant.java
old mode 100644
new mode 100755
index 620576e4f..5f7010cb8
--- a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/discovery/ShellyDiscoveryParticipant.java
+++ b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/discovery/ShellyDiscoveryParticipant.java
@@ -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
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 abeb9d7e3..2f2314634 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
@@ -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)) {
diff --git a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/handler/ShellyBaseHandler.java b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/handler/ShellyBaseHandler.java
old mode 100644
new mode 100755
diff --git a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/handler/ShellyComponents.java b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/handler/ShellyComponents.java
index 796067fb0..5345b5325 100644
--- a/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/handler/ShellyComponents.java
+++ b/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/handler/ShellyComponents.java
@@ -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,
diff --git a/bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/i18n/shelly_de.properties b/bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/i18n/shelly_de.properties
index 100022069..3d3890cfd 100644
--- a/bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/i18n/shelly_de.properties
+++ b/bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/i18n/shelly_de.properties
@@ -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
diff --git a/bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/thing/lights.xml b/bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/thing/lights.xml
index 09bc887f9..b3daaf21b 100644
--- a/bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/thing/lights.xml
+++ b/bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/thing/lights.xml
@@ -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>
 
diff --git a/bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/thing/relay.xml b/bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/thing/relay.xml
index 6ebd13869..649d10938 100644
--- a/bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/thing/relay.xml
+++ b/bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/thing/relay.xml
@@ -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>
 
@@ -82,8 +86,10 @@
 			<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>
@@ -94,6 +100,7 @@
 			<channel-group id="device" typeId="deviceStatus"/>
 		</channel-groups>
 
+		<representation-property>deviceName</representation-property>
 		<config-description-ref uri="thing-type:shelly:roller"/>
 	</thing-type>
 
@@ -116,8 +123,10 @@
 			<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>
@@ -128,6 +137,7 @@
 			<channel-group id="device" typeId="deviceStatus"/>
 		</channel-groups>
 
+		<representation-property>deviceName</representation-property>
 		<config-description-ref uri="thing-type:shelly:roller"/>
 	</thing-type>
 
@@ -163,6 +173,7 @@
 			<channel-group id="device" typeId="deviceStatus"/>
 		</channel-groups>
 
+		<representation-property>deviceName</representation-property>
 		<config-description-ref uri="thing-type:shelly:relay"/>
 	</thing-type>
 
@@ -175,6 +186,7 @@
 			<channel-group id="device" typeId="deviceStatus"/>
 		</channel-groups>
 
+		<representation-property>deviceName</representation-property>
 		<config-description-ref uri="thing-type:shelly:relay"/>
 	</thing-type>
 
@@ -188,6 +200,21 @@
 			<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>
 
@@ -201,6 +228,7 @@
 			<channel-group id="device" typeId="deviceStatus"/>
 		</channel-groups>
 
+		<representation-property>deviceName</representation-property>
 		<config-description-ref uri="thing-type:shelly:dimmer"/>
 	</thing-type>
 
@@ -214,6 +242,7 @@
 			<channel-group id="device" typeId="deviceStatus"/>
 		</channel-groups>
 
+		<representation-property>deviceName</representation-property>
 		<config-description-ref uri="thing-type:shelly:dimmer"/>
 	</thing-type>
 
@@ -227,6 +256,7 @@
 			<channel-group id="device" typeId="deviceStatus"/>
 		</channel-groups>
 
+		<representation-property>deviceName</representation-property>
 		<config-description-ref uri="thing-type:shelly:relay"/>
 	</thing-type>
 
diff --git a/bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/thing/sensor.xml b/bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/thing/sensor.xml
index 3131955ef..d877c0c69 100644
--- a/bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/thing/sensor.xml
+++ b/bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/thing/sensor.xml
@@ -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>
 
@@ -103,6 +110,7 @@
 			<channel-group id="device" typeId="deviceStatus"/>
 		</channel-groups>
 
+		<representation-property>deviceName</representation-property>
 		<config-description-ref uri="thing-type:shelly:battery"/>
 	</thing-type>
 
diff --git a/bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/thing/unknown.xml b/bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/thing/unknown.xml
index 03a20ca8c..7555e75ec 100644
--- a/bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/thing/unknown.xml
+++ b/bundles/org.openhab.binding.shelly/src/main/resources/OH-INF/thing/unknown.xml
@@ -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>