Java Code Examples for org.eclipse.smarthome.core.thing.ThingStatusDetail#NONE

The following examples show how to use org.eclipse.smarthome.core.thing.ThingStatusDetail#NONE . 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: AstroValidConfigurationTest.java    From smarthome with Eclipse Public License 2.0 6 votes vote down vote up
private void assertThingStatus(Configuration configuration, ThingStatus expectedStatus) {
    ThingUID thingUID = new ThingUID(THING_TYPE_SUN, TEST_SUN_THING_ID);

    Thing thing = mock(Thing.class);
    when(thing.getConfiguration()).thenReturn(configuration);
    when(thing.getUID()).thenReturn(thingUID);

    ThingHandlerCallback callback = mock(ThingHandlerCallback.class);
    CronScheduler cronScheduler = mock(CronScheduler.class);
    ThingHandler sunHandler = new SunHandler(thing, cronScheduler);
    sunHandler.setCallback(callback);

    sunHandler.initialize();

    ThingStatusInfo expectedThingStatus = new ThingStatusInfo(expectedStatus, ThingStatusDetail.NONE, null);
    verify(callback, times(1)).statusUpdated(thing, expectedThingStatus);
}
 
Example 2
Source File: ThingStatusInfoI18nLocalizationServiceOSGiTest.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void thingStatusInfoNotChangedForNonI18nConstantDescription() {
    ThingStatusInfo expected = new ThingStatusInfo(ThingStatus.ONLINE, ThingStatusDetail.NONE, "The description.");
    setThingStatusInfo(thing, expected);

    ThingStatusInfo thingStatusInfo = thingStatusInfoI18nLocalizationService.getLocalizedThingStatusInfo(thing,
            null);
    assertThat(thingStatusInfo, is(expected));
}
 
Example 3
Source File: HomematicThingHandler.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Updates the thing status based on device status.
 */
private void updateStatus(HmDevice device) throws GatewayNotAvailableException, IOException {
    loadHomematicChannelValues(device.getChannel(0));

    ThingStatus oldStatus = thing.getStatus();
    ThingStatus newStatus = ThingStatus.ONLINE;
    ThingStatusDetail newDetail = ThingStatusDetail.NONE;

    if (getBridge().getStatus() == ThingStatus.OFFLINE) {
        newStatus = ThingStatus.OFFLINE;
        newDetail = ThingStatusDetail.BRIDGE_OFFLINE;
    } else if (device.isFirmwareUpdating()) {
        newStatus = ThingStatus.OFFLINE;
        newDetail = ThingStatusDetail.FIRMWARE_UPDATING;
    } else if (device.isUnreach()) {
        newStatus = ThingStatus.OFFLINE;
        newDetail = ThingStatusDetail.COMMUNICATION_ERROR;
    } else if (device.isConfigPending() || device.isUpdatePending()) {
        newDetail = ThingStatusDetail.CONFIGURATION_PENDING;
    }

    if (thing.getStatus() != newStatus || thing.getStatusInfo().getStatusDetail() != newDetail) {
        updateStatus(newStatus, newDetail);
    }
    if (oldStatus == ThingStatus.OFFLINE && newStatus == ThingStatus.ONLINE) {
        initialize();
    }
}
 
Example 4
Source File: ChannelStateTransformationTests.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
@Before
public void setUp() throws ConfigurationException, MqttException {
    initMocks(this);

    ThingStatusInfo thingStatus = new ThingStatusInfo(ThingStatus.ONLINE, ThingStatusDetail.NONE, null);

    // Mock the thing: We need the thingUID and the bridgeUID
    when(thing.getUID()).thenReturn(testGenericThing);
    when(thing.getChannels()).thenReturn(thingChannelListWithJson);
    when(thing.getStatusInfo()).thenReturn(thingStatus);
    when(thing.getConfiguration()).thenReturn(new Configuration());

    // Return the mocked connection object if the bridge handler is asked for it
    when(bridgeHandler.getConnectionAsync()).thenReturn(CompletableFuture.completedFuture(connection));

    CompletableFuture<Void> voidFutureComplete = new CompletableFuture<Void>();
    voidFutureComplete.complete(null);
    doReturn(voidFutureComplete).when(connection).unsubscribeAll();
    doReturn(CompletableFuture.completedFuture(true)).when(connection).subscribe(any(), any());
    doReturn(CompletableFuture.completedFuture(true)).when(connection).unsubscribe(any(), any());

    thingHandler = spy(new GenericThingHandler(thing, mock(MqttChannelStateDescriptionProvider.class),
            transformationServiceProvider, 1500));
    when(transformationServiceProvider.getTransformationService(anyString())).thenReturn(jsonPathService);

    thingHandler.setCallback(callback);
    // 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();
}
 
