use of org.openhab.core.thing.ThingStatusInfo in project openhab-addons by openhab.
the class MieleApplianceHandler method onBridgeConnectionResumed.
public void onBridgeConnectionResumed() {
Bridge bridge = getBridge();
if (bridge != null && getMieleBridgeHandler() != null) {
ThingStatusInfo statusInfo = bridge.getStatusInfo();
updateStatus(statusInfo.getStatus(), statusInfo.getStatusDetail(), statusInfo.getDescription());
initializeTranslationProvider(bridge);
}
}
use of org.openhab.core.thing.ThingStatusInfo in project openhab-addons by openhab.
the class HomieThingHandlerTests method setUp.
@BeforeEach
public void setUp() {
final ThingStatusInfo thingStatus = new ThingStatusInfo(ThingStatus.ONLINE, ThingStatusDetail.NONE, null);
final Configuration config = new Configuration();
config.put("basetopic", "homie");
config.put("deviceid", deviceID);
thing = ThingBuilder.create(MqttBindingConstants.HOMIE300_MQTT_THING, TEST_HOMIE_THING.getId()).withConfiguration(config).build();
thing.setStatusInfo(thingStatus);
// Return the mocked connection object if the bridge handler is asked for it
when(bridgeHandler.getConnectionAsync()).thenReturn(CompletableFuture.completedFuture(connection));
doReturn(CompletableFuture.completedFuture(true)).when(connection).subscribe(any(), any());
doReturn(CompletableFuture.completedFuture(true)).when(connection).unsubscribe(any(), any());
doReturn(CompletableFuture.completedFuture(true)).when(connection).unsubscribeAll();
doReturn(CompletableFuture.completedFuture(true)).when(connection).publish(any(), any(), anyInt(), anyBoolean());
doReturn(false).when(scheduledFuture).isDone();
doReturn(scheduledFuture).when(scheduler).schedule(any(Runnable.class), anyLong(), any(TimeUnit.class));
final HomieThingHandler handler = new HomieThingHandler(thing, channelTypeProvider, 1000, 30, 5);
thingHandler = spy(handler);
thingHandler.setCallback(callback);
final Device device = new Device(thing.getUID(), thingHandler, spy(new DeviceAttributes()), spy(new ChildMap<>()));
thingHandler.setInternalObjects(spy(device), spy(new DelayedBatchProcessing<>(500, thingHandler, scheduler)));
// Return the bridge handler if the thing handler asks for it
doReturn(bridgeHandler).when(thingHandler).getBridgeHandler();
// We are by default online
doReturn(thingStatus).when(thingHandler).getBridgeStatus();
}
use of org.openhab.core.thing.ThingStatusInfo in project openhab-addons by openhab.
the class AbstractHomeAssistantTests method beforeEachAbstractHomeAssistantTests.
@BeforeEach
public void beforeEachAbstractHomeAssistantTests() {
when(thingTypeRegistry.getThingType(BRIDGE_TYPE_UID)).thenReturn(ThingTypeBuilder.instance(BRIDGE_TYPE_UID, BRIDGE_TYPE_LABEL).build());
when(thingTypeRegistry.getThingType(HA_TYPE_UID)).thenReturn(ThingTypeBuilder.instance(HA_TYPE_UID, HA_TYPE_LABEL).build());
when(transformationServiceProvider.getTransformationService(JinjaTransformationProfile.PROFILE_TYPE_UID.getId())).thenReturn(jinjaTransformationService);
channelTypeProvider = spy(new MqttChannelTypeProvider(thingTypeRegistry));
setupConnection();
// Return the mocked connection object if the bridge handler is asked for it
when(bridgeHandler.getConnectionAsync()).thenReturn(CompletableFuture.completedFuture(bridgeConnection));
bridgeThing.setStatusInfo(new ThingStatusInfo(ThingStatus.ONLINE, ThingStatusDetail.ONLINE.NONE, ""));
bridgeThing.setHandler(bridgeHandler);
haThing.setStatusInfo(new ThingStatusInfo(ThingStatus.ONLINE, ThingStatusDetail.ONLINE.NONE, ""));
}
use of org.openhab.core.thing.ThingStatusInfo in project openhab-addons by openhab.
the class SceneHandler method onSceneAdded.
@Override
public void onSceneAdded(InternalScene scene) {
logger.debug("Scene {} added", scene.getID());
if (this.bridgeHandler != null) {
ThingStatusInfo statusInfo = this.bridgeHandler.getThing().getStatusInfo();
updateStatus(statusInfo.getStatus(), statusInfo.getStatusDetail(), statusInfo.getDescription());
logger.debug("Set status on {}", getThing().getStatus());
}
this.scene = scene;
onSceneStateChanged(scene.isActive());
}
use of org.openhab.core.thing.ThingStatusInfo in project openhab-addons by openhab.
the class RoombaHandlerTest method setUp.
@BeforeEach
void setUp() throws Exception {
Logger logger = LoggerFactory.getLogger(RoombaHandler.class);
Field logLevelField = logger.getClass().getDeclaredField("currentLogLevel");
logLevelField.setAccessible(true);
logLevelField.set(logger, LocationAwareLogger.TRACE_INT);
Configuration config = new Configuration();
config.put("ipaddress", RoombaHandlerTest.IP_ADDRESS);
config.put("password", RoombaHandlerTest.PASSWORD);
Mockito.when(thing.getConfiguration()).thenReturn(config);
Mockito.lenient().when(thing.getStatusInfo()).thenReturn(new ThingStatusInfo(ThingStatus.UNINITIALIZED, ThingStatusDetail.NONE, "mocked"));
Mockito.lenient().when(thing.getUID()).thenReturn(new ThingUID("mocked", "irobot", "uid"));
callback = Mockito.mock(ThingHandlerCallback.class);
handler = new RoombaHandler(thing);
handler.setCallback(callback);
}
Aggregations