/** * Creates a new custom unit simulator. * * @param unitController the unit to simulate. * @param serviceType the service type, e.g SMOKE_ALARM_STATE */ public AlarmStateSimulator(UnitController unitController, ServiceType serviceType) { super(unitController, serviceType); this.simulatedAlarmState = AlarmState.newBuilder(); this.simulatedAlarmState.setValue(AlarmState.State.NO_ALARM); this.counter = 0; }
/** * Creates a new custom unit simulator. * * @param unitController the unit to simulate. */ public HandleStateServiceSimulator(UnitController unitController) { super(unitController, ServiceType.HANDLE_STATE_SERVICE); this.simulatedHandleState = HandleState.newBuilder(); this.simulatedHandleState.setPosition(MIN_HANDLE_POSITION); }
/** * Transform a number to a brightness state by setting the number as the brightness value. * * @param value the brightness value * @return the corresponding brightness state */ public static BrightnessState transform(final Double value) { BrightnessState.Builder state = BrightnessState.newBuilder(); state.setBrightness(value); return state.build(); }
public static TemperatureState transform(final double state) throws CouldNotTransformException { return TemperatureState.newBuilder().setTemperature(state).setTemperatureDataUnit(TemperatureState.DataUnit.CELSIUS).build(); }
/** * OpenHAB receives the value for the current in milli ampere and therefore * must be transformed. * * @param value the new value for the current in mA * @return a PowerConsumptionState with the given current and a voltage of * 230V */ public static PowerConsumptionState transform(final Double value) { PowerConsumptionState.Builder state = PowerConsumptionState.newBuilder(); state.setCurrent(value / MILLITOAMPERE); state.setVoltage(DEFAULTVOLTAGE); state.setConsumption(state.getCurrent() * state.getVoltage()); return state.build(); }
/** * {@inheritDoc } * * @return {@inheritDoc } * @throws NotAvailableException {@inheritDoc } */ @Override protected BrightnessState getNextServiceState() throws NotAvailableException { return BrightnessState.newBuilder().setBrightnessDataUnit(BrightnessState.DataUnit.PERCENT).setBrightness(RANDOM.nextInt(MAX_BRIGHTNESS)).build(); } }
/** * Transform a number to a brightness state by setting the number as the brightness value. * * @param value the brightness value * @return the corresponding brightness state */ public static BlindState transform(final Double value) { BlindState.Builder state = BlindState.newBuilder(); state.setOpeningRatio(value); return state.build(); }
/** * Creates a new custom service simulator. * * @param unitController the unit to simulate. */ public BlindStateServiceSimulator(UnitController unitController) { super(unitController, ServiceType.BLIND_STATE_SERVICE); this.simulatedBlindState = BlindState.newBuilder(); this.simulatedBlindState.setMovementState(BlindState.MovementState.STOP); this.simulatedBlindState.setOpeningRatio(100); }
/** * {@inheritDoc } * * @return {@inheritDoc } * @throws NotAvailableException {@inheritDoc } */ @Override protected IlluminanceState getNextServiceState() throws NotAvailableException { return IlluminanceState.newBuilder().setIlluminanceDataUnit(IlluminanceState.DataUnit.LUX).setIlluminance(RANDOM.nextInt(MAX_ILLUMINANCE)).build(); } }
/** * Transform a number to an illuminationState by setting the number as the illuminance. * * @param value the brightness value * @return the corresponding brightness state */ public static IlluminanceState transform(final Double value) { IlluminanceState.Builder state = IlluminanceState.newBuilder(); state.setIlluminance(value); return state.build(); }
/** * Get the brightness value. * * @param brightnessState the state * @return the current brightness value */ public static Double transform(BrightnessState brightnessState) { return brightnessState.getBrightness(); } }
/** * Get the illuminance value. * * @param illuminanceState the state * @return the current illuminance */ public static Double transform(IlluminanceState illuminanceState) { return illuminanceState.getIlluminance(); } }
/** * Get the brightness value. * * @param blindState the state to transform * @return the current brightness value */ public static Double transform(BlindState blindState) { return blindState.getOpeningRatio(); } }
private synchronized void updateMotionState(final MotionStateOrBuilder motionState) throws CouldNotPerformException { // Filter rush motion predictions. if (motionState.getValue() == MotionState.State.NO_MOTION) { return; } if (motionState.getValue() == MotionState.State.MOTION) { updatePresenceState(PresenceState.newBuilder().setValue(PresenceState.State.PRESENT).setLastPresence(motionState.getLastMotion())); } }
/** * Get the current in milli ampere from a PowerConsumptionState. * * @param powerConsumptionState the state * @return the current in milli ampere */ public static Double transform(PowerConsumptionState powerConsumptionState) { return powerConsumptionState.getCurrent() * MILLITOAMPERE; } }
/** * Get the battery level between 0 and 100. * * @param batteryState the state * @return the current battery level */ public static Double transform(BatteryState batteryState) { return batteryState.getLevel(); } }
/** * Creates a new custom unit simulator. * * @param unitController the unit to simulate. */ public BatteryStateServiceSimulator(final UnitController unitController) { super(unitController, ServiceType.BATTERY_STATE_SERVICE); this.simulatedBatteryState = BatteryState.newBuilder(); this.simulatedBatteryState.setLevel(RANDOM.nextInt(MAX_BATTERY_LEVEL)); }
/** * {@inheritDoc } * * @return {@inheritDoc } * @throws NotAvailableException {@inheritDoc } */ @Override protected TemperatureState getNextServiceState() throws NotAvailableException { return TemperatureState.newBuilder().setTemperatureDataUnit(TemperatureState.DataUnit.CELSIUS).setTemperature(getSimulatedTemperature()).build(); } }