Search in sources :

Example 1 with OneWireBindingProvider

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);
    }
}
Also used : OneWireBindingProvider(org.openhab.binding.onewire.OneWireBindingProvider)

Example 2 with OneWireBindingProvider

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);
            }
        }
    }
}
Also used : AbstractOneWireDevicePropertyBindingConfig(org.openhab.binding.onewire.internal.deviceproperties.AbstractOneWireDevicePropertyBindingConfig) OneWireBindingProvider(org.openhab.binding.onewire.OneWireBindingProvider)

Example 3 with OneWireBindingProvider

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);
                }
            }
        }
    }
}
Also used : AbstractOneWireDevicePropertyBindingConfig(org.openhab.binding.onewire.internal.deviceproperties.AbstractOneWireDevicePropertyBindingConfig) OneWireDevicePropertyExecutableBindingConfig(org.openhab.binding.onewire.internal.deviceproperties.OneWireDevicePropertyExecutableBindingConfig) AbstractOneWireDevicePropertyWritableBindingConfig(org.openhab.binding.onewire.internal.deviceproperties.AbstractOneWireDevicePropertyWritableBindingConfig) BindingConfig(org.openhab.core.binding.BindingConfig) AbstractOneWireControlBindingConfig(org.openhab.binding.onewire.internal.control.AbstractOneWireControlBindingConfig) AbstractOneWireDevicePropertyBindingConfig(org.openhab.binding.onewire.internal.deviceproperties.AbstractOneWireDevicePropertyBindingConfig) OneWireBindingProvider(org.openhab.binding.onewire.OneWireBindingProvider)

Aggregations

OneWireBindingProvider (org.openhab.binding.onewire.OneWireBindingProvider)3 AbstractOneWireDevicePropertyBindingConfig (org.openhab.binding.onewire.internal.deviceproperties.AbstractOneWireDevicePropertyBindingConfig)2 AbstractOneWireControlBindingConfig (org.openhab.binding.onewire.internal.control.AbstractOneWireControlBindingConfig)1 AbstractOneWireDevicePropertyWritableBindingConfig (org.openhab.binding.onewire.internal.deviceproperties.AbstractOneWireDevicePropertyWritableBindingConfig)1 OneWireDevicePropertyExecutableBindingConfig (org.openhab.binding.onewire.internal.deviceproperties.OneWireDevicePropertyExecutableBindingConfig)1 BindingConfig (org.openhab.core.binding.BindingConfig)1