]> git.basschouten.com Git - openhab-addons.git/blob
09b7a825694ce8915753e18e6d6be15004b13b06
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2024 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.netatmo.internal.handler.channelhelper;
14
15 import static org.openhab.binding.netatmo.internal.NetatmoBindingConstants.*;
16 import static org.openhab.binding.netatmo.internal.utils.ChannelTypeUtils.toQuantityType;
17
18 import java.util.Set;
19
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.eclipse.jdt.annotation.Nullable;
22 import org.openhab.binding.netatmo.internal.api.data.NetatmoConstants.MeasureClass;
23 import org.openhab.binding.netatmo.internal.api.dto.Dashboard;
24 import org.openhab.core.library.types.DecimalType;
25 import org.openhab.core.types.State;
26
27 /**
28  * The {@link AirQualityChannelHelper} handles specific channels of things handling ppm measurement
29  *
30  * @author GaĆ«l L'hopital - Initial contribution
31  *
32  */
33 @NonNullByDefault
34 public class AirQualityChannelHelper extends ChannelHelper {
35
36     public AirQualityChannelHelper(Set<String> providedGroups) {
37         super(providedGroups);
38     }
39
40     @Override
41     protected @Nullable State internalGetDashboard(String channelId, Dashboard dashboard) {
42         switch (channelId) {
43             case CHANNEL_CO2:
44                 return toQuantityType(dashboard.getCo2(), MeasureClass.CO2);
45             case CHANNEL_HEALTH_INDEX:
46                 return new DecimalType(dashboard.getHealthIdx());
47         }
48         return null;
49     }
50 }