Skip to content

Commit

Permalink
Apply spotless fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Benajmin Hahn <[email protected]>
  • Loading branch information
HahnBenjamin committed Jun 18, 2020
1 parent e64256c commit 7797697
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,5 @@ public class BindingConstants {
public static final int ZCL_CT_UNDEFINED = 0; // 0x0000
public static final int ZCL_CT_MIN = 1;
public static final int ZCL_CT_MAX = 65279; // 0xFEFF
public static final int ZCL_CT_INVALID = 65535; //0xFFFF
public static final int ZCL_CT_INVALID = 65535; // 0xFFFF
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@
@NonNullByDefault
public class ThingDiscoveryService extends AbstractDiscoveryService implements DiscoveryService, ThingHandlerService {
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Stream
.of(LightThingHandler.SUPPORTED_THING_TYPE_UIDS,
SensorThingHandler.SUPPORTED_THING_TYPES,
.of(LightThingHandler.SUPPORTED_THING_TYPE_UIDS, SensorThingHandler.SUPPORTED_THING_TYPES,
SensorThermostatThingHandler.SUPPORTED_THING_TYPES)
.flatMap(Set::stream).collect(Collectors.toSet());
private final Logger logger = LoggerFactory.getLogger(ThingDiscoveryService.class);
Expand Down Expand Up @@ -123,7 +122,7 @@ private void addLight(String lightID, LightMessage light) {
if (light.ctmax != null && light.ctmin != null) {
int ctmax = (light.ctmax > ZCL_CT_MAX) ? ZCL_CT_MAX : light.ctmax;
properties.put(PROPERTY_CT_MAX, Integer.toString(ctmax));

int ctmin = (light.ctmin < ZCL_CT_MIN) ? ZCL_CT_MIN : light.ctmin;
properties.put(PROPERTY_CT_MIN, Integer.toString(ctmin));
}
Expand Down Expand Up @@ -162,10 +161,8 @@ 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 + ")")
.withProperties(properties)
.withRepresentationProperty(UNIQUE_ID)
.build();
.withLabel(light.name + " (" + light.manufacturername + ")").withProperties(properties)
.withRepresentationProperty(UNIQUE_ID).build();
thingDiscovered(discoveryResult);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,8 @@
@NonNullByDefault
public class LightThingHandler extends DeconzBaseThingHandler<LightMessage> {
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPE_UIDS = Stream
.of(THING_TYPE_COLOR_TEMPERATURE_LIGHT,
THING_TYPE_DIMMABLE_LIGHT,
THING_TYPE_COLOR_LIGHT,
THING_TYPE_EXTENDED_COLOR_LIGHT,
THING_TYPE_ONOFF_LIGHT,
THING_TYPE_WINDOW_COVERING)
.of(THING_TYPE_COLOR_TEMPERATURE_LIGHT, THING_TYPE_DIMMABLE_LIGHT, THING_TYPE_COLOR_LIGHT,
THING_TYPE_EXTENDED_COLOR_LIGHT, THING_TYPE_ONOFF_LIGHT, THING_TYPE_WINDOW_COVERING)
.collect(Collectors.toSet());

private static final double HUE_FACTOR = 65535 / 360.0;
Expand Down Expand Up @@ -280,10 +276,11 @@ private void valueUpdated(String channelId, LightState newState) {
HSBType color = HSBType.fromXY((float) xy[0], (float) xy[1]);
updateState(channelId, new HSBType(color.getHue(), color.getSaturation(), toPercentType(bri)));
}
} else if (bri != null && newState.hue != null && newState.sat != null) {
} else if (bri != null && newState.hue != null && newState.sat != null) {
final Integer hue = newState.hue;
final Integer sat = newState.sat;
updateState(channelId, new HSBType(new DecimalType(hue / HUE_FACTOR), toPercentType(sat), toPercentType(bri)));
updateState(channelId,
new HSBType(new DecimalType(hue / HUE_FACTOR), toPercentType(sat), toPercentType(bri)));
}
break;
case CHANNEL_BRIGHTNESS:
Expand Down Expand Up @@ -326,7 +323,6 @@ public void messageReceived(String sensorID, DeconzBaseMessage message) {
}
}


private PercentType toPercentType(int val) {
int scaledValue = (int) Math.ceil(val / BRIGHTNESS_FACTOR);
if (scaledValue < 0 || scaledValue > 100) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ protected void createTypeSpecificChannels(SensorConfig sensorConfig, SensorState
createChannel(CHANNEL_GESTURE, ChannelKind.STATE);
createChannel(CHANNEL_GESTUREEVENT, ChannelKind.TRIGGER);
}

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,5 @@ public ThermostatMode deserialize(@Nullable JsonElement json, @Nullable Type typ
public JsonElement serialize(ThermostatMode src, @Nullable Type typeOfSrc,
@Nullable JsonSerializationContext context) throws JsonParseException {
return src != ThermostatMode.UNKNOWN ? new JsonPrimitive(src.getDeconzValue()) : JsonNull.INSTANCE;

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@
<option value="AUTO">auto</option>
<option value="HEAT">heat</option>
<option value="OFF">off</option>
</options>
</options>
</state>
</channel-type>
<channel-type id="offset">
Expand Down

0 comments on commit 7797697

Please sign in to comment.