private void switchMultimediaOff() { try { List<? extends UnitGroupRemote> unitsByLabel = Units.getUnitsByLabel(locationRemote.getLabel().concat("MultimediaGroup"), true, Units.UNITGROUP); if (!unitsByLabel.isEmpty()) { UnitGroupRemote multimediaGroup = unitsByLabel.get(0); ActionDescriptionType.ActionDescription.Builder actionDescriptionBuilder = getNewActionDescription(ActionAuthorityType.ActionAuthority.getDefaultInstance(), ResourceAllocationType.ResourceAllocation.Initiator.SYSTEM, 1000 * 30, ResourceAllocationType.ResourceAllocation.Policy.FIRST, ResourceAllocationType.ResourceAllocation.Priority.NORMAL, multimediaGroup, PowerState.newBuilder().setValue(PowerState.State.OFF).build(), UnitType.UNKNOWN, ServiceTemplateType.ServiceTemplate.ServiceType.POWER_STATE_SERVICE, MultiResourceAllocationStrategy.Strategy.AT_LEAST_ONE); actionRescheduleHelper.addRescheduleAction(multimediaGroup.applyAction(actionDescriptionBuilder.build()).get().toBuilder()); } } catch (NotAvailableException ex) { logger.info("MultimediaGroup not available."); } catch (InterruptedException ex) { logger.error("Could not get MultimediaGroup!"); } catch (CouldNotPerformException ex) { logger.error("Could not set Powerstate of MultimediaGroup."); } catch (ExecutionException ex) { logger.error("Could not set Powerstate of MultimediaGroup!"); } } }
ResourceAllocationType.ResourceAllocation.Priority.NORMAL, currentLocation, PowerState.newBuilder().setValue(PowerState.State.ON).build(), UnitType.LIGHT, ServiceTemplateType.ServiceTemplate.ServiceType.POWER_STATE_SERVICE, ResourceAllocationType.ResourceAllocation.Priority.NORMAL, currentLocation, PowerState.newBuilder().setValue(PowerState.State.OFF).build(), UnitType.LIGHT, ServiceTemplateType.ServiceTemplate.ServiceType.POWER_STATE_SERVICE,
public static PowerState transform(OnOffHolderType.OnOffHolder.OnOff onOffType) throws CouldNotTransformException { switch (onOffType) { case OFF: return PowerState.newBuilder().setValue(PowerState.State.OFF).build(); case ON: return PowerState.newBuilder().setValue(PowerState.State.ON).build(); default: throw new CouldNotTransformException("Could not transform " + OnOffHolderType.OnOffHolder.OnOff.class.getName() + "! " + OnOffHolderType.OnOffHolder.OnOff.class.getSimpleName() + "[" + onOffType.name() + "] is unknown!"); } }
ResourceAllocationType.ResourceAllocation.Priority.NORMAL, ambientLightGroup, PowerState.newBuilder().setValue(PowerState.State.OFF).build(), UnitType.LIGHT, ServiceTemplateType.ServiceTemplate.ServiceType.POWER_STATE_SERVICE, ResourceAllocationType.ResourceAllocation.Priority.NORMAL, locationRemote, PowerState.newBuilder().setValue(PowerState.State.OFF).build(), UnitType.LIGHT, ServiceTemplateType.ServiceTemplate.ServiceType.POWER_STATE_SERVICE,
serviceRemote.setPowerState(PowerState.newBuilder().setValue(newState).build()); } catch (CouldNotPerformException ex) { throw new CouldNotPerformException("Could not switch power state.", ex);
ResourceAllocationType.ResourceAllocation.Priority.EMERGENCY, locationRemote, PowerState.newBuilder().setValue(PowerState.State.ON).build(), UnitType.LIGHT, ServiceTemplateType.ServiceTemplate.ServiceType.POWER_STATE_SERVICE,
private void switchlightsOff() { try { ActionDescriptionType.ActionDescription.Builder actionDescriptionBuilder = getNewActionDescription(ActionAuthorityType.ActionAuthority.getDefaultInstance(), ResourceAllocationType.ResourceAllocation.Initiator.SYSTEM, 1000 * 30, ResourceAllocationType.ResourceAllocation.Policy.FIRST, ResourceAllocationType.ResourceAllocation.Priority.NORMAL, locationRemote, PowerState.newBuilder().setValue(PowerState.State.OFF).build(), UnitType.LIGHT, ServiceTemplateType.ServiceTemplate.ServiceType.POWER_STATE_SERVICE, MultiResourceAllocationStrategy.Strategy.AT_LEAST_ONE); actionRescheduleHelper.startActionRescheduleing(locationRemote.applyAction(actionDescriptionBuilder.build()).get().toBuilder()); } catch (CouldNotPerformException | InterruptedException | ExecutionException ex) { logger.error("Could not switch on Lights.", ex); } }
private void switchlightsOn() { try { ActionDescription.Builder actionDescriptionBuilder = getNewActionDescription(ActionAuthority.getDefaultInstance(), ResourceAllocation.Initiator.SYSTEM, 1000 * 30, ResourceAllocation.Policy.FIRST, ResourceAllocation.Priority.NORMAL, locationRemote, PowerState.newBuilder().setValue(PowerState.State.ON).build(), UnitType.LIGHT, ServiceTemplateType.ServiceTemplate.ServiceType.POWER_STATE_SERVICE, MultiResourceAllocationStrategy.Strategy.AT_LEAST_ONE); actionRescheduleHelper.startActionRescheduleing(locationRemote.applyAction(actionDescriptionBuilder.build()).get().toBuilder()); } catch (CouldNotPerformException | InterruptedException | ExecutionException ex) { logger.error("Could not switch on Lights.", ex); } } }
@Override public PowerState getPowerState(final UnitType unitType) throws NotAvailableException { PowerState.State powerStateValue = PowerState.State.OFF; long timestamp = 0; for (PowerStateOperationService service : getServices(unitType)) { if (!((UnitRemote) service).isDataAvailable()) { continue; } if (service.getPowerState().getValue() == PowerState.State.ON) { powerStateValue = PowerState.State.ON; } timestamp = Math.max(timestamp, service.getPowerState().getTimestamp().getTime()); } return TimestampProcessor.updateTimestamp(timestamp, PowerState.newBuilder().setValue(powerStateValue), TimeUnit.MICROSECONDS, logger).build(); }
default public Future<ActionFuture> setPowerState(final PowerState.State powerState, final UnitType unitType) throws CouldNotPerformException { return setPowerState(PowerState.newBuilder().setValue(powerState).build(), unitType); }
@Override default Future<ActionFuture> setPowerState(final PowerState.State state, final UnitType unitType) throws CouldNotPerformException { return setPowerState(PowerState.newBuilder().setValue(state).build(), unitType); }
@Override default Future<ActionFuture> setPowerState(final PowerState.State state) throws CouldNotPerformException { return setPowerState(PowerState.newBuilder().setValue(state).build()); }
public default Future<ActionFuture> setPowerState(final PowerState.State powerState) throws CouldNotPerformException { return setPowerState(PowerState.newBuilder().setValue(powerState).build()); } }