use of org.openhab.core.types.StateOption in project openhab-addons by openhab.
the class BoseSoundTouchHandler method refreshPresetChannel.
public void refreshPresetChannel() {
List<StateOption> stateOptions = presetContainer.getAllPresets().stream().map(e -> e.toStateOption()).sorted(Comparator.comparing(StateOption::getValue)).collect(Collectors.toList());
stateOptionProvider.setStateOptions(new ChannelUID(getThing().getUID(), CHANNEL_PRESET), stateOptions);
}
use of org.openhab.core.types.StateOption in project openhab-addons by openhab.
the class LxControlTest method testChannel.
void testChannel(LxControl ctrl, String itemType, String namePostFix, BigDecimal min, BigDecimal max, BigDecimal step, String format, Boolean readOnly, List<StateOption> options, Set<String> tags) {
assertNotNull(ctrl);
Channel c = getChannel(getExpectedName(ctrl.getLabel(), ctrl.getRoom().getName(), namePostFix), ctrl);
assertNotNull(c);
assertNotNull(c.getUID());
assertNotNull(c.getDescription());
assertEquals(itemType, c.getAcceptedItemType());
assertEquals(ChannelKind.STATE, c.getKind());
StateDescription d = handler.stateDescriptions.get(c.getUID());
if (readOnly != null || min != null || max != null || step != null || format != null || options != null) {
assertNotNull(d);
assertEquals(min, d.getMinimum());
assertEquals(max, d.getMaximum());
assertEquals(step, d.getStep());
assertEquals(format, d.getPattern());
assertEquals(readOnly, d.isReadOnly());
List<StateOption> opts = d.getOptions();
if (options == null) {
assertTrue(opts.isEmpty());
} else {
assertNotNull(opts);
assertEquals(options.size(), opts.size());
options.forEach(o -> {
String label = o.getLabel();
long num = opts.stream().filter(f -> label != null && label.equals(f.getLabel()) && o.getValue().equals(f.getValue())).collect(Collectors.counting());
assertEquals(1, num);
});
}
} else {
assertNull(d);
}
if (tags != null) {
assertThat(c.getDefaultTags(), hasItems(tags.toArray(new String[0])));
} else {
assertThat(c.getDefaultTags(), empty());
}
}
use of org.openhab.core.types.StateOption in project openhab-addons by openhab.
the class LxControlLightControllerV2Test method loadMoodList1.
private void loadMoodList1() {
String list = loadMoodList("MoodList1.json");
changeLoxoneState("moodlist", list);
List<StateOption> options = new ArrayList<>();
options.add(new StateOption("2", "Side Lights"));
options.add(new StateOption("3", "Play Lights"));
options.add(new StateOption("4", "Study Only"));
options.add(new StateOption("5", "Low Lights"));
options.add(new StateOption("777", "Bright"));
options.add(new StateOption("778", "Off"));
testMoodList(options, 778);
}
use of org.openhab.core.types.StateOption in project openhab-addons by openhab.
the class LxControlRadioTest2 method testChannels.
@Override
@Test
public void testChannels() {
List<StateOption> opts = new ArrayList<>();
for (Integer i = 1; i <= 6; i++) {
opts.add(new StateOption(i.toString(), "Sprinkler " + i.toString()));
}
opts.add(new StateOption("0", "All Off"));
testChannel("Number", null, BigDecimal.ZERO, new BigDecimal(16), BigDecimal.ONE, null, false, opts);
}
use of org.openhab.core.types.StateOption in project openhab-addons by openhab.
the class LxControlLightControllerV2Test method testMoodList.
private void testMoodList(List<StateOption> options, Integer offId) {
assertEquals(options.size(), handler.extraControls.size());
if (options.isEmpty()) {
return;
}
Integer min = null;
Integer max = null;
for (StateOption o : options) {
testMood(o.getLabel(), o.getValue(), o.getValue().equals(offId.toString()));
Integer id = Integer.parseInt(o.getValue());
assertNotNull(id);
if (min == null || id < min) {
min = id;
}
if (max == null || id > max) {
max = id;
}
}
assertNotNull(min);
assertNotNull(max);
testChannel("Number", null, new BigDecimal(min), new BigDecimal(max), BigDecimal.ONE, null, false, options, Collections.singleton("Scene"));
}
Aggregations