Search in sources :

Example 6 with Configuration

use of org.openhab.core.config.core.Configuration in project openhab-addons by openhab.

the class HueBridgeHandler method updateBridgeThingConfiguration.

private void updateBridgeThingConfiguration(String userName) {
    Configuration config = editConfiguration();
    config.put(USER_NAME, userName);
    try {
        updateConfiguration(config);
        logger.debug("Updated configuration parameter '{}'", USER_NAME);
        hueBridgeConfig = getConfigAs(HueBridgeConfig.class);
    } catch (IllegalStateException e) {
        logger.trace("Configuration update failed.", e);
        logger.warn("Unable to update configuration of Hue bridge.");
        logger.warn("Please configure the user name manually.");
    }
}
Also used : Configuration(org.openhab.core.config.core.Configuration) HueBridgeConfig(org.openhab.binding.hue.internal.config.HueBridgeConfig)

Example 7 with Configuration

use of org.openhab.core.config.core.Configuration in project openhab-addons by openhab.

the class InnogyBridgeHandlerTest method testOnEventDisconnect.

@Test
public void testOnEventDisconnect() throws Exception {
    final String disconnectEventJSON = "{ type: \"Disconnect\" }";
    Configuration bridgeConfig = new Configuration();
    when(bridgeMock.getConfiguration()).thenReturn(bridgeConfig);
    bridgeHandler.initialize();
    verify(webSocketMock).start();
    assertEquals(1, bridgeHandler.getDirectExecutionCount());
    bridgeHandler.onEvent(disconnectEventJSON);
    // automatically restarted (with a delay)
    verify(webSocketMock, times(2)).start();
    assertEquals(1, bridgeHandler.getDirectExecutionCount());
    bridgeHandler.onEvent(disconnectEventJSON);
    // automatically restarted (with a delay)
    verify(webSocketMock, times(3)).start();
    assertEquals(1, bridgeHandler.getDirectExecutionCount());
}
Also used : Configuration(org.openhab.core.config.core.Configuration) Test(org.junit.jupiter.api.Test)

Example 8 with Configuration

use of org.openhab.core.config.core.Configuration in project openhab-addons by openhab.

the class InnogyBridgeHandlerTest method testInitializeErrorOnStartingWebSocket.

@Test
public void testInitializeErrorOnStartingWebSocket() throws Exception {
    Configuration bridgeConfig = new Configuration();
    when(bridgeMock.getConfiguration()).thenReturn(bridgeConfig);
    doThrow(new RuntimeException("Test-Exception")).when(webSocketMock).start();
    bridgeHandler.initialize();
    verify(webSocketMock, times(MAXIMUM_RETRY_EXECUTIONS)).start();
    // only the first execution should be without a delay
    assertEquals(1, bridgeHandler.getDirectExecutionCount());
}
Also used : Configuration(org.openhab.core.config.core.Configuration) Test(org.junit.jupiter.api.Test)

Example 9 with Configuration

use of org.openhab.core.config.core.Configuration in project openhab-addons by openhab.

the class AhaWasteCollectionHandlerTest method createConfig.

private static Configuration createConfig() {
    final Configuration config = new Configuration();
    config.put("commune", "Hannover");
    config.put("collectionPlace", "02095-0010+");
    config.put("houseNumber", "10");
    config.put("houseNumberAddon", "");
    config.put("street", "02095@Oesterleystr.+/+Südstadt@Südstadt");
    return config;
}
Also used : Configuration(org.openhab.core.config.core.Configuration)

Example 10 with Configuration

use of org.openhab.core.config.core.Configuration in project openhab-addons by openhab.

the class AVMFritzBaseThingHandler method updateThingChannelConfiguration.

/**
 * Updates thing channel configurations.
 *
 * @param channelId ID of the channel which configuration to be updated.
 * @param configId ID of the configuration to be updated.
 * @param value Value to be set.
 */
protected void updateThingChannelConfiguration(String channelId, String configId, Object value) {
    Channel channel = thing.getChannel(channelId);
    if (channel != null) {
        Configuration editConfig = channel.getConfiguration();
        editConfig.put(configId, value);
    }
}
Also used : Configuration(org.openhab.core.config.core.Configuration) AVMFritzDeviceConfiguration(org.openhab.binding.avmfritz.internal.config.AVMFritzDeviceConfiguration) Channel(org.openhab.core.thing.Channel)

Aggregations

Configuration (org.openhab.core.config.core.Configuration)498 Test (org.junit.jupiter.api.Test)193 Thing (org.openhab.core.thing.Thing)97 Channel (org.openhab.core.thing.Channel)62 HashMap (java.util.HashMap)60 JavaOSGiTest (org.openhab.core.test.java.JavaOSGiTest)59 ChannelUID (org.openhab.core.thing.ChannelUID)50 ThingUID (org.openhab.core.thing.ThingUID)50 Bridge (org.openhab.core.thing.Bridge)49 Nullable (org.eclipse.jdt.annotation.Nullable)39 BeforeEach (org.junit.jupiter.api.BeforeEach)39 BigDecimal (java.math.BigDecimal)35 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)32 IOException (java.io.IOException)31 ArrayList (java.util.ArrayList)26 Rule (org.openhab.core.automation.Rule)24 ThingHandlerCallback (org.openhab.core.thing.binding.ThingHandlerCallback)24 ThingTypeUID (org.openhab.core.thing.ThingTypeUID)22 Action (org.openhab.core.automation.Action)19 Condition (org.openhab.core.automation.Condition)19