2 * Copyright (c) 2010-2023 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.*;
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.types.State;
28 * The {@link TemperatureChannelHelper} handles channels of modules measuring temperature
30 * @author Gaƫl L'hopital - Initial contribution
34 public class TemperatureChannelHelper extends ChannelHelper {
36 public TemperatureChannelHelper(Set<String> providedGroups) {
37 super(providedGroups);
41 protected @Nullable State internalGetDashboard(String channelId, Dashboard dashboard) {
44 return toQuantityType(dashboard.getTemperature(), MeasureClass.OUTSIDE_TEMPERATURE);
45 case CHANNEL_MIN_VALUE:
46 return toQuantityType(dashboard.getMinTemp(), MeasureClass.OUTSIDE_TEMPERATURE);
47 case CHANNEL_MAX_VALUE:
48 return toQuantityType(dashboard.getMaxTemp(), MeasureClass.OUTSIDE_TEMPERATURE);
49 case CHANNEL_MIN_TIME:
50 return toDateTimeType(dashboard.getDateMinTemp());
51 case CHANNEL_MAX_TIME:
52 return toDateTimeType(dashboard.getDateMaxTemp());
53 case CHANNEL_HEAT_INDEX:
54 return toQuantityType(heatIndex(dashboard.getTemperature(), dashboard.getHumidity()),
55 MeasureClass.HEAT_INDEX);
56 case CHANNEL_DEWPOINT:
57 return toQuantityType(dewPoint(dashboard.getTemperature(), dashboard.getHumidity()),
58 MeasureClass.OUTSIDE_TEMPERATURE);
59 case CHANNEL_DEWPOINT_DEP:
60 double dewPoint = dewPoint(dashboard.getTemperature(), dashboard.getHumidity());
61 return toQuantityType(dewPointDep(dashboard.getTemperature(), dewPoint),
62 MeasureClass.OUTSIDE_TEMPERATURE);
64 return toStringType(dashboard.getTempTrend());