Example 5
Source File: GenericThingHandlerTests.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
@Before
public void setUp() {
    ThingStatusInfo thingStatus = new ThingStatusInfo(ThingStatus.ONLINE, ThingStatusDetail.NONE, null);

    MockitoAnnotations.initMocks(this);
    // Mock the thing: We need the thingUID and the bridgeUID
    when(thing.getUID()).thenReturn(testGenericThing);
    when(thing.getChannels()).thenReturn(thingChannelList);
    when(thing.getStatusInfo()).thenReturn(thingStatus);
    when(thing.getConfiguration()).thenReturn(new Configuration());

    // Return the mocked connection object if the bridge handler is asked for it
    when(bridgeHandler.getConnectionAsync()).thenReturn(CompletableFuture.completedFuture(connection));

    CompletableFuture<Void> voidFutureComplete = new CompletableFuture<Void>();
    voidFutureComplete.complete(null);
    doReturn(voidFutureComplete).when(connection).unsubscribeAll();
    doReturn(CompletableFuture.completedFuture(true)).when(connection).subscribe(any(), any());
    doReturn(CompletableFuture.completedFuture(true)).when(connection).unsubscribe(any(), any());
    doReturn(CompletableFuture.completedFuture(true)).when(connection).publish(any(), any());
    doReturn(CompletableFuture.completedFuture(true)).when(connection).publish(any(), any(), anyInt(),
            anyBoolean());

    thingHandler = spy(new GenericThingHandler(thing, mock(MqttChannelStateDescriptionProvider.class),
            mock(TransformationServiceProvider.class), 1500));
    thingHandler.setCallback(callback);

    // Return the bridge handler if the thing handler asks for it
    doReturn(bridgeHandler).when(thingHandler).getBridgeHandler();

    // The broker connection bridge is by default online
    doReturn(thingStatus).when(thingHandler).getBridgeStatus();
}
 
Example 6
Source File: DimmerThingHandler.java    From smarthome with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void initialize() {
    Bridge bridge = getBridge();
    DmxBridgeHandler bridgeHandler;
    if (bridge == null) {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "no bridge assigned");
        dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
        return;
    } else {
        bridgeHandler = (DmxBridgeHandler) bridge.getHandler();
        if (bridgeHandler == null) {
            updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "no bridge handler available");
            dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
            return;
        }
    }

    DimmerThingHandlerConfiguration configuration = getConfig().as(DimmerThingHandlerConfiguration.class);

    if (configuration.dmxid.isEmpty()) {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
                "DMX channel configuration missing");
        dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
        return;
    }
    try {
        List<BaseDmxChannel> configChannels = BaseDmxChannel.fromString(configuration.dmxid,
                bridgeHandler.getUniverseId());
        logger.trace("found {} channels in {}", configChannels.size(), this.thing.getUID());
        for (BaseDmxChannel channel : configChannels) {
            channels.add(bridgeHandler.getDmxChannel(channel, this.thing));
        }
    } catch (IllegalArgumentException e) {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, e.getMessage());
        dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
        return;
    }

    fadeTime = configuration.fadetime;
    logger.trace("setting fadeTime to {} ms in {}", fadeTime, this.thing.getUID());

    dimTime = configuration.dimtime;
    logger.trace("setting dimTime to {} ms in {}", fadeTime, this.thing.getUID());

    String turnOnValueString = String.valueOf(fadeTime) + ":" + configuration.turnonvalue + ":-1";

    ValueSet turnOnValue = ValueSet.fromString(turnOnValueString);
    if (!turnOnValue.isEmpty()) {
        this.turnOnValue = turnOnValue;
        logger.trace("set turnonvalue to {} in {}", turnOnValue, this.thing.getUID());
    } else {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "turn-on value malformed");
        dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
        return;
    }

    this.turnOnValue.setFadeTime(fadeTime);

    dynamicTurnOnValue = configuration.dynamicturnonvalue;

    String turnOffValueString = String.valueOf(fadeTime) + ":" + configuration.turnoffvalue + ":-1";
    ValueSet turnOffValue = ValueSet.fromString(turnOffValueString);
    if (!turnOffValue.isEmpty()) {
        this.turnOffValue = turnOffValue;
        logger.trace("set turnoffvalue to {} in {}", turnOffValue, this.thing.getUID());
    } else {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "turn-off value malformed");
        dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
        return;
    }

    this.turnOffValue.setFadeTime(fadeTime);

    // register feedback listener
    channels.get(0).addListener(new ChannelUID(this.thing.getUID(), CHANNEL_BRIGHTNESS), this, ListenerType.VALUE);

    if (bridge.getStatus().equals(ThingStatus.ONLINE)) {
        updateStatus(ThingStatus.ONLINE);
        dmxHandlerStatus = ThingStatusDetail.NONE;
    } else {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE);
    }
}
 
