logger.debug("Using long SSE httpClient={} for {}}", httpClientSSETouchEvent, httpClientName);
}
+ @Override
public void initialize() {
logger.debug("Initializing the controller (bridge)");
updateStatus(ThingStatus.UNKNOWN);
}
}
+ @Override
public void handleCommand(ChannelUID channelUID, Command command) {
logger.debug("Received command {} for channel {}", command, channelUID);
if (!ThingStatus.ONLINE.equals(getThing().getStatusInfo().getStatus())) {
private void handleTouchEvents(TouchEvents touchEvents) {
touchEvents.getEvents().forEach((event) -> {
- logger.info("panel: {} gesture id: {}", event.getPanelId(), event.getGesture());
+ logger.debug("panel: {} gesture id: {}", event.getPanelId(), event.getGesture());
// Swipes go to the controller, taps go to the individual panel
if (event.getPanelId().equals(CONTROLLER_PANEL_ID)) {
logger.debug("Triggering controller {} with gesture {}.", thing.getUID(), event.getGesture());
hue = min == null ? 0 : min;
Integer max = colorTemperature.getMax();
saturation = max == null ? 0 : max;
- colorTempPercent = (float) ((colorTemperature.getValue() - hue) / (saturation - hue)
- * PercentType.HUNDRED.intValue());
+ colorTempPercent = (colorTemperature.getValue() - hue) / (saturation - hue)
+ * PercentType.HUNDRED.intValue();
}
updateState(CHANNEL_COLOR_TEMPERATURE, new PercentType(Float.toString(colorTempPercent)));
updateState(CHANNEL_RHYTHM_MODE, new DecimalType(controllerInfo.getRhythm().getRhythmMode()));
updateState(CHANNEL_RHYTHM_STATE,
controllerInfo.getRhythm().getRhythmConnected() ? OnOffType.ON : OnOffType.OFF);
- // update bridge properties which may have changed, or are not present during discovery
- Map<String, String> properties = editProperties();
- properties.put(Thing.PROPERTY_SERIAL_NUMBER, controllerInfo.getSerialNo());
- properties.put(Thing.PROPERTY_FIRMWARE_VERSION, controllerInfo.getFirmwareVersion());
- properties.put(Thing.PROPERTY_MODEL_ID, controllerInfo.getModel());
- properties.put(Thing.PROPERTY_VENDOR, controllerInfo.getManufacturer());
- updateProperties(properties);
- Configuration config = editConfiguration();
- if (hasTouchSupport(controllerInfo.getModel())) {
- config.put(NanoleafControllerConfig.DEVICE_TYPE, DEVICE_TYPE_TOUCHSUPPORT);
- logger.debug("Set to device type {}", DEVICE_TYPE_TOUCHSUPPORT);
- } else {
- config.put(NanoleafControllerConfig.DEVICE_TYPE, DEVICE_TYPE_LIGHTPANELS);
- logger.debug("Set to device type {}", DEVICE_TYPE_LIGHTPANELS);
- }
- updateConfiguration(config);
-
- getConfig().getProperties().forEach((key, value) -> {
- logger.trace("Configuration property: key {} value {}", key, value);
- });
-
- getThing().getProperties().forEach((key, value) -> {
- logger.debug("Thing property: key {} value {}", key, value);
- });
// update the color channels of each panel
getThing().getThings().forEach(child -> {
}
});
+ updateProperties();
+ updateConfiguration();
+
for (NanoleafControllerListener controllerListener : controllerListeners) {
controllerListener.onControllerInfoFetched(getThing().getUID(), controllerInfo);
}
}
+ private void updateConfiguration() {
+ // only update the Thing config if value isn't set yet
+ if (getConfig().get(NanoleafControllerConfig.DEVICE_TYPE) == null) {
+ Configuration config = editConfiguration();
+ if (hasTouchSupport(controllerInfo.getModel())) {
+ config.put(NanoleafControllerConfig.DEVICE_TYPE, DEVICE_TYPE_TOUCHSUPPORT);
+ logger.debug("Set to device type {}", DEVICE_TYPE_TOUCHSUPPORT);
+ } else {
+ config.put(NanoleafControllerConfig.DEVICE_TYPE, DEVICE_TYPE_LIGHTPANELS);
+ logger.debug("Set to device type {}", DEVICE_TYPE_LIGHTPANELS);
+ }
+ updateConfiguration(config);
+ if (logger.isTraceEnabled()) {
+ getConfig().getProperties().forEach((key, value) -> {
+ logger.trace("Configuration property: key {} value {}", key, value);
+ });
+ }
+ }
+ }
+
+ private void updateProperties() {
+ // update bridge properties which may have changed, or are not present during discovery
+ Map<String, String> properties = editProperties();
+ properties.put(Thing.PROPERTY_SERIAL_NUMBER, controllerInfo.getSerialNo());
+ properties.put(Thing.PROPERTY_FIRMWARE_VERSION, controllerInfo.getFirmwareVersion());
+ properties.put(Thing.PROPERTY_MODEL_ID, controllerInfo.getModel());
+ properties.put(Thing.PROPERTY_VENDOR, controllerInfo.getManufacturer());
+ updateProperties(properties);
+ if (logger.isTraceEnabled()) {
+ getThing().getProperties().forEach((key, value) -> {
+ logger.trace("Thing property: key {} value {}", key, value);
+ });
+ }
+ }
+
private ControllerInfo receiveControllerInfo() throws NanoleafException, NanoleafUnauthorizedException {
ContentResponse controllerlInfoJSON = OpenAPIUtils.sendOpenAPIRequest(OpenAPIUtils.requestBuilder(httpClient,
getControllerConfig(), API_GET_CONTROLLER_INFO, HttpMethod.GET));