]> git.basschouten.com Git - openhab-addons.git/commitdiff
[deconz] Pimp channel types with proper categories (#9513)
authorChristoph Weitkamp <github@christophweitkamp.de>
Fri, 25 Dec 2020 13:17:03 +0000 (14:17 +0100)
committerGitHub <noreply@github.com>
Fri, 25 Dec 2020 13:17:03 +0000 (14:17 +0100)
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/discovery/ThingDiscoveryService.java
bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/SensorBaseThingHandler.java
bundles/org.openhab.binding.deconz/src/main/resources/OH-INF/thing/sensor-thing-types.xml

index 3e3bd8dba119981cbc3d289af8924c288d465c0a..6c92cb5185455355113b7d6bdc66728b734fa7b5 100644 (file)
@@ -237,6 +237,14 @@ public class ThingDiscoveryService extends AbstractDiscoveryService implements D
             return;
         }
         ThingTypeUID thingTypeUID;
+
+        Map<String, Object> properties = new HashMap<>();
+        properties.put(CONFIG_ID, sensorID);
+        properties.put(UNIQUE_ID, sensor.uniqueid);
+        properties.put(Thing.PROPERTY_FIRMWARE_VERSION, sensor.swversion);
+        properties.put(Thing.PROPERTY_VENDOR, sensor.manufacturername);
+        properties.put(Thing.PROPERTY_MODEL_ID, sensor.modelid);
+
         if (sensor.type.contains("Daylight")) { // deCONZ specific: Software simulated daylight sensor
             thingTypeUID = THING_TYPE_DAYLIGHT_SENSOR;
         } else if (sensor.type.contains("Power")) { // ZHAPower, CLIPPower
@@ -281,8 +289,8 @@ public class ThingDiscoveryService extends AbstractDiscoveryService implements D
         ThingUID uid = new ThingUID(thingTypeUID, bridgeUID, sensor.uniqueid.replaceAll("[^a-z0-9\\[\\]]", ""));
 
         DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(uid).withBridge(bridgeUID)
-                .withLabel(sensor.name + " (" + sensor.manufacturername + ")").withProperty(CONFIG_ID, sensorID)
-                .withProperty(UNIQUE_ID, sensor.uniqueid).withRepresentationProperty(UNIQUE_ID).build();
+                .withLabel(sensor.name + " (" + sensor.manufacturername + ")").withProperties(properties)
+                .withRepresentationProperty(UNIQUE_ID).build();
         thingDiscovered(discoveryResult);
     }
 
index b5891dbfec138cc485bb5a84a7712d46c47fe57f..14400945cbd18f67217a863f58bc665701db317a 100644 (file)
@@ -127,9 +127,10 @@ public abstract class SensorBaseThingHandler extends DeconzBaseThingHandler {
         }
 
         Map<String, String> editProperties = editProperties();
+        editProperties.put(UNIQUE_ID, sensorMessage.uniqueid);
         editProperties.put(Thing.PROPERTY_FIRMWARE_VERSION, sensorMessage.swversion);
+        editProperties.put(Thing.PROPERTY_VENDOR, sensorMessage.manufacturername);
         editProperties.put(Thing.PROPERTY_MODEL_ID, sensorMessage.modelid);
-        editProperties.put(UNIQUE_ID, sensorMessage.uniqueid);
         ignoreConfigurationUpdate = true;
         updateProperties(editProperties);
 
index bd00412d9d812f9dfa3570ec55b6a01a67a0ca00..a991e36574c8bfedec8514d34c6639d00b45483b 100644 (file)
@@ -11,7 +11,7 @@
                <label>Presence Sensor</label>
                <description>A Presence sensor</description>
                <channels>
-                       <channel typeId="presence" id="presence"/>
+                       <channel typeId="system.motion" id="presence"/>
                        <channel typeId="last_updated" id="last_updated"/>
                </channels>
 
                <config-description-ref uri="thing-type:deconz:sensor"/>
        </thing-type>
 
-       <channel-type id="presence">
-               <item-type>Switch</item-type>
-               <label>Presence</label>
-               <description>Presence detected</description>
-               <state readOnly="true"></state>
-       </channel-type>
-
        <channel-type id="last_updated">
                <item-type>DateTime</item-type>
                <label>Last Updated</label>
                <label>Battery Sensor</label>
                <description>A battery sensor</description>
                <channels>
-                       <channel typeId="battery" id="battery_level"/>
+                       <channel typeId="system.battery-level" id="battery_level"/>
                        <channel typeId="last_updated" id="last_updated"/>
                </channels>
 
                <config-description-ref uri="thing-type:deconz:sensor"/>
        </thing-type>
 
-       <channel-type id="battery">
-               <item-type>Number</item-type>
-               <label>Battery</label>
-               <description>The battery state.</description>
-               <state pattern="%d %%" readOnly="true"/>
-       </channel-type>
-
        <thing-type id="carbonmonoxidesensor">
                <supported-bridge-type-refs>
                        <bridge-type-ref id="deconz"/>