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.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.StringType;
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 SomfyTahomaHitachiATWMCHandler} is responsible for handling commands,
26 * which are sent to one of the channels of the Hitachi Air To Water Main Component thing.
28 * @author Ondrej Pecta - Initial contribution
31 public class SomfyTahomaHitachiATWMCHandler extends SomfyTahomaBaseThingHandler {
33 public SomfyTahomaHitachiATWMCHandler(Thing thing) {
35 stateNames.put(AUTO_MANU_MODE, "core:AutoManuModeState");
36 stateNames.put(UNIT_CONTROL, "modbus:ControlUnitState");
37 stateNames.put(UNIT_MODE_STATUS, "modbus:StatusUnitModeState");
38 stateNames.put(UNIT_MODE_CONTROL, "modbus:ControlUnitModeState");
39 stateNames.put(BLOCK_MENU_CONTROL, "modbus:ControlBlockMenuState");
40 stateNames.put(SPACE_MODE, "modbus:SpaceModeState");
41 stateNames.put(ECO_MODE_TARGET_OFFSET, "modbus:EcoModeOffsetTargetState");
42 stateNames.put(COMM_ALARM_BIT_STATUS, "modbus:StatusCommunicationAlarmBitState");
43 stateNames.put(OPERATION, "modbus:OperationState");
44 stateNames.put(OUTDOOR_TEMP, "modbus:OutdoorAmbientTemperatureState");
45 stateNames.put(WATER_INLET_TEMP, "modbus:WaterInletUnitTemperatureState");
46 stateNames.put(WATER_OUTLET_TEMP, "modbus:WaterOutletUnitTemperatureState");
47 stateNames.put(ECO_MODE_OFFSET, "modbus:EcoModeOffsetState");
48 stateNames.put(WATER_OUTLET_HP_TEMP, "modbus:WaterOutletHpTemperatureState");
49 stateNames.put(LIQUID_TEMP_THMI, "modbus:LiquidTemperatureTHMIState");
50 stateNames.put(LIQUID_TEMP, "modbus:LiquidTemperatureState");
51 stateNames.put(COMPRESSOR_RUNNING_CURRENT, "modbus:CompressorRunningCurrentState");
52 // override state type because the cloud sends consumption in percent
53 cacheStateType(COMPRESSOR_RUNNING_CURRENT, TYPE_DECIMAL);
54 stateNames.put(WATER_TEMP_SETTING, "modbus:WaterTemperatureSettingState");
55 stateNames.put(YUTAKI_OPERATING_MODE, "modbus:YutakiVirtualOperatingModeState");
56 stateNames.put(ALARM_NUMBER, "modbus:AlarmNumberState");
60 public void handleCommand(ChannelUID channelUID, Command command) {
61 super.handleCommand(channelUID, command);
62 if (command instanceof RefreshType) {
65 switch (channelUID.getId()) {
67 if (command instanceof StringType) {
68 sendCommand("setGlobalAutoManuMode", "[\"" + command + "\"]");
72 if (command instanceof StringType) {
73 sendCommand("setControlUnit", "[\"" + command + "\"]");
76 case UNIT_MODE_CONTROL:
77 if (command instanceof StringType) {
78 sendCommand("setControlUnitMode", "[\"" + command + "\"]");
81 case BLOCK_MENU_CONTROL:
82 if (command instanceof StringType) {
83 sendCommand("setControlBlockMenu", "[\"" + command + "\"]");
87 if (command instanceof StringType) {
88 sendCommand("setSpaceMode", "[\"" + command + "\"]");
91 case ECO_MODE_TARGET_OFFSET:
92 sendTempCommand("setEcoModeOffset", command);
95 getLogger().debug("This channel doesn't accept any commands");