Skip to content

Commit

Permalink
Consolidate property handling
Browse files Browse the repository at this point in the history
  • Loading branch information
HahnBenjamin committed Jun 15, 2020
1 parent 45d2c33 commit 89b4e16
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,17 @@ private void addLight(String lightID, LightMessage light) {
}

Map<String, Object> properties = new HashMap<>();
properties.put("id", lightType);
properties.put(UNIQUE_ID, light.uniqueid);
properties.put(Thing.PROPERTY_FIRMWARE_VERSION, light.swversion);
properties.put(Thing.PROPERTY_FIRMWARE_VERSION, light.swversion);
properties.put(Thing.PROPERTY_VENDOR, light.manufacturername);
properties.put(Thing.PROPERTY_MODEL_ID, light.modelid);

if (light.ctmax != null)
if (light.ctmax != null && light.ctmin != null) {
properties.put(PROPERTY_CT_MAX, Integer.toString(light.ctmax));
if (light.ctmin != null)
properties.put(PROPERTY_CT_MIN, Integer.toString(light.ctmin));
}

switch (lightType) {
case ON_OFF_LIGHT:
Expand Down Expand Up @@ -160,8 +163,6 @@ private void addLight(String lightID, LightMessage light) {
ThingUID uid = new ThingUID(thingTypeUID, bridgeUID, light.uniqueid.replaceAll("[^a-z0-9\\[\\]]", ""));
DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(uid).withBridge(bridgeUID)
.withLabel(light.name + " (" + light.manufacturername + ")")
.withProperty("id", lightID)
.withProperty(UNIQUE_ID, light.uniqueid)
.withProperties(properties)
.withRepresentationProperty(UNIQUE_ID)
.build();
Expand Down

0 comments on commit 89b4e16

Please sign in to comment.