Skip to content

Commit

Permalink
[deconz] Pimp channel types with proper categories (openhab#9513)
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Weitkamp <[email protected]>
  • Loading branch information
cweitkamp authored and thinkingstone committed Nov 7, 2021
1 parent 99872d8 commit 5390b28
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,14 @@ private void addSensor(String sensorID, SensorMessage sensor) {
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
Expand Down Expand Up @@ -281,8 +289,8 @@ private void addSensor(String sensorID, SensorMessage sensor) {
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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,10 @@ protected void processStateResponse(DeconzBaseMessage stateResponse) {
}

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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand All @@ -20,13 +20,6 @@
<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>
Expand Down Expand Up @@ -469,7 +462,7 @@
<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>

Expand All @@ -478,13 +471,6 @@
<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"/>
Expand Down

0 comments on commit 5390b28

Please sign in to comment.