Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[deconz] Pimp properties and channel types with proper categories #9513

Merged
merged 1 commit into from
Dec 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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