use of org.openhab.core.library.types.PercentType in project openhab1-addons by openhab.
the class DenonConnector method updateMainZone.
private void updateMainZone() {
String url = statusUrl + URL_ZONE_MAIN;
logger.trace("Refreshing URL: {}", url);
ZoneStatus mainZone = getDocument(url, ZoneStatus.class);
if (mainZone != null) {
stateCache.put(DenonProperty.INPUT.getCode(), new StringType(mainZone.getInputFuncSelect().getValue()));
stateCache.put("SI" + mainZone.getInputFuncSelect().getValue(), OnOffType.ON);
stateCache.put(DenonProperty.MASTER_VOLUME.getCode(), new PercentType(mainZone.getMasterVolume().getValue()));
stateCache.put(DenonProperty.POWER_MAINZONE.getCode(), mainZone.getPower().getValue() ? OnOffType.ON : OnOffType.OFF);
stateCache.put(DenonProperty.MUTE.getCode(), mainZone.getMute().getValue() ? OnOffType.ON : OnOffType.OFF);
if (mainZone.getSurrMode() == null) {
logger.debug("Unable to get the SURROUND_MODE. MainZone update may not be correct.");
} else {
stateCache.put(DenonProperty.SURROUND_MODE.getCode(), new StringType(mainZone.getSurrMode().getValue()));
}
}
}
use of org.openhab.core.library.types.PercentType in project openhab1-addons by openhab.
the class DiyOnXBeeBinding method changeColorBrightness.
private String changeColorBrightness(final HSBType hsbType, IncreaseDecreaseType increaseDecrease) {
final PercentType brightness = hsbType.getBrightness();
final PercentType newBrightness = changeBrightness(increaseDecrease, brightness);
final HSBType newHSB = new HSBType(hsbType.getHue(), hsbType.getSaturation(), newBrightness);
return makeRGB(newHSB.toColor());
}
use of org.openhab.core.library.types.PercentType in project openhab1-addons by openhab.
the class DmxColorItem method processCommand.
/**
* {@inheritDoc}
*/
@Override
public void processCommand(DmxService service, Command command) {
// process HSB command
if (command instanceof HSBType) {
HSBType hsbValue = (HSBType) command;
setHSBValue(service, hsbValue);
return;
}
// process increase/decrease
if (command instanceof IncreaseDecreaseType && !isRedefinedByCustomCommand(command) && !service.hasChannelActions(channels[0])) {
// rather than doing a linear fade on all channels, we fade only the
// V part of HSV to maintain the color during the fade
HSBType hsb = hsbState;
int brightness = 0;
IncreaseDecreaseType t = (IncreaseDecreaseType) command;
if (IncreaseDecreaseType.INCREASE.equals(t)) {
if (hsb == null) {
hsb = new HSBType(Color.WHITE);
}
for (int ch : channels) {
service.enableChannel(ch);
}
brightness = hsb.getBrightness().intValue();
brightness += BRIGHTNESS_STEP_SIZE;
if (brightness > 100) {
brightness = 100;
}
} else {
if (hsb == null) {
hsb = new HSBType(Color.BLACK);
}
brightness = hsb.getBrightness().intValue();
brightness -= BRIGHTNESS_STEP_SIZE;
if (brightness <= 0) {
brightness = 0;
}
}
HSBType newHsb = new HSBType(hsb.getHue(), hsb.getSaturation(), new PercentType(brightness));
setHSBValue(service, newHsb);
return;
}
// process percent command
if (command instanceof PercentType && !isRedefinedByCustomCommand(command) && !service.hasChannelActions(channels[0])) {
PercentType t = (PercentType) command;
HSBType hsb = hsbState;
if (hsb == null) {
hsb = new HSBType(Color.WHITE);
}
HSBType newHsb = new HSBType(hsb.getHue(), hsb.getSaturation(), t);
setHSBValue(service, newHsb);
return;
}
// process on/off, increase/decrease, percent type
super.processCommand(service, command);
}
use of org.openhab.core.library.types.PercentType in project openhab1-addons by openhab.
the class DmxDimmerItem method processCommand.
/**
* {@inheritDoc}
*/
@Override
public void processCommand(DmxService service, Command command) {
// process increase/decrease
if (command instanceof IncreaseDecreaseType && !isRedefinedByCustomCommand(command)) {
IncreaseDecreaseType t = (IncreaseDecreaseType) command;
if (IncreaseDecreaseType.INCREASE.equals(t)) {
for (int channelId : channels) {
service.enableChannel(channelId);
service.increaseChannel(channelId, DIMMER_STEP_SIZE);
if (service.getChannelValue(channelId) == 0) {
service.setChannelValue(channelId, DmxChannel.DMX_MAX_VALUE);
}
}
} else {
for (int channelId : channels) {
service.decreaseChannel(channelId, DIMMER_STEP_SIZE);
}
}
return;
}
// process percent command
if (command instanceof PercentType && !isRedefinedByCustomCommand(command)) {
for (int channelId : channels) {
service.setChannelValue(channelId, DmxChannel.DMX_MAX_VALUE);
service.setChannelValue(channelId, (PercentType) command);
}
return;
}
// process switch command
super.processCommand(service, command);
}
use of org.openhab.core.library.types.PercentType in project openhab1-addons by openhab.
the class DmxColorItemTest method canBeSetWithPercentType.
@Override
@Test
public void canBeSetWithPercentType() throws BindingConfigParseException {
DmxItem item = getValidInstance();
DmxService service = Mockito.mock(DmxService.class);
item.processCommand(service, new PercentType(50));
Mockito.verify(service).setChannelValue(3, 129);
Mockito.verify(service).setChannelValue(4, 129);
Mockito.verify(service).setChannelValue(5, 129);
}
Aggregations