Search in sources :

Example 1 with MeasureGroup

use of org.openhab.binding.withings.internal.model.MeasureGroup in project openhab1-addons by openhab.

the class WithingsBinding method updateItemStates.

private void updateItemStates(Map<String, WithingsBindingConfig> withingsBindings) {
    try {
        WithingsApiClient client = this.withingsApiClients.get(0);
        List<MeasureGroup> measures = client.getMeasures(lastUpdate);
        if (measures == null || measures.isEmpty()) {
            logger.info("No new measures found since the last update.");
            return;
        }
        for (Entry<String, WithingsBindingConfig> withingBinding : withingsBindings.entrySet()) {
            WithingsBindingConfig withingsBindingConfig = withingBinding.getValue();
            String itemName = withingBinding.getKey();
            updateItemState(itemName, withingsBindingConfig, measures);
        }
        lastUpdate = now();
    } catch (Exception ex) {
        logger.error("Cannot get Withings measure data: " + ex.getMessage(), ex);
    }
}
Also used : MeasureGroup(org.openhab.binding.withings.internal.model.MeasureGroup) WithingsBindingConfig(org.openhab.binding.withings.WithingsBindingConfig) WithingsApiClient(org.openhab.binding.withings.internal.api.WithingsApiClient) ConfigurationException(org.osgi.service.cm.ConfigurationException)

Aggregations

WithingsBindingConfig (org.openhab.binding.withings.WithingsBindingConfig)1 WithingsApiClient (org.openhab.binding.withings.internal.api.WithingsApiClient)1 MeasureGroup (org.openhab.binding.withings.internal.model.MeasureGroup)1 ConfigurationException (org.osgi.service.cm.ConfigurationException)1