use of org.openhab.binding.mystromecopower.internal.api.mock.MockMystromClient in project openhab1-addons by openhab.
the class MyStromEcoPowerBinding method updated.
/**
* {@inheritDoc}
*/
@Override
public void updated(Dictionary<String, ?> config) throws ConfigurationException {
if (config != null) {
// to override the default refresh interval one has to add a
// parameter to openhab.cfg like
// <bindingName>:refresh=<intervalInMs>
String refreshIntervalString = (String) config.get("refresh");
if (StringUtils.isNotBlank(refreshIntervalString)) {
refreshInterval = Long.parseLong(refreshIntervalString);
}
// read further config parameters here ...
// read user name
String userName = (String) config.get("userName");
if (StringUtils.isNotBlank(userName)) {
this.userName = userName;
} else {
throw new ConfigurationException("userName", "The userName to connect to myStrom must be specified in config file");
}
String password = (String) config.get("password");
if (StringUtils.isNotBlank(password)) {
this.password = password;
} else {
throw new ConfigurationException("password", "The password to connect to myStrom must be specified in config file");
}
if (this.devMode) {
this.mystromClient = new MockMystromClient();
} else {
this.mystromClient = new MystromClient(this.userName, this.password, logger);
}
if (ChangeStateJob.MystromClient == null) {
ChangeStateJob.MystromClient = this.mystromClient;
}
setProperlyConfigured(true);
// do a discovery of all mystrom eco power to get id of devices
try {
this.mystromDiscovery();
} catch (IOException e) {
logger.error("Error doing discovery of your devices", e);
}
}
}
Aggregations