use of org.openhab.binding.hyperion.internal.protocol.ng.Adjustment in project openhab-addons by openhab.
the class HyperionNgHandler method handleServerInfoResponse.
protected void handleServerInfoResponse(NgResponse response) {
NgInfo info = response.getInfo();
if (info != null) {
// update Hyperion, older API compatibility
Hyperion hyperion = info.getHyperion();
if (hyperion != null) {
updateHyperion(hyperion);
}
// populate the effect states
List<Effect> effects = info.getEffects();
populateEffects(effects);
// update adjustments
List<Adjustment> adjustments = info.getAdjustment();
updateAdjustments(adjustments);
// update components
List<Component> components = info.getComponents();
updateComponents(components);
// update colors/effects
List<Priority> priorities = info.getPriorities();
updatePriorities(priorities);
}
}
use of org.openhab.binding.hyperion.internal.protocol.ng.Adjustment in project openhab-addons by openhab.
the class HyperionNgHandler method updateAdjustments.
private void updateAdjustments(List<Adjustment> adjustments) {
Optional<Adjustment> defaultAdjustment = // convert list to stream
adjustments.stream().filter(adjustment -> DEFAULT_ADJUSTMENT.equals(adjustment.getId())).findFirst();
if (defaultAdjustment.isPresent()) {
int brightness = defaultAdjustment.get().getBrightness();
PercentType brightnessState = new PercentType(brightness);
updateState(CHANNEL_BRIGHTNESS, brightnessState);
} else {
updateState(CHANNEL_BRIGHTNESS, UnDefType.NULL);
}
}
use of org.openhab.binding.hyperion.internal.protocol.ng.Adjustment in project openhab-addons by openhab.
the class HyperionNgHandler method handleBrightness.
private void handleBrightness(Command command) throws IOException, CommandUnsuccessfulException {
if (command instanceof PercentType) {
PercentType percent = (PercentType) command;
int brightnessValue = percent.intValue();
Adjustment adjustment = new Adjustment();
adjustment.setBrightness(brightnessValue);
AdjustmentCommand brightnessCommand = new AdjustmentCommand(adjustment);
sendCommand(brightnessCommand);
} else {
logger.debug("Channel {} unable to process command {}", CHANNEL_BRIGHTNESS, command);
}
}
Aggregations