use of org.openhab.binding.onewire.OneWireBindingProvider in project openhab1-addons by openhab.
the class OneWireBinding method updated.
/*
* (non-Javadoc)
*
* @see org.osgi.service.cm.ManagedService#updated(java.util.Dictionary)
*/
@Override
public void updated(Dictionary<String, ?> pvConfig) throws ConfigurationException {
if (pvConfig != null) {
// Basic config
String lvPostOnlyChangedValues = Objects.toString(pvConfig.get("post_only_changed_values"), null);
if (StringUtils.isNotBlank(lvPostOnlyChangedValues)) {
ivPostOnlyChangedValues = Boolean.getBoolean(lvPostOnlyChangedValues);
}
// Connection config
OneWireConnection.updated(pvConfig);
}
for (OneWireBindingProvider lvProvider : providers) {
scheduleAllBindings(lvProvider);
}
}
use of org.openhab.binding.onewire.OneWireBindingProvider in project openhab1-addons by openhab.
the class OneWireBinding method bindingChanged.
/*
* (non-Javadoc)
*
* @see
* org.openhab.core.binding.AbstractBinding#bindingChanged(org.openhab.core
* .binding.BindingProvider, java.lang.String)
*/
@Override
public void bindingChanged(BindingProvider pvProvider, String pvItemName) {
logger.debug("bindingChanged() for item {} msg received.", pvItemName);
if (pvProvider instanceof OneWireBindingProvider) {
ivCacheItemStates.remove(pvItemName);
OneWireBindingProvider lvBindingProvider = (OneWireBindingProvider) pvProvider;
OneWireBindingConfig lvBindingConfig = lvBindingProvider.getBindingConfig(pvItemName);
// AbstractOneWireControlBindingConfigs
if (lvBindingConfig != null && lvBindingConfig instanceof AbstractOneWireDevicePropertyBindingConfig) {
AbstractOneWireDevicePropertyBindingConfig lvDeviceBindingConfig = (AbstractOneWireDevicePropertyBindingConfig) lvBindingConfig;
logger.debug("Initializing read of item {}.", pvItemName);
int lvAutoRefreshTimeInSecs = lvDeviceBindingConfig.getAutoRefreshInSecs();
if (lvAutoRefreshTimeInSecs > -1) {
ivOneWireReaderScheduler.updateOnce(pvItemName);
}
if (lvAutoRefreshTimeInSecs > 0) {
if (!ivOneWireReaderScheduler.scheduleUpdate(pvItemName, lvAutoRefreshTimeInSecs)) {
logger.warn("Couldn't add to OneWireUpdate scheduler", lvDeviceBindingConfig);
}
} else {
logger.debug("Didn't add to OneWireUpdate scheduler, because refresh is <= 0: {}", lvDeviceBindingConfig);
}
}
}
}
use of org.openhab.binding.onewire.OneWireBindingProvider in project openhab1-addons by openhab.
the class OneWireBinding method scheduleAllBindings.
/**
* schedule All Bindings to get updated
*
* @param pvProvider
*/
private void scheduleAllBindings(BindingProvider pvProvider) {
if (OneWireConnection.isConnectionEstablished()) {
logger.debug("scheduleAllBindings");
if (pvProvider instanceof OneWireBindingProvider) {
OneWireBindingProvider lvBindingProvider = (OneWireBindingProvider) pvProvider;
ivOneWireReaderScheduler.clear();
ivCacheItemStates.clear();
Map<String, BindingConfig> lvBindigConfigs = lvBindingProvider.getBindingConfigs();
for (String lvItemName : lvBindigConfigs.keySet()) {
logger.debug("scheduleAllBindings, now item {}.", lvItemName);
OneWireBindingConfig lvOneWireBindingConfig = (OneWireBindingConfig) lvBindigConfigs.get(lvItemName);
if (lvOneWireBindingConfig instanceof AbstractOneWireDevicePropertyBindingConfig) {
logger.debug("Initializing read of item {}.", lvItemName);
AbstractOneWireDevicePropertyBindingConfig lvDevicePropertyBindingConfig = (AbstractOneWireDevicePropertyBindingConfig) lvOneWireBindingConfig;
if (lvDevicePropertyBindingConfig != null) {
int lvAutoRefreshTimeInSecs = lvDevicePropertyBindingConfig.getAutoRefreshInSecs();
if (lvAutoRefreshTimeInSecs > -1) {
ivOneWireReaderScheduler.updateOnce(lvItemName);
}
if (lvAutoRefreshTimeInSecs > 0) {
if (!ivOneWireReaderScheduler.scheduleUpdate(lvItemName, lvAutoRefreshTimeInSecs)) {
logger.warn("Couldn't add to OneWireUpdate scheduler", lvDevicePropertyBindingConfig);
}
}
}
} else {
logger.debug("Didn't schedule item {} because it is not a DevicePropertyBinding.", lvItemName);
}
}
}
}
}
Aggregations