use of org.eclipse.smarthome.config.core.Configuration in project smarthome by eclipse.
the class TradfriGatewayHandler method initialize.
@Override
public void initialize() {
TradfriGatewayConfig configuration = getConfigAs(TradfriGatewayConfig.class);
if (isNullOrEmpty(configuration.host)) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Host must be specified in the configuration!");
return;
}
if (isNullOrEmpty(configuration.code)) {
if (isNullOrEmpty(configuration.identity) || isNullOrEmpty(configuration.preSharedKey)) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Either security code or identity and pre-shared key must be provided in the configuration!");
return;
} else {
establishConnection();
}
} else {
if (isOldFirmware()) {
/*
* older firmware - fall back to authentication with security code
* in this case the Thing configuration will not be persisted
*/
logger.warn("Gateway with old firmware - please consider upgrading to the latest version.");
Configuration editedConfig = editConfiguration();
editedConfig.put(TradfriBindingConstants.GATEWAY_CONFIG_IDENTITY, "");
editedConfig.put(TradfriBindingConstants.GATEWAY_CONFIG_PRE_SHARED_KEY, configuration.code);
updateConfiguration(editedConfig);
establishConnection();
} else {
// Running async operation to retrieve new <'identity','key'> pair
scheduler.execute(() -> {
boolean success = obtainIdentityAndPreSharedKey();
if (success) {
establishConnection();
}
});
}
}
}
use of org.eclipse.smarthome.config.core.Configuration in project smarthome by eclipse.
the class WemoMakerHandler method onUpdate.
private synchronized void onUpdate() {
if (service.isRegistered(this)) {
if (refreshJob == null || refreshJob.isCancelled()) {
Configuration config = getThing().getConfiguration();
int refreshInterval = DEFAULT_REFRESH_INTERVAL;
Object refreshConfig = config.get("refresh");
if (refreshConfig != null) {
refreshInterval = ((BigDecimal) refreshConfig).intValue();
}
refreshJob = scheduler.scheduleWithFixedDelay(refreshRunnable, 0, refreshInterval, TimeUnit.SECONDS);
}
}
}
use of org.eclipse.smarthome.config.core.Configuration in project smarthome by eclipse.
the class WemoMakerHandler method initialize.
@Override
public void initialize() {
Configuration configuration = getConfig();
if (configuration.get("udn") != null) {
logger.debug("Initializing WemoMakerHandler for UDN '{}'", configuration.get("udn"));
onUpdate();
updateStatus(ThingStatus.ONLINE);
} else {
logger.debug("Cannot initalize WemoMakerHandler. UDN not set.");
}
}
use of org.eclipse.smarthome.config.core.Configuration in project smarthome by eclipse.
the class YahooWeatherHandler method initialize.
@Override
public void initialize() {
logger.debug("Initializing YahooWeather handler.");
Configuration config = getThing().getConfiguration();
location = (BigDecimal) config.get(LOCATION_PARAM);
try {
refresh = (BigDecimal) config.get("refresh");
} catch (Exception e) {
logger.debug("Cannot set refresh parameter.", e);
}
if (refresh == null) {
// let's go for the default
refresh = new BigDecimal(60);
}
cache.put(CACHE_KEY_CONFIG, () -> connection.getResponseFromQuery("SELECT location FROM weather.forecast WHERE woeid = " + location.toPlainString()));
cache.put(CACHE_KEY_WEATHER, () -> connection.getResponseFromQuery("SELECT * FROM weather.forecast WHERE u = 'c' AND woeid = " + location.toPlainString()));
startAutomaticRefresh();
}
use of org.eclipse.smarthome.config.core.Configuration in project smarthome by eclipse.
the class WemoBridgeHandler method initialize.
@Override
public void initialize() {
logger.debug("Initializing WemoBridgeHandler");
Configuration configuration = getConfig();
if (configuration.get(UDN) != null) {
logger.trace("Initializing WemoBridgeHandler for UDN '{}'", configuration.get(UDN));
updateStatus(ThingStatus.ONLINE);
} else {
logger.debug("Cannot initalize WemoBridgeHandler. UDN not set.");
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR);
}
}
Aggregations