Search in sources :

Example 1 with Adjustment

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);
    }
}
Also used : Adjustment(org.openhab.binding.hyperion.internal.protocol.ng.Adjustment) Hyperion(org.openhab.binding.hyperion.internal.protocol.ng.Hyperion) Priority(org.openhab.binding.hyperion.internal.protocol.ng.Priority) Effect(org.openhab.binding.hyperion.internal.protocol.v1.Effect) Component(org.openhab.binding.hyperion.internal.protocol.ng.Component) NgInfo(org.openhab.binding.hyperion.internal.protocol.ng.NgInfo)

Example 2 with Adjustment

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);
    }
}
Also used : Color(java.awt.Color) CommandUnsuccessfulException(org.openhab.binding.hyperion.internal.protocol.CommandUnsuccessfulException) ScheduledFuture(java.util.concurrent.ScheduledFuture) StringType(org.openhab.core.library.types.StringType) LoggerFactory(org.slf4j.LoggerFactory) OnOffType(org.openhab.core.library.types.OnOffType) ComponentStateCommand(org.openhab.binding.hyperion.internal.protocol.ng.ComponentStateCommand) BigDecimal(java.math.BigDecimal) Configuration(org.openhab.core.config.core.Configuration) Gson(com.google.gson.Gson) Priority(org.openhab.binding.hyperion.internal.protocol.ng.Priority) AdjustmentCommand(org.openhab.binding.hyperion.internal.protocol.ng.AdjustmentCommand) Effect(org.openhab.binding.hyperion.internal.protocol.v1.Effect) UnDefType(org.openhab.core.types.UnDefType) BaseThingHandler(org.openhab.core.thing.binding.BaseThingHandler) StateOption(org.openhab.core.types.StateOption) HyperionStateDescriptionProvider(org.openhab.binding.hyperion.internal.HyperionStateDescriptionProvider) JsonTcpConnection(org.openhab.binding.hyperion.internal.connection.JsonTcpConnection) HyperionCommand(org.openhab.binding.hyperion.internal.protocol.HyperionCommand) List(java.util.List) ServerInfoCommand(org.openhab.binding.hyperion.internal.protocol.ServerInfoCommand) ColorCommand(org.openhab.binding.hyperion.internal.protocol.ColorCommand) Optional(java.util.Optional) HSBType(org.openhab.core.library.types.HSBType) Value(org.openhab.binding.hyperion.internal.protocol.ng.Value) Component(org.openhab.binding.hyperion.internal.protocol.ng.Component) ClearCommand(org.openhab.binding.hyperion.internal.protocol.v1.ClearCommand) JsonParseException(com.google.gson.JsonParseException) ComponentState(org.openhab.binding.hyperion.internal.protocol.ng.ComponentState) Adjustment(org.openhab.binding.hyperion.internal.protocol.ng.Adjustment) HyperionBindingConstants(org.openhab.binding.hyperion.internal.HyperionBindingConstants) ArrayList(java.util.ArrayList) Thing(org.openhab.core.thing.Thing) EffectCommand(org.openhab.binding.hyperion.internal.protocol.EffectCommand) ChannelUID(org.openhab.core.thing.ChannelUID) ThingStatusInfo(org.openhab.core.thing.ThingStatusInfo) NgResponse(org.openhab.binding.hyperion.internal.protocol.ng.NgResponse) NgInfo(org.openhab.binding.hyperion.internal.protocol.ng.NgInfo) ThingStatus(org.openhab.core.thing.ThingStatus) Command(org.openhab.core.types.Command) Logger(org.slf4j.Logger) RefreshType(org.openhab.core.types.RefreshType) IOException(java.io.IOException) ThingStatusDetail(org.openhab.core.thing.ThingStatusDetail) UnknownHostException(java.net.UnknownHostException) ClearAllCommand(org.openhab.binding.hyperion.internal.protocol.v1.ClearAllCommand) TimeUnit(java.util.concurrent.TimeUnit) PercentType(org.openhab.core.library.types.PercentType) Hyperion(org.openhab.binding.hyperion.internal.protocol.ng.Hyperion) Adjustment(org.openhab.binding.hyperion.internal.protocol.ng.Adjustment) PercentType(org.openhab.core.library.types.PercentType)

Example 3 with Adjustment

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);
    }
}
Also used : Adjustment(org.openhab.binding.hyperion.internal.protocol.ng.Adjustment) AdjustmentCommand(org.openhab.binding.hyperion.internal.protocol.ng.AdjustmentCommand) PercentType(org.openhab.core.library.types.PercentType)

Aggregations

Adjustment (org.openhab.binding.hyperion.internal.protocol.ng.Adjustment)3 AdjustmentCommand (org.openhab.binding.hyperion.internal.protocol.ng.AdjustmentCommand)2 Component (org.openhab.binding.hyperion.internal.protocol.ng.Component)2 Hyperion (org.openhab.binding.hyperion.internal.protocol.ng.Hyperion)2 NgInfo (org.openhab.binding.hyperion.internal.protocol.ng.NgInfo)2 Priority (org.openhab.binding.hyperion.internal.protocol.ng.Priority)2 Effect (org.openhab.binding.hyperion.internal.protocol.v1.Effect)2 PercentType (org.openhab.core.library.types.PercentType)2 Gson (com.google.gson.Gson)1 JsonParseException (com.google.gson.JsonParseException)1 Color (java.awt.Color)1 IOException (java.io.IOException)1 BigDecimal (java.math.BigDecimal)1 UnknownHostException (java.net.UnknownHostException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Optional (java.util.Optional)1 ScheduledFuture (java.util.concurrent.ScheduledFuture)1 TimeUnit (java.util.concurrent.TimeUnit)1 HyperionBindingConstants (org.openhab.binding.hyperion.internal.HyperionBindingConstants)1