]> git.basschouten.com Git - openhab-addons.git/commitdiff
[melcloud] Fixed representation property (#10133)
authorChristoph Weitkamp <github@christophweitkamp.de>
Sat, 13 Feb 2021 20:10:26 +0000 (21:10 +0100)
committerGitHub <noreply@github.com>
Sat, 13 Feb 2021 20:10:26 +0000 (12:10 -0800)
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
bundles/org.openhab.binding.melcloud/src/main/java/org/openhab/binding/melcloud/internal/discovery/MelCloudDiscoveryService.java
bundles/org.openhab.binding.melcloud/src/main/resources/OH-INF/thing/acDevice.xml
bundles/org.openhab.binding.melcloud/src/main/resources/OH-INF/thing/heatpumpDevice.xml

index 4d090ea26920329e56d574ee5bd634978fc71eae..975d2b449e7efb5ae97bb626800c3ee43bf6a530 100644 (file)
@@ -29,6 +29,7 @@ import org.openhab.binding.melcloud.internal.handler.MelCloudAccountHandler;
 import org.openhab.core.config.discovery.AbstractDiscoveryService;
 import org.openhab.core.config.discovery.DiscoveryResultBuilder;
 import org.openhab.core.config.discovery.DiscoveryService;
+import org.openhab.core.thing.Thing;
 import org.openhab.core.thing.ThingTypeUID;
 import org.openhab.core.thing.ThingUID;
 import org.openhab.core.thing.binding.ThingHandler;
@@ -46,8 +47,10 @@ import org.slf4j.LoggerFactory;
  */
 public class MelCloudDiscoveryService extends AbstractDiscoveryService
         implements DiscoveryService, ThingHandlerService {
+
     private final Logger logger = LoggerFactory.getLogger(MelCloudDiscoveryService.class);
 
+    private static final String PROPERTY_DEVICE_ID = "deviceID";
     private static final int DISCOVER_TIMEOUT_SECONDS = 10;
 
     private MelCloudAccountHandler melCloudHandler;
@@ -126,9 +129,9 @@ public class MelCloudDiscoveryService extends AbstractDiscoveryService
                                 device.getDeviceID().toString());
 
                         Map<String, Object> deviceProperties = new HashMap<>();
-                        deviceProperties.put("deviceID", device.getDeviceID().toString());
-                        deviceProperties.put("serialNumber", device.getSerialNumber().toString());
-                        deviceProperties.put("macAddress", device.getMacAddress().toString());
+                        deviceProperties.put(PROPERTY_DEVICE_ID, device.getDeviceID().toString());
+                        deviceProperties.put(Thing.PROPERTY_SERIAL_NUMBER, device.getSerialNumber().toString());
+                        deviceProperties.put(Thing.PROPERTY_MAC_ADDRESS, device.getMacAddress().toString());
                         deviceProperties.put("deviceName", device.getDeviceName().toString());
                         deviceProperties.put("buildingID", device.getBuildingID().toString());
 
@@ -136,9 +139,8 @@ public class MelCloudDiscoveryService extends AbstractDiscoveryService
                         logger.debug("Found device: {} : {}", label, deviceProperties);
 
                         thingDiscovered(DiscoveryResultBuilder.create(deviceThing).withLabel(label)
-                                .withProperties(deviceProperties)
-                                .withRepresentationProperty(device.getDeviceID().toString()).withBridge(bridgeUID)
-                                .build());
+                                .withProperties(deviceProperties).withRepresentationProperty(PROPERTY_DEVICE_ID)
+                                .withBridge(bridgeUID).build());
                     });
                 }
             } catch (MelCloudLoginException e) {
index 18c1b34153f4267f82faf5a41aba6a3810675a0e..5779708c504ea147456b98a7983a51b37220b674 100644 (file)
@@ -25,6 +25,8 @@
                        <channel id="nextCommunication" typeId="nextCommunication-channel"/>
                </channels>
 
+               <representation-property>deviceID</representation-property>
+
                <config-description>
                        <parameter name="deviceID" type="integer" required="true">
                                <label>Device ID</label>
index aa0d2faf7c96a50619630833cfe1bf7e1909cc5b..3b58cec5d946af4caae6d3e09e8319caa4741d23 100644 (file)
@@ -23,6 +23,8 @@
                        <channel id="nextCommunication" typeId="nextCommunication-channel"/>
                </channels>
 
+               <representation-property>deviceID</representation-property>
+
                <config-description>
                        <parameter name="deviceID" type="integer" required="true">
                                <label>Device ID</label>