2 * Copyright (c) 2010-2022 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.netatmo.internal.handler.channelhelper;
15 import static org.openhab.binding.netatmo.internal.NetatmoBindingConstants.*;
16 import static org.openhab.binding.netatmo.internal.utils.ChannelTypeUtils.*;
17 import static org.openhab.binding.netatmo.internal.utils.WeatherUtils.*;
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.eclipse.jdt.annotation.Nullable;
21 import org.openhab.binding.netatmo.internal.api.data.NetatmoConstants.MeasureClass;
22 import org.openhab.binding.netatmo.internal.api.dto.Dashboard;
23 import org.openhab.core.types.State;
26 * The {@link TemperatureChannelHelper} handles channels of modules measuring temperature
28 * @author Gaƫl L'hopital - Initial contribution
32 public class TemperatureChannelHelper extends ChannelHelper {
34 * TemperatureChannelHelper may be used by indoor or outdoor modules. There is no easy way here to decide what is
35 * the handler owning the channelHelper. The usage of OUTSIDE_TEMPERATURE instead of INSIDE_TEMPERATURE is by design
36 * because OUTSIDE_TEMPERATURE has wide value range than INSIDE_TEMPERATURE.
38 public TemperatureChannelHelper() {
39 this(GROUP_TEMPERATURE, MeasureClass.OUTSIDE_TEMPERATURE);
42 protected TemperatureChannelHelper(String groupName, MeasureClass measureClass) {
43 super(groupName, measureClass);
47 protected @Nullable State internalGetDashboard(String channelId, Dashboard dashboard) {
50 return toQuantityType(dashboard.getTemperature(), MeasureClass.OUTSIDE_TEMPERATURE);
51 case CHANNEL_MIN_VALUE:
52 return toQuantityType(dashboard.getMinTemp(), MeasureClass.OUTSIDE_TEMPERATURE);
53 case CHANNEL_MAX_VALUE:
54 return toQuantityType(dashboard.getMaxTemp(), MeasureClass.OUTSIDE_TEMPERATURE);
55 case CHANNEL_MIN_TIME:
56 return toDateTimeType(dashboard.getDateMinTemp());
57 case CHANNEL_MAX_TIME:
58 return toDateTimeType(dashboard.getDateMaxTemp());
59 case CHANNEL_HEAT_INDEX:
60 return toQuantityType(heatIndex(dashboard.getTemperature(), dashboard.getHumidity()),
61 MeasureClass.HEAT_INDEX);
62 case CHANNEL_DEWPOINT:
63 return toQuantityType(dewPoint(dashboard.getTemperature(), dashboard.getHumidity()),
64 MeasureClass.OUTSIDE_TEMPERATURE);
65 case CHANNEL_DEWPOINT_DEP:
66 double dewPoint = dewPoint(dashboard.getTemperature(), dashboard.getHumidity());
67 return toQuantityType(dewPointDep(dashboard.getTemperature(), dewPoint),
68 MeasureClass.OUTSIDE_TEMPERATURE);