use of org.eclipse.smarthome.core.thing.Thing in project smarthome by eclipse.
the class AutomaticInboxProcessor method receiveTypedEvent.
@Override
public void receiveTypedEvent(ThingStatusInfoChangedEvent event) {
if (autoIgnore) {
Thing thing = thingRegistry.get(event.getThingUID());
ThingStatus thingStatus = event.getStatusInfo().getStatus();
autoIgnore(thing, thingStatus);
}
}
use of org.eclipse.smarthome.core.thing.Thing in project smarthome by eclipse.
the class PersistentInboxTest method testConfigUpdateNormalization_withConfigDescription.
@Test
public void testConfigUpdateNormalization_withConfigDescription() throws Exception {
Map<String, Object> props = new HashMap<>();
props.put("foo", "1");
Configuration config = new Configuration(props);
Thing thing = ThingBuilder.create(THING_TYPE_UID, THING_UID).withConfiguration(config).build();
configureConfigDescriptionRegistryMock("foo", Type.TEXT);
when(thingRegistry.get(eq(THING_UID))).thenReturn(thing);
assertTrue(thing.getConfiguration().get("foo") instanceof String);
inbox.add(DiscoveryResultBuilder.create(THING_UID).withProperty("foo", 3).build());
assertTrue(thing.getConfiguration().get("foo") instanceof String);
assertEquals("3", thing.getConfiguration().get("foo"));
}
use of org.eclipse.smarthome.core.thing.Thing in project smarthome by eclipse.
the class CommunicationManager method handleCallFromHandler.
void handleCallFromHandler(ChannelUID channelUID, @Nullable Thing thing, Consumer<Profile> action) {
itemChannelLinkRegistry.stream().filter(link -> {
// all links for the channel
return link.getLinkedUID().equals(channelUID);
}).forEach(link -> {
Item item = getItem(link.getItemName());
if (item != null) {
Profile profile = getProfile(link, item, thing);
action.accept(profile);
}
});
}
use of org.eclipse.smarthome.core.thing.Thing in project smarthome by eclipse.
the class CommunicationManager method stateUpdated.
public void stateUpdated(ChannelUID channelUID, State state) {
final Thing thing = getThing(channelUID.getThingUID());
handleCallFromHandler(channelUID, thing, profile -> {
if (profile instanceof StateProfile) {
((StateProfile) profile).onStateUpdateFromHandler(state);
}
});
}
use of org.eclipse.smarthome.core.thing.Thing in project smarthome by eclipse.
the class ThingConfigDescriptionAliasProvider method getChannelConfigDescriptionURI.
@Nullable
private URI getChannelConfigDescriptionURI(URI uri) {
String stringUID = uri.getSchemeSpecificPart();
if (uri.getFragment() != null) {
stringUID = stringUID + "#" + uri.getFragment();
}
ChannelUID channelUID = new ChannelUID(stringUID);
ThingUID thingUID = channelUID.getThingUID();
// First, get the thing so we get access to the channel type via the channel
Thing thing = thingRegistry.get(thingUID);
if (thing == null) {
return null;
}
Channel channel = thing.getChannel(channelUID.getId());
if (channel == null) {
return null;
}
ChannelType channelType = channelTypeRegistry.getChannelType(channel.getChannelTypeUID());
if (channelType == null) {
return null;
}
// Get the config description URI for this channel type
URI configURI = channelType.getConfigDescriptionURI();
return configURI;
}
Aggregations