use of org.eclipse.smarthome.core.library.types.RawType in project smarthome by eclipse.
the class ZonePlayerHandler method updateAlbumArtChannel.
private void updateAlbumArtChannel(boolean allGroup) {
String url = getAlbumArtUrl();
if (url != null) {
// We download the cover art in a different thread to not delay the other operations
scheduler.submit(() -> {
RawType image = HttpUtil.downloadImage(url, true, 500000);
updateChannel(CURRENTALBUMART, image != null ? image : UnDefType.UNDEF, allGroup);
});
} else {
updateChannel(CURRENTALBUMART, UnDefType.UNDEF, allGroup);
}
}
use of org.eclipse.smarthome.core.library.types.RawType in project smarthome by eclipse.
the class GroupItemTest method assertThatGroupItemChangesDoNotAffectTheGroupStatusIfnoFunctionOrBaseItemAreDefined.
@SuppressWarnings("deprecation")
@Test
public void assertThatGroupItemChangesDoNotAffectTheGroupStatusIfnoFunctionOrBaseItemAreDefined() throws InterruptedException {
events.clear();
GroupItem groupItem = new GroupItem("root");
TestItem member = new TestItem("member1");
groupItem.addMember(member);
groupItem.setEventPublisher(publisher);
State oldGroupState = groupItem.getState();
// State changes -> NO change event should be fired
member.setState(new RawType());
// wait to see that the event doesn't fire
Thread.sleep(WAIT_EVENT_TO_BE_HANDLED);
assertThat(events.size(), is(0));
assertTrue(groupItem.getState().equals(oldGroupState));
}
use of org.eclipse.smarthome.core.library.types.RawType in project smarthome by eclipse.
the class ImageItemTest method testRawType.
@Test
public void testRawType() {
ImageItem item = new ImageItem("test");
State state = new RawType(new byte[0], "application/octet-stream");
item.setState(state);
assertEquals(state, item.getState());
}
use of org.eclipse.smarthome.core.library.types.RawType in project smarthome by eclipse.
the class StateUtil method getAllStates.
public static List<State> getAllStates() {
LinkedList<State> states = new LinkedList<>();
DateTimeType dateTime = new DateTimeType();
states.add(dateTime);
DecimalType decimal = new DecimalType(23);
states.add(decimal);
PercentType percent = new PercentType(50);
states.add(percent);
HSBType hsb = new HSBType("50,75,42");
states.add(hsb);
states.add(OnOffType.ON);
states.add(OnOffType.OFF);
states.add(OpenClosedType.OPEN);
states.add(OpenClosedType.CLOSED);
states.add(PlayPauseType.PLAY);
states.add(PlayPauseType.PAUSE);
PointType point = new PointType("42.23,23.5");
states.add(point);
RawType raw = new RawType(new byte[0], "application/octet-stream");
states.add(raw);
states.add(RewindFastforwardType.REWIND);
states.add(RewindFastforwardType.FASTFORWARD);
StringListType stringList = new StringListType(new String[] { "foo", "bar" });
states.add(stringList);
StringType string = new StringType("foo");
states.add(string);
states.add(UnDefType.NULL);
states.add(UnDefType.UNDEF);
states.add(UpDownType.UP);
states.add(UpDownType.DOWN);
QuantityType<Temperature> quantityType = new QuantityType<Temperature>("12 °C");
states.add(quantityType);
return states;
}
use of org.eclipse.smarthome.core.library.types.RawType in project smarthome by eclipse.
the class ImageRenderer method renderWidget.
@Override
public EList<Widget> renderWidget(Widget w, StringBuilder sb) throws RenderException {
Image image = (Image) w;
String snippet = (image.getChildren().size() > 0) ? getSnippet("image_link") : getSnippet("image");
if (image.getRefresh() > 0) {
snippet = StringUtils.replace(snippet, "%refresh%", "id=\"%id%\" data-timeout=\"" + image.getRefresh() + "\" onload=\"startReloadImage('%url%', '%id%')\"");
} else {
snippet = StringUtils.replace(snippet, "%refresh%", "");
}
String widgetId = itemUIRegistry.getWidgetId(w);
snippet = StringUtils.replace(snippet, "%id%", widgetId);
String sitemap = null;
if (w.eResource() != null) {
sitemap = w.eResource().getURI().path();
}
boolean validUrl = false;
if (image.getUrl() != null && !image.getUrl().isEmpty()) {
try {
URI.create(image.getUrl());
validUrl = true;
} catch (IllegalArgumentException ex) {
}
}
String proxiedUrl = "../proxy?sitemap=" + sitemap + "&widgetId=" + widgetId;
State state = itemUIRegistry.getState(w);
String url;
if (state instanceof RawType) {
url = state.toFullString();
} else if ((sitemap != null) && ((state instanceof StringType) || validUrl)) {
url = proxiedUrl + "&t=" + (new Date()).getTime();
} else {
url = "images/none.png";
}
snippet = StringUtils.replace(snippet, "%url%", url);
sb.append(snippet);
return null;
}
Aggregations