use of org.openhab.core.types.StateOption in project openhab-addons by openhab.
the class UpnpServerHandler method updateTitleSelection.
private void updateTitleSelection(List<UpnpEntry> titleList) {
// Optionally, filter only items that can be played on the renderer
logger.debug("Filtering content on server {}: {}", thing.getLabel(), config.filter);
List<UpnpEntry> resultList = config.filter ? filterEntries(titleList, true) : titleList;
List<StateOption> stateOptionList = new ArrayList<>();
// Add a directory up selector if not in the directory root
if ((!resultList.isEmpty() && !(DIRECTORY_ROOT.equals(resultList.get(0).getParentId()))) || (resultList.isEmpty() && !DIRECTORY_ROOT.equals(currentEntry.getId()))) {
StateOption stateOption = new StateOption(UP, UP);
stateOptionList.add(stateOption);
logger.debug("UP added to selection list on server {}", thing.getLabel());
}
synchronized (entries) {
// always only keep the current selection in the entry map to keep memory usage down
entries.clear();
resultList.forEach((value) -> {
StateOption stateOption = new StateOption(value.getId(), value.getTitle());
stateOptionList.add(stateOption);
logger.trace("{} added to selection list on server {}", value.getId(), thing.getLabel());
// back up
if (value.isContainer()) {
parentMap.put(value.getId(), value);
}
entries.add(value);
});
}
logger.debug("{} entries added to selection list on server {}", stateOptionList.size(), thing.getLabel());
updateStateDescription(currentSelectionChannelUID, stateOptionList);
updateState(BROWSE, StringType.valueOf(currentEntry.getId()));
updateState(CURRENTTITLE, StringType.valueOf(currentEntry.getTitle()));
serveMedia();
}
use of org.openhab.core.types.StateOption in project openhab-addons by openhab.
the class UpnpServerHandler method addRendererOption.
/**
* Add a renderer to the renderer channel state option list.
* This method is called from the {@link UpnpControlHandlerFactory} class when creating a renderer handler.
*
* @param key
*/
public void addRendererOption(String key) {
synchronized (rendererStateOptionList) {
UpnpRendererHandler handler = upnpRenderers.get(key);
if (handler != null) {
rendererStateOptionList.add(new StateOption(key, handler.getThing().getLabel()));
}
}
updateStateDescription(rendererChannelUID, rendererStateOptionList);
logger.debug("Renderer option {} added to {}", key, thing.getLabel());
}
use of org.openhab.core.types.StateOption in project openhab-addons by openhab.
the class UpnpServerHandler method initJob.
@Override
protected void initJob() {
synchronized (jobLock) {
if (!upnpIOService.isRegistered(this)) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, "UPnP device with UDN " + getUDN() + " not yet registered");
return;
}
if (!ThingStatus.ONLINE.equals(thing.getStatus())) {
rendererStateOptionList = Collections.synchronizedList(new ArrayList<>());
synchronized (rendererStateOptionList) {
upnpRenderers.forEach((key, value) -> {
StateOption stateOption = new StateOption(key, value.getThing().getLabel());
rendererStateOptionList.add(stateOption);
});
}
updateStateDescription(rendererChannelUID, rendererStateOptionList);
getProtocolInfo();
browse(currentEntry.getId(), "BrowseDirectChildren", "*", "0", "0", config.sortCriteria);
playlistsListChanged();
updateStatus(ThingStatus.ONLINE);
}
if (!upnpSubscribed) {
addSubscriptions();
}
}
}
use of org.openhab.core.types.StateOption in project openhab-addons by openhab.
the class ZmBridgeHandler method getMonitors.
@SuppressWarnings("null")
private synchronized List<Monitor> getMonitors() {
List<Monitor> monitorList = new ArrayList<>();
if (!zmAuth.isAuthorized()) {
return monitorList;
}
try {
String response = executeGet(buildUrl("/api/monitors.json"));
MonitorsDTO monitorsDTO = GSON.fromJson(response, MonitorsDTO.class);
if (monitorsDTO != null && monitorsDTO.monitorItems != null) {
List<StateOption> options = new ArrayList<>();
for (MonitorItemDTO monitorItemDTO : monitorsDTO.monitorItems) {
MonitorDTO monitorDTO = monitorItemDTO.monitor;
MonitorStatusDTO monitorStatusDTO = monitorItemDTO.monitorStatus;
if (monitorDTO != null && monitorStatusDTO != null) {
Monitor monitor = new Monitor(monitorDTO.id, monitorDTO.name, monitorDTO.function, monitorDTO.enabled, monitorStatusDTO.status);
extractEventCounts(monitor, monitorItemDTO);
monitor.setImageUrl(buildStreamUrl(monitorDTO.id, STREAM_IMAGE));
monitor.setVideoUrl(buildStreamUrl(monitorDTO.id, STREAM_VIDEO));
monitorList.add(monitor);
options.add(new StateOption(monitorDTO.id, "Monitor " + monitorDTO.id));
}
}
// Update state options
stateDescriptionProvider.setStateOptions(new ChannelUID(getThing().getUID(), CHANNEL_IMAGE_MONITOR_ID), options);
stateDescriptionProvider.setStateOptions(new ChannelUID(getThing().getUID(), CHANNEL_VIDEO_MONITOR_ID), options);
// Only update alarm and event info for monitors whose handlers are initialized
Set<String> ids = monitorHandlers.keySet();
for (Monitor m : monitorList) {
if (ids.contains(m.getId())) {
m.setState(getState(m.getId()));
m.setLastEvent(getLastEvent(m.getId()));
}
}
}
} catch (JsonSyntaxException e) {
logger.debug("Bridge: JsonSyntaxException: {}", e.getMessage(), e);
}
return monitorList;
}
use of org.openhab.core.types.StateOption in project openhab-addons by openhab.
the class OppoHandler method buildOptionDropdowns.
private void buildOptionDropdowns(int model) {
if (model == MODEL83 || model == MODEL103 || model == MODEL105) {
hdmiModeOptions.add(new StateOption("AUTO", "Auto"));
hdmiModeOptions.add(new StateOption("SRC", "Source Direct"));
if (!(model == MODEL83)) {
hdmiModeOptions.add(new StateOption("4K2K", "4K*2K"));
}
hdmiModeOptions.add(new StateOption("1080P", "1080P"));
hdmiModeOptions.add(new StateOption("1080I", "1080I"));
hdmiModeOptions.add(new StateOption("720P", "720P"));
hdmiModeOptions.add(new StateOption("SDP", "480P"));
hdmiModeOptions.add(new StateOption("SDI", "480I"));
}
if (model == MODEL103 || model == MODEL105) {
inputSourceOptions.add(new StateOption("0", "Blu-Ray Player"));
inputSourceOptions.add(new StateOption("1", "HDMI/MHL IN-Front"));
inputSourceOptions.add(new StateOption("2", "HDMI IN-Back"));
inputSourceOptions.add(new StateOption("3", "ARC"));
if (model == MODEL105) {
inputSourceOptions.add(new StateOption("4", "Optical In"));
inputSourceOptions.add(new StateOption("5", "Coaxial In"));
inputSourceOptions.add(new StateOption("6", "USB Audio In"));
}
}
if (model == MODEL203 || model == MODEL205) {
hdmiModeOptions.add(new StateOption("AUTO", "Auto"));
hdmiModeOptions.add(new StateOption("SRC", "Source Direct"));
hdmiModeOptions.add(new StateOption("UHD_AUTO", "UHD Auto"));
hdmiModeOptions.add(new StateOption("UHD24", "UHD24"));
hdmiModeOptions.add(new StateOption("UHD50", "UHD50"));
hdmiModeOptions.add(new StateOption("UHD60", "UHD60"));
hdmiModeOptions.add(new StateOption("1080P_AUTO", "1080P Auto"));
hdmiModeOptions.add(new StateOption("1080P24", "1080P24"));
hdmiModeOptions.add(new StateOption("1080P50", "1080P50"));
hdmiModeOptions.add(new StateOption("1080P60", "1080P60"));
hdmiModeOptions.add(new StateOption("1080I50", "1080I50"));
hdmiModeOptions.add(new StateOption("1080I60", "1080I60"));
hdmiModeOptions.add(new StateOption("720P50", "720P50"));
hdmiModeOptions.add(new StateOption("720P60", "720P60"));
hdmiModeOptions.add(new StateOption("576P", "567P"));
hdmiModeOptions.add(new StateOption("576I", "567I"));
hdmiModeOptions.add(new StateOption("480P", "480P"));
hdmiModeOptions.add(new StateOption("480I", "480I"));
inputSourceOptions.add(new StateOption("0", "Blu-Ray Player"));
inputSourceOptions.add(new StateOption("1", "HDMI IN"));
inputSourceOptions.add(new StateOption("2", "ARC"));
if (model == MODEL205) {
inputSourceOptions.add(new StateOption("3", "Optical In"));
inputSourceOptions.add(new StateOption("4", "Coaxial In"));
inputSourceOptions.add(new StateOption("5", "USB Audio In"));
}
}
}
Aggregations