Example 7
Source File: ColorThingHandler.java    From smarthome with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void initialize() {
    Bridge bridge = getBridge();
    DmxBridgeHandler bridgeHandler;
    if (bridge == null) {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "no bridge assigned");
        dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
        return;
    } else {
        bridgeHandler = (DmxBridgeHandler) bridge.getHandler();
        if (bridgeHandler == null) {
            updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "no bridge handler available");
            dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
            return;
        }
    }

    ColorThingHandlerConfiguration configuration = getConfig().as(ColorThingHandlerConfiguration.class);
    if (configuration.dmxid.isEmpty()) {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
                "DMX channel configuration missing");
        dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
        return;
    }
    try {
        List<BaseDmxChannel> configChannels = BaseDmxChannel.fromString(configuration.dmxid,
                bridgeHandler.getUniverseId());
        logger.trace("found {} channels in {}", configChannels.size(), this.thing.getUID());
        for (BaseDmxChannel channel : configChannels) {
            channels.add(bridgeHandler.getDmxChannel(channel, this.thing));
        }
    } catch (IllegalArgumentException e) {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, e.getMessage());
        dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
        return;
    }

    currentValues.add(DmxChannel.MIN_VALUE);
    currentValues.add(DmxChannel.MIN_VALUE);
    currentValues.add(DmxChannel.MIN_VALUE);

    fadeTime = configuration.fadetime;
    logger.trace("setting fadeTime to {} ms in {}", fadeTime, this.thing.getUID());

    dimTime = configuration.dimtime;
    logger.trace("setting dimTime to {} ms in {}", fadeTime, this.thing.getUID());

    String turnOnValueString = String.valueOf(fadeTime) + ":" + configuration.turnonvalue + ":-1";
    ValueSet turnOnValue = ValueSet.fromString(turnOnValueString);
    if (turnOnValue.size() % 3 == 0) {
        this.turnOnValue = turnOnValue;
        logger.trace("set turnonvalue to {} in {}", turnOnValue, this.thing.getUID());
    } else {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "turn-on value malformed");
        dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
        return;
    }
    this.turnOnValue.setFadeTime(fadeTime);

    dynamicTurnOnValue = configuration.dynamicturnonvalue;

    String turnOffValueString = String.valueOf(fadeTime) + ":" + configuration.turnoffvalue + ":-1";
    ValueSet turnOffValue = ValueSet.fromString(turnOffValueString);
    if (turnOffValue.size() % 3 == 0) {
        this.turnOffValue = turnOffValue;
        logger.trace("set turnoffvalue to {} in {}", turnOffValue, this.thing.getUID());
    } else {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "turn-off value malformed");
        dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
        return;
    }

    this.turnOffValue.setFadeTime(fadeTime);

    // register feedback listeners
    channels.get(0).addListener(new ChannelUID(this.thing.getUID(), CHANNEL_BRIGHTNESS_R), this,
            ListenerType.VALUE);
    channels.get(1).addListener(new ChannelUID(this.thing.getUID(), CHANNEL_BRIGHTNESS_G), this,
            ListenerType.VALUE);
    channels.get(2).addListener(new ChannelUID(this.thing.getUID(), CHANNEL_BRIGHTNESS_B), this,
            ListenerType.VALUE);

    if (bridge.getStatus().equals(ThingStatus.ONLINE)) {
        updateStatus(ThingStatus.ONLINE);
        dmxHandlerStatus = ThingStatusDetail.NONE;
    } else {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE);
    }
}
 
Example 8
Source File: ChaserThingHandler.java    From smarthome with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void initialize() {
    Bridge bridge = getBridge();
    DmxBridgeHandler bridgeHandler;
    if (bridge == null) {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "no bridge assigned");
        dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
        return;
    } else {
        bridgeHandler = (DmxBridgeHandler) bridge.getHandler();
        if (bridgeHandler == null) {
            updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "no bridge handler available");
            dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
            return;
        }
    }

    ChaserThingHandlerConfiguration configuration = getConfig().as(ChaserThingHandlerConfiguration.class);

    if (configuration.dmxid.isEmpty()) {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
                "DMX channel configuration missing");
        dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
        return;
    }

    try {
        List<BaseDmxChannel> configChannels = BaseDmxChannel.fromString(configuration.dmxid,
                bridgeHandler.getUniverseId());
        logger.trace("found {} channels in {}", configChannels.size(), this.thing.getUID());
        for (BaseDmxChannel channel : configChannels) {
            channels.add(bridgeHandler.getDmxChannel(channel, this.thing));
        }
    } catch (IllegalArgumentException e) {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, e.getMessage());
        dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
        return;
    }
    if (!configuration.steps.isEmpty()) {
        if (parseChaserConfig(configuration.steps)) {
            if (bridge.getStatus().equals(ThingStatus.ONLINE)) {
                updateStatus(ThingStatus.ONLINE);
                dmxHandlerStatus = ThingStatusDetail.NONE;
            } else {
                updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE);
            }
        } else {
            updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
                    "Chase configuration malformed");
            dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
        }
    } else {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Chase configuration missing");
        dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
    }

    resumeAfter = configuration.resumeafter;
    logger.trace("set resumeAfter to {}", resumeAfter);
}
 
