]> git.basschouten.com Git - openhab-addons.git/blob
09f507cb1055630f048c3741847c2b39dca3b732
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 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 import static org.openhab.binding.netatmo.internal.utils.WeatherUtils.*;
18
19 import java.util.Set;
20
21 import org.eclipse.jdt.annotation.NonNullByDefault;
22 import org.eclipse.jdt.annotation.Nullable;
23 import org.openhab.binding.netatmo.internal.api.data.NetatmoConstants.MeasureClass;
24 import org.openhab.binding.netatmo.internal.api.dto.Dashboard;
25 import org.openhab.core.library.types.DecimalType;
26 import org.openhab.core.types.State;
27
28 /**
29  * The {@link HumidityChannelHelper} handles specific channels of modules returning humidity measures.
30  *
31  * @author GaĆ«l L'hopital - Initial contribution
32  *
33  */
34 @NonNullByDefault
35 public class HumidityChannelHelper extends ChannelHelper {
36
37     public HumidityChannelHelper(Set<String> providedGroups) {
38         super(providedGroups);
39     }
40
41     @Override
42     protected @Nullable State internalGetDashboard(String channelId, Dashboard dashboard) {
43         switch (channelId) {
44             case CHANNEL_HUMIDEX:
45                 return new DecimalType(humidex(dashboard.getTemperature(), dashboard.getHumidity()));
46             case CHANNEL_HUMIDEX_SCALE:
47                 return new DecimalType(humidexScale(humidex(dashboard.getTemperature(), dashboard.getHumidity())));
48             case CHANNEL_VALUE:
49                 return toQuantityType(dashboard.getHumidity(), MeasureClass.HUMIDITY);
50         }
51         return null;
52     }
53 }