Various small enhancements (#11874)
- do not go from INITIALIZING to OFFLINE and then ONLINE, but skip OFFLINE for panels, if the controller is ONLINE - reduce logging to debug when receiving trigger events - only update Thing configuration if necessary to avoid Thing updated events - fix description of model types, which was outdated due to new models being available by now Signed-off-by: Kai Kreuzer <kai.kreuzer@telekom.de>
This commit is contained in:
parent
96a8f942b1
commit
db567bc652
@ -144,6 +144,7 @@ public class NanoleafControllerHandler extends BaseBridgeHandler {
|
|||||||
logger.debug("Using long SSE httpClient={} for {}}", httpClientSSETouchEvent, httpClientName);
|
logger.debug("Using long SSE httpClient={} for {}}", httpClientSSETouchEvent, httpClientName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
logger.debug("Initializing the controller (bridge)");
|
logger.debug("Initializing the controller (bridge)");
|
||||||
updateStatus(ThingStatus.UNKNOWN);
|
updateStatus(ThingStatus.UNKNOWN);
|
||||||
@ -199,6 +200,7 @@ public class NanoleafControllerHandler extends BaseBridgeHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void handleCommand(ChannelUID channelUID, Command command) {
|
public void handleCommand(ChannelUID channelUID, Command command) {
|
||||||
logger.debug("Received command {} for channel {}", command, channelUID);
|
logger.debug("Received command {} for channel {}", command, channelUID);
|
||||||
if (!ThingStatus.ONLINE.equals(getThing().getStatusInfo().getStatus())) {
|
if (!ThingStatus.ONLINE.equals(getThing().getStatusInfo().getStatus())) {
|
||||||
@ -565,7 +567,7 @@ public class NanoleafControllerHandler extends BaseBridgeHandler {
|
|||||||
|
|
||||||
private void handleTouchEvents(TouchEvents touchEvents) {
|
private void handleTouchEvents(TouchEvents touchEvents) {
|
||||||
touchEvents.getEvents().forEach((event) -> {
|
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
|
// Swipes go to the controller, taps go to the individual panel
|
||||||
if (event.getPanelId().equals(CONTROLLER_PANEL_ID)) {
|
if (event.getPanelId().equals(CONTROLLER_PANEL_ID)) {
|
||||||
logger.debug("Triggering controller {} with gesture {}.", thing.getUID(), event.getGesture());
|
logger.debug("Triggering controller {} with gesture {}.", thing.getUID(), event.getGesture());
|
||||||
@ -628,8 +630,8 @@ public class NanoleafControllerHandler extends BaseBridgeHandler {
|
|||||||
hue = min == null ? 0 : min;
|
hue = min == null ? 0 : min;
|
||||||
Integer max = colorTemperature.getMax();
|
Integer max = colorTemperature.getMax();
|
||||||
saturation = max == null ? 0 : max;
|
saturation = max == null ? 0 : max;
|
||||||
colorTempPercent = (float) ((colorTemperature.getValue() - hue) / (saturation - hue)
|
colorTempPercent = (colorTemperature.getValue() - hue) / (saturation - hue)
|
||||||
* PercentType.HUNDRED.intValue());
|
* PercentType.HUNDRED.intValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
updateState(CHANNEL_COLOR_TEMPERATURE, new PercentType(Float.toString(colorTempPercent)));
|
updateState(CHANNEL_COLOR_TEMPERATURE, new PercentType(Float.toString(colorTempPercent)));
|
||||||
@ -650,30 +652,6 @@ public class NanoleafControllerHandler extends BaseBridgeHandler {
|
|||||||
updateState(CHANNEL_RHYTHM_MODE, new DecimalType(controllerInfo.getRhythm().getRhythmMode()));
|
updateState(CHANNEL_RHYTHM_MODE, new DecimalType(controllerInfo.getRhythm().getRhythmMode()));
|
||||||
updateState(CHANNEL_RHYTHM_STATE,
|
updateState(CHANNEL_RHYTHM_STATE,
|
||||||
controllerInfo.getRhythm().getRhythmConnected() ? OnOffType.ON : OnOffType.OFF);
|
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
|
// update the color channels of each panel
|
||||||
getThing().getThings().forEach(child -> {
|
getThing().getThings().forEach(child -> {
|
||||||
@ -684,11 +662,49 @@ public class NanoleafControllerHandler extends BaseBridgeHandler {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
updateProperties();
|
||||||
|
updateConfiguration();
|
||||||
|
|
||||||
for (NanoleafControllerListener controllerListener : controllerListeners) {
|
for (NanoleafControllerListener controllerListener : controllerListeners) {
|
||||||
controllerListener.onControllerInfoFetched(getThing().getUID(), controllerInfo);
|
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 {
|
private ControllerInfo receiveControllerInfo() throws NanoleafException, NanoleafUnauthorizedException {
|
||||||
ContentResponse controllerlInfoJSON = OpenAPIUtils.sendOpenAPIRequest(OpenAPIUtils.requestBuilder(httpClient,
|
ContentResponse controllerlInfoJSON = OpenAPIUtils.sendOpenAPIRequest(OpenAPIUtils.requestBuilder(httpClient,
|
||||||
getControllerConfig(), API_GET_CONTROLLER_INFO, HttpMethod.GET));
|
getControllerConfig(), API_GET_CONTROLLER_INFO, HttpMethod.GET));
|
||||||
|
|||||||
@ -90,7 +90,6 @@ public class NanoleafPanelHandler extends BaseThingHandler {
|
|||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
logger.debug("Initializing handler for panel {}", getThing().getUID());
|
logger.debug("Initializing handler for panel {}", getThing().getUID());
|
||||||
updateStatus(ThingStatus.OFFLINE);
|
|
||||||
Bridge controller = getBridge();
|
Bridge controller = getBridge();
|
||||||
if (controller == null) {
|
if (controller == null) {
|
||||||
initializePanel(new ThingStatusInfo(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_UNINITIALIZED, ""));
|
initializePanel(new ThingStatusInfo(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_UNINITIALIZED, ""));
|
||||||
|
|||||||
@ -17,8 +17,8 @@ thing-type.config.nanoleaf.controller.authToken.description = Authorization toke
|
|||||||
thing-type.config.nanoleaf.controller.refreshInterval.label = Refresh Interval
|
thing-type.config.nanoleaf.controller.refreshInterval.label = Refresh Interval
|
||||||
thing-type.config.nanoleaf.controller.refreshInterval.description = Interval (in seconds) to refresh the controller channels status
|
thing-type.config.nanoleaf.controller.refreshInterval.description = Interval (in seconds) to refresh the controller channels status
|
||||||
thing-type.config.nanoleaf.controller.deviceType.label = Nanoleaf Device Type
|
thing-type.config.nanoleaf.controller.deviceType.label = Nanoleaf Device Type
|
||||||
thing-type.config.nanoleaf.controller.deviceType.description = Light Panels (triangles) or Canvas (squares)
|
thing-type.config.nanoleaf.controller.deviceType.description = Light Panels (older triangle models) or Canvas/Shapes (newer models as squares, triangles, hexagons, etc.)
|
||||||
thing-type.config.nanoleaf.lightpanel.id.label = ID Of The Panel
|
thing-type.config.nanoleaf.lightpanel.id.label = Panel ID
|
||||||
thing-type.config.nanoleaf.lightpanel.id.description = The ID of the panel assigned by the controller
|
thing-type.config.nanoleaf.lightpanel.id.description = The ID of the panel assigned by the controller
|
||||||
|
|
||||||
# channel types
|
# channel types
|
||||||
|
|||||||
@ -17,8 +17,8 @@ thing-type.config.nanoleaf.controller.authToken.description = Token zur Authenti
|
|||||||
thing-type.config.nanoleaf.controller.refreshInterval.label = Aktualisierungsintervall
|
thing-type.config.nanoleaf.controller.refreshInterval.label = Aktualisierungsintervall
|
||||||
thing-type.config.nanoleaf.controller.refreshInterval.description = Intervall (in Sekunden) in dem die Kanäle aktualisiert werden
|
thing-type.config.nanoleaf.controller.refreshInterval.description = Intervall (in Sekunden) in dem die Kanäle aktualisiert werden
|
||||||
thing-type.config.nanoleaf.controller.deviceType.label = Nanoleaf Gerätetyp
|
thing-type.config.nanoleaf.controller.deviceType.label = Nanoleaf Gerätetyp
|
||||||
thing-type.config.nanoleaf.controller.deviceType.description = Light Panels (Dreiecke) oder Canvas (Quadrate)
|
thing-type.config.nanoleaf.controller.deviceType.description = Light Panels (alte Dreieck-Modelle) oder Canvas/Shapes (neue Modelle als Quadrat, Dreieck, Hexagon, etc.)
|
||||||
thing-type.config.nanoleaf.lightpanel.id.label = Paneel ID
|
thing-type.config.nanoleaf.lightpanel.id.label = Panel ID
|
||||||
thing-type.config.nanoleaf.lightpanel.id.description = Vom Controller vergebene ID eines Paneels
|
thing-type.config.nanoleaf.lightpanel.id.description = Vom Controller vergebene ID eines Paneels
|
||||||
|
|
||||||
# channel types
|
# channel types
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user