]> git.basschouten.com Git - openhab-addons.git/blob
b6bcfd202749dd17da942bd4d882419471f0e3e4
[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 SomfyTahomaHitachiATWHZHandler} is responsible for handling commands,
26  * which are sent to one of the channels of the Hitachi Air To Water Heating Zone thing.
27  *
28  * @author Ondrej Pecta - Initial contribution
29  */
30 @NonNullByDefault
31 public class SomfyTahomaHitachiATWHZHandler extends SomfyTahomaBaseThingHandler {
32
33     public SomfyTahomaHitachiATWHZHandler(Thing thing) {
34         super(thing);
35         stateNames.put(ZONE_MODE, "modbus:AutoManuModeZone1State");
36         stateNames.put(CIRCUIT_CONTROL, "modbus:ControlCircuit1State");
37         stateNames.put(CIRCUIT_STATUS, "modbus:StatusCircuit1State");
38         stateNames.put(YUTAKI_TARGET_MODE, "modbus:YutakiTargetModeState");
39         stateNames.put(YUTAKI_MODE, "modbus:YutakiModeState");
40         stateNames.put(HOLIDAY_MODE, "modbus:HolidayModeZone1State");
41         stateNames.put(ALARM_NUMBER, "modbus:AlarmNumberState");
42         stateNames.put(THERMOSTAT_SETTING_ZONE1, "modbus:ThermostatSettingStatusZone1State");
43         stateNames.put(WH_SETTING_TEMP_ZONE1, "modbus:WaterHeatingSettingTemperatureStatusZone1State");
44         stateNames.put(ROOM_AMBIENT_TEMP_ZONE1, "modbus:RoomAmbientTemperatureStatusZone1State");
45     }
46
47     @Override
48     public void handleCommand(ChannelUID channelUID, Command command) {
49         super.handleCommand(channelUID, command);
50         if (command instanceof RefreshType) {
51             return;
52         } else {
53             switch (channelUID.getId()) {
54                 case ZONE_MODE:
55                     if (command instanceof StringType) {
56                         sendCommand("setAutoManuMode", "[\"" + command + "\"]");
57                     }
58                     break;
59                 case CIRCUIT_CONTROL:
60                     if (command instanceof StringType) {
61                         sendCommand("setControlCircuit1", "[\"" + command + "\"]");
62                     }
63                     break;
64                 case YUTAKI_TARGET_MODE:
65                     if (command instanceof StringType) {
66                         sendCommand("setTargetMode", "[\"" + command + "\"]");
67                     }
68                     break;
69                 case HOLIDAY_MODE:
70                     if (command instanceof StringType) {
71                         sendCommand("setHolidayMode", "[\"" + command + "\"]");
72                     }
73                     break;
74                 case THERMOSTAT_SETTING_ZONE1:
75                     sendTempCommand("setThermostatSettingControlZone1", command);
76                     break;
77                 case WH_SETTING_TEMP_ZONE1:
78                     sendTempCommand("setWaterHeatingSettingTemperatureControlZone1", command);
79                     break;
80                 case ROOM_AMBIENT_TEMP_ZONE1:
81                     sendTempCommand("setRoomAmbientTemperatureControlZone1", command);
82                     break;
83                 default:
84                     getLogger().debug("This channel doesn't accept any commands");
85             }
86         }
87     }
88 }