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.toQuantityType;
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.library.types.DecimalType;
26 import org.openhab.core.types.State;
29 * The {@link HumidityChannelHelper} handles specific channels of modules returning humidity measures.
31 * @author Gaƫl L'hopital - Initial contribution
35 public class HumidityChannelHelper extends ChannelHelper {
37 public HumidityChannelHelper(Set<String> providedGroups) {
38 super(providedGroups);
42 protected @Nullable State internalGetDashboard(String channelId, Dashboard dashboard) {
43 return switch (channelId) {
44 case CHANNEL_HUMIDEX -> new DecimalType(humidex(dashboard.getTemperature(), dashboard.getHumidity()));
45 case CHANNEL_HUMIDEX_SCALE ->
46 new DecimalType(humidexScale(humidex(dashboard.getTemperature(), dashboard.getHumidity())));
47 case CHANNEL_VALUE -> toQuantityType(dashboard.getHumidity(), MeasureClass.HUMIDITY);