2 * Copyright (c) 2010-2020 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.somfytahoma.internal.handler;
15 import static org.openhab.binding.somfytahoma.internal.SomfyTahomaBindingConstants.*;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.openhab.core.library.types.QuantityType;
19 import org.openhab.core.thing.ChannelUID;
20 import org.openhab.core.thing.Thing;
21 import org.openhab.core.types.Command;
22 import org.openhab.core.types.RefreshType;
25 * The {@link SomfyTahomaValveHeatingSystemHandler} is responsible for handling commands,
26 * which are sent to one of the channels of the valve heating system thing.
28 * @author Ondrej Pecta - Initial contribution
31 public class SomfyTahomaValveHeatingSystemHandler extends SomfyTahomaBaseThingHandler {
33 public SomfyTahomaValveHeatingSystemHandler(Thing thing) {
35 stateNames.put(TARGET_TEMPERATURE, TARGET_ROOM_TEMPERATURE_STATE);
36 stateNames.put(BATTERY_LEVEL, BATTERY_LEVEL_STATE);
37 stateNames.put(DEROGATION_HEATING_MODE, "io:DerogationHeatingModeState");
38 stateNames.put(DEROGATED_TARGET_TEMPERATURE, "core:DerogatedTargetTemperatureState");
39 stateNames.put(CURRENT_HEATING_MODE, "io:CurrentHeatingModeState");
40 stateNames.put(OPEN_CLOSED_VALVE, "core:OpenClosedValveState");
41 stateNames.put(OPERATING_MODE, "core:OperatingModeState");
45 public void handleCommand(ChannelUID channelUID, Command command) {
46 super.handleCommand(channelUID, command);
47 if (command instanceof RefreshType) {
50 if (DEROGATED_TARGET_TEMPERATURE.equals(channelUID.getId()) && command instanceof QuantityType) {
51 QuantityType type = (QuantityType) command;
52 String param = "[" + type.doubleValue() + ", \"next_mode\"]";
53 sendCommand(COMMAND_SET_DEROGATION, param);
54 } else if (DEROGATION_HEATING_MODE.equals(channelUID.getId())) {
55 switch (command.toString()) {
57 sendCommand("exitDerogation");
62 case "frostprotection":
63 String param = "[\"" + command.toString() + "\", \"next_mode\"]";
64 sendCommand(COMMAND_SET_DEROGATION, param);