Java Code Examples for org.eclipse.smarthome.core.thing.Thing#setStatusInfo()

The following examples show how to use org.eclipse.smarthome.core.thing.Thing#setStatusInfo() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ThingRegistryImpl.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
private void preserveDynamicState(Thing thing) {
    final Thing existingThing = get(thing.getUID());
    if (existingThing != null) {
        thing.setHandler(existingThing.getHandler());
        thing.setStatusInfo(existingThing.getStatusInfo());
    }
}
 
Example 2
Source File: ThingManagerImpl.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
private void setThingStatus(Thing thing, ThingStatusInfo thingStatusInfo) {
    ThingStatusInfo oldStatusInfo = thingStatusInfoI18nLocalizationService.getLocalizedThingStatusInfo(thing, null);
    thing.setStatusInfo(thingStatusInfo);
    ThingStatusInfo newStatusInfo = thingStatusInfoI18nLocalizationService.getLocalizedThingStatusInfo(thing, null);
    try {
        eventPublisher.post(ThingEventFactory.createStatusInfoEvent(thing.getUID(), newStatusInfo));
        if (!oldStatusInfo.equals(newStatusInfo)) {
            eventPublisher.post(
                    ThingEventFactory.createStatusInfoChangedEvent(thing.getUID(), newStatusInfo, oldStatusInfo));
        }
    } catch (Exception ex) {
        logger.error("Could not post 'ThingStatusInfoEvent' event: {}", ex.getMessage(), ex);
    }
}