Example 9
Source File: TunableWhiteThingHandler.java    From smarthome with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void initialize() {
    Bridge bridge = getBridge();
    DmxBridgeHandler bridgeHandler;
    if (bridge == null) {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "no bridge assigned");
        dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
        return;
    } else {
        bridgeHandler = (DmxBridgeHandler) bridge.getHandler();
        if (bridgeHandler == null) {
            updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "no bridge handler available");
            dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
            return;
        }
    }

    TunableWhiteThingHandlerConfiguration configuration = getConfig()
            .as(TunableWhiteThingHandlerConfiguration.class);
    if (configuration.dmxid.isEmpty()) {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
                "DMX channel configuration missing");
        dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
        return;
    }
    try {
        List<BaseDmxChannel> configChannels = BaseDmxChannel.fromString(configuration.dmxid,
                bridgeHandler.getUniverseId());
        logger.trace("found {} channels in {}", configChannels.size(), this.thing.getUID());
        for (BaseDmxChannel channel : configChannels) {
            channels.add(bridgeHandler.getDmxChannel(channel, this.thing));
        }
    } catch (IllegalArgumentException e) {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, e.getMessage());
        dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
        return;
    }

    currentValues.add(DmxChannel.MIN_VALUE);
    currentValues.add(DmxChannel.MIN_VALUE);

    fadeTime = configuration.fadetime;
    logger.trace("setting fadeTime to {} ms in {}", fadeTime, this.thing.getUID());

    dimTime = configuration.dimtime;
    logger.trace("setting dimTime to {} ms in {}", fadeTime, this.thing.getUID());

    String turnOnValueString = String.valueOf(fadeTime) + ":" + configuration.turnonvalue + ":-1";
    ValueSet turnOnValue = ValueSet.fromString(turnOnValueString);
    if (turnOnValue.size() % 2 == 0) {
        this.turnOnValue = turnOnValue;
        logger.trace("set turnonvalue to {} in {}", turnOnValue, this.thing.getUID());
    } else {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "turn-on value malformed");
        dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
        return;
    }
    this.turnOnValue.setFadeTime(fadeTime);

    dynamicTurnOnValue = configuration.dynamicturnonvalue;

    String turnOffValueString = String.valueOf(fadeTime) + ":" + configuration.turnoffvalue + ":-1";
    ValueSet turnOffValue = ValueSet.fromString(turnOffValueString);
    if (turnOffValue.size() % 2 == 0) {
        this.turnOffValue = turnOffValue;
        logger.trace("set turnoffvalue to {} in {}", turnOffValue, this.thing.getUID());
    } else {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "turn-off value malformed");
        dmxHandlerStatus = ThingStatusDetail.CONFIGURATION_ERROR;
        return;
    }

    this.turnOffValue.setFadeTime(fadeTime);

    // register feedback listeners
    channels.get(0).addListener(new ChannelUID(this.thing.getUID(), CHANNEL_BRIGHTNESS_CW), this,
            ListenerType.VALUE);
    channels.get(1).addListener(new ChannelUID(this.thing.getUID(), CHANNEL_BRIGHTNESS_WW), this,
            ListenerType.VALUE);

    if (bridge.getStatus().equals(ThingStatus.ONLINE)) {
        updateStatus(ThingStatus.ONLINE);
        dmxHandlerStatus = ThingStatusDetail.NONE;
    } else {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE);
    }
}
 
Example 10
Source File: HomieThingHandlerTests.java    From smarthome with Eclipse Public License 2.0 4 votes vote down vote up
@Before
public void setUp() {
    final ThingStatusInfo thingStatus = new ThingStatusInfo(ThingStatus.ONLINE, ThingStatusDetail.NONE, null);

    MockitoAnnotations.initMocks(this);

    final Configuration config = new Configuration();
    config.put("basetopic", "homie");
    config.put("deviceid", deviceID);

    thing = ThingBuilder.create(MqttBindingConstants.HOMIE300_MQTT_THING, testHomieThing.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, 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<Object>(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();

}