]> git.basschouten.com Git - openhab-addons.git/blob
91b48e359459fd5776d75d11dfbe742eb7c79c43
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.somfytahoma.internal.handler;
14
15 import static org.openhab.binding.somfytahoma.internal.SomfyTahomaBindingConstants.*;
16
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;
23
24 /**
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.
27  *
28  * @author Ondrej Pecta - Initial contribution
29  */
30 @NonNullByDefault
31 public class SomfyTahomaHitachiATWMCHandler extends SomfyTahomaBaseThingHandler {
32
33     public SomfyTahomaHitachiATWMCHandler(Thing thing) {
34         super(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");
57     }
58
59     @Override
60     public void handleCommand(ChannelUID channelUID, Command command) {
61         super.handleCommand(channelUID, command);
62         if (command instanceof RefreshType) {
63             return;
64         } else {
65             switch (channelUID.getId()) {
66                 case AUTO_MANU_MODE:
67                     if (command instanceof StringType) {
68                         sendCommand("setGlobalAutoManuMode", "[\"" + command + "\"]");
69                     }
70                     break;
71                 case UNIT_CONTROL:
72                     if (command instanceof StringType) {
73                         sendCommand("setControlUnit", "[\"" + command + "\"]");
74                     }
75                     break;
76                 case UNIT_MODE_CONTROL:
77                     if (command instanceof StringType) {
78                         sendCommand("setControlUnitMode", "[\"" + command + "\"]");
79                     }
80                     break;
81                 case BLOCK_MENU_CONTROL:
82                     if (command instanceof StringType) {
83                         sendCommand("setControlBlockMenu", "[\"" + command + "\"]");
84                     }
85                     break;
86                 case SPACE_MODE:
87                     if (command instanceof StringType) {
88                         sendCommand("setSpaceMode", "[\"" + command + "\"]");
89                     }
90                     break;
91                 case ECO_MODE_TARGET_OFFSET:
92                     sendTempCommand("setEcoModeOffset", command);
93                     break;
94                 default:
95                     getLogger().debug("This channel doesn't accept any commands");
96             }
97         }
98     }
99 }