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.*;
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.NAObject;
24 import org.openhab.binding.netatmo.internal.api.dto.Room;
25 import org.openhab.core.types.State;
26 import org.openhab.core.types.UnDefType;
29 * The {@link SetpointChannelHelper} handles channels for a room capable of managing a thermostat
31 * @author Gaƫl L'hopital - Initial contribution
35 public class SetpointChannelHelper extends ChannelHelper {
37 public SetpointChannelHelper(Set<String> providedGroups) {
38 super(providedGroups);
42 protected @Nullable State internalGetObject(String channelId, NAObject naObject) {
43 if (naObject instanceof Room) {
44 Room room = (Room) naObject;
46 case CHANNEL_SETPOINT_MODE:
47 return toStringType(room.getSetpointMode().name());
48 case CHANNEL_SETPOINT_START_TIME:
49 return toDateTimeType(room.getSetpointBegin());
50 case CHANNEL_SETPOINT_END_TIME:
51 return toDateTimeType(room.getSetpointEnd());
53 switch (room.getSetpointMode()) {
56 return UnDefType.UNDEF;
63 return toQuantityType(room.getSetpointTemp(), MeasureClass.INSIDE_TEMPERATURE);
65 return UnDefType.NULL;