]> git.basschouten.com Git - openhab-addons.git/blob
186a1486da759f90d8b6236a3ab13b416ae0a38c
[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.draytonwiser.internal;
14
15 import java.util.Set;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19 import org.openhab.core.library.types.DecimalType;
20 import org.openhab.core.thing.ThingTypeUID;
21 import org.openhab.core.types.State;
22 import org.openhab.core.types.UnDefType;
23
24 /**
25  * The {@link DraytonWiserBindingConstants} class defines common constants, which are
26  * used across the whole binding.
27  *
28  * @author Andrew Schofield - Initial contribution
29  */
30 @NonNullByDefault
31 public class DraytonWiserBindingConstants {
32
33     public static final String BINDING_ID = "draytonwiser";
34
35     public static final String REFRESH_INTERVAL = "refresh";
36     public static final int DEFAULT_REFRESH_SECONDS = 60;
37
38     public static final int OFFLINE_TEMPERATURE = -32768;
39
40     // Web Service Endpoints
41     public static final String DEVICE_ENDPOINT = "data/domain/Device/";
42     public static final String ROOMSTATS_ENDPOINT = "data/domain/RoomStat/";
43     public static final String TRVS_ENDPOINT = "data/domain/SmartValve/";
44     public static final String ROOMS_ENDPOINT = "data/domain/Room/";
45     public static final String HEATCHANNELS_ENDPOINT = "data/domain/HeatingChannel/";
46     public static final String SYSTEM_ENDPOINT = "data/domain/System/";
47     public static final String STATION_ENDPOINT = "data/network/Station/";
48     public static final String DOMAIN_ENDPOINT = "data/domain/";
49     public static final String HOTWATER_ENDPOINT = "data/domain/HotWater/";
50     public static final String SMARTPLUG_ENDPOINT = "data/domain/SmartPlug/";
51
52     // bridge
53     public static final ThingTypeUID THING_TYPE_BRIDGE = new ThingTypeUID(BINDING_ID, "heathub");
54
55     // List of all Thing Type UIDs
56     public static final ThingTypeUID THING_TYPE_CONTROLLER = new ThingTypeUID(BINDING_ID, "boiler-controller");
57     public static final ThingTypeUID THING_TYPE_ROOM = new ThingTypeUID(BINDING_ID, "room");
58     public static final ThingTypeUID THING_TYPE_ROOMSTAT = new ThingTypeUID(BINDING_ID, "roomstat");
59     public static final ThingTypeUID THING_TYPE_ITRV = new ThingTypeUID(BINDING_ID, "itrv");
60     public static final ThingTypeUID THING_TYPE_HOTWATER = new ThingTypeUID(BINDING_ID, "hotwater");
61     public static final ThingTypeUID THING_TYPE_SMARTPLUG = new ThingTypeUID(BINDING_ID, "smart-plug");
62
63     // properties
64     public static final String PROP_ADDRESS = "networkAddress";
65     public static final String PROP_SERIAL_NUMBER = "serialNumber";
66     public static final String PROP_NAME = "name";
67     public static final String PROP_ID = "id";
68
69     // List of all Channel ids
70     public static final String CHANNEL_CURRENT_TEMPERATURE = "currentTemperature";
71     public static final String CHANNEL_CURRENT_HUMIDITY = "currentHumidity";
72     public static final String CHANNEL_CURRENT_SETPOINT = "currentSetPoint";
73     public static final String CHANNEL_CURRENT_BATTERY_VOLTAGE = "currentBatteryVoltage";
74     public static final String CHANNEL_CURRENT_BATTERY_LEVEL = "currentBatteryLevel";
75     public static final String CHANNEL_CURRENT_WISER_BATTERY_LEVEL = "currentWiserBatteryLevel";
76     public static final String CHANNEL_CURRENT_DEMAND = "currentDemand";
77     public static final String CHANNEL_HEAT_REQUEST = "heatRequest";
78     public static final String CHANNEL_CURRENT_SIGNAL_RSSI = "currentSignalRSSI";
79     public static final String CHANNEL_CURRENT_SIGNAL_LQI = "currentSignalLQI";
80     public static final String CHANNEL_CURRENT_SIGNAL_STRENGTH = "currentSignalStrength";
81     public static final String CHANNEL_CURRENT_WISER_SIGNAL_STRENGTH = "currentWiserSignalStrength";
82     public static final String CHANNEL_HEATING_OVERRIDE = "heatingOverride";
83     public static final String CHANNEL_HOT_WATER_OVERRIDE = "hotWaterOverride";
84     public static final String CHANNEL_HEATCHANNEL_1_DEMAND = "heatChannel1Demand";
85     public static final String CHANNEL_HEATCHANNEL_2_DEMAND = "heatChannel2Demand";
86     public static final String CHANNEL_HEATCHANNEL_1_DEMAND_STATE = "heatChannel1DemandState";
87     public static final String CHANNEL_HEATCHANNEL_2_DEMAND_STATE = "heatChannel2DemandState";
88     public static final String CHANNEL_HOTWATER_DEMAND_STATE = "hotWaterDemandState";
89     public static final String CHANNEL_AWAY_MODE_STATE = "awayModeState";
90     public static final String CHANNEL_ECO_MODE_STATE = "ecoModeState";
91     public static final String CHANNEL_MANUAL_MODE_STATE = "manualModeState";
92     public static final String CHANNEL_ZIGBEE_CONNECTED = "zigbeeConnected";
93     public static final String CHANNEL_HOT_WATER_SETPOINT = "hotWaterSetPoint";
94     public static final String CHANNEL_HOT_WATER_BOOST_DURATION = "hotWaterBoostDuration";
95     public static final String CHANNEL_HOT_WATER_BOOSTED = "hotWaterBoosted";
96     public static final String CHANNEL_HOT_WATER_BOOST_REMAINING = "hotWaterBoostRemaining";
97     public static final String CHANNEL_ROOM_BOOST_DURATION = "roomBoostDuration";
98     public static final String CHANNEL_ROOM_BOOSTED = "roomBoosted";
99     public static final String CHANNEL_ROOM_BOOST_REMAINING = "roomBoostRemaining";
100     public static final String CHANNEL_ROOM_WINDOW_STATE_DETECTION = "windowStateDetection";
101     public static final String CHANNEL_ROOM_WINDOW_STATE = "windowState";
102     public static final String CHANNEL_DEVICE_LOCKED = "deviceLocked";
103     public static final String CHANNEL_SMARTPLUG_OUTPUT_STATE = "plugOutputState";
104     public static final String CHANNEL_SMARTPLUG_AWAY_ACTION = "plugAwayAction";
105     public static final String CHANNEL_COMFORT_MODE_STATE = "comfortModeState";
106     public static final String CHANNEL_SMARTPLUG_INSTANTANEOUS_POWER = "plugInstantaneousPower";
107     public static final String CHANNEL_SMARTPLUG_ENERGY_DELIVERED = "plugEnergyDelivered";
108
109     public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_CONTROLLER, THING_TYPE_ROOM,
110             THING_TYPE_ROOMSTAT, THING_TYPE_BRIDGE, THING_TYPE_ITRV, THING_TYPE_HOTWATER, THING_TYPE_SMARTPLUG);
111
112     // Lookups from text representations to useful values
113
114     public enum SignalStrength {
115         VERYGOOD(4),
116         GOOD(3),
117         MEDIUM(2),
118         POOR(1),
119         NOSIGNAL(0);
120
121         private final int signalStrength;
122
123         SignalStrength(final int signalStrength) {
124             this.signalStrength = signalStrength;
125         }
126
127         public static State toSignalStrength(final String strength) {
128             try {
129                 return new DecimalType(SignalStrength.valueOf(strength.toUpperCase()).signalStrength);
130             } catch (final IllegalArgumentException e) {
131                 // Catch unrecognized values.
132                 return UnDefType.UNDEF;
133             }
134         }
135     }
136
137     public enum BatteryLevel {
138         FULL(100),
139         NORMAL(80),
140         TWOTHIRDS(60),
141         ONETHIRD(40),
142         LOW(20),
143         CRITICAL(0);
144
145         private final int batteryLevel;
146
147         private BatteryLevel(final int batteryLevel) {
148             this.batteryLevel = batteryLevel;
149         }
150
151         public static State toBatteryLevel(final @Nullable String level) {
152             if (level != null) {
153                 try {
154                     return new DecimalType(BatteryLevel.valueOf(level.toUpperCase()).batteryLevel);
155                 } catch (final IllegalArgumentException e) {
156                     // Catch unrecognized values.
157                     return UnDefType.UNDEF;
158                 }
159             } else {
160                 return UnDefType.UNDEF;
161             }
162         }
163     }
164 }