]> git.basschouten.com Git - openhab-addons.git/blob
36488083b2b82603c5cbfdd2bb95c0299f99e772
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 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     }
43
44     @Override
45     public void handleCommand(ChannelUID channelUID, Command command) {
46         super.handleCommand(channelUID, command);
47         if (command instanceof RefreshType) {
48             return;
49         } else {
50             if (command instanceof StringType) {
51                 switch (channelUID.getId()) {
52                     case ZONE_MODE:
53                         sendCommand("setAutoManuMode", "[\"" + command + "\"]");
54                         break;
55                     case CIRCUIT_CONTROL:
56                         sendCommand("setControlCircuit1", "[\"" + command + "\"]");
57                         break;
58                     case YUTAKI_TARGET_MODE:
59                         sendCommand("setTargetMode", "[\"" + command + "\"]");
60                         break;
61                     case HOLIDAY_MODE:
62                         sendCommand("setHolidayMode", "[\"" + command + "\"]");
63                         break;
64                     default:
65                         getLogger().debug("This channel doesn't accept any commands");
66                 }
67             } else {
68                 getLogger().debug("This thing accepts only String commands");
69             }
70         }
71     }
72 }