2 * Copyright (c) 2010-2020 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.draytonwiser.internal;
15 import java.util.Arrays;
16 import java.util.Collections;
17 import java.util.HashSet;
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.openhab.core.library.types.DecimalType;
22 import org.openhab.core.thing.ThingTypeUID;
23 import org.openhab.core.types.State;
24 import org.openhab.core.types.UnDefType;
27 * The {@link DraytonWiserBindingConstants} class defines common constants, which are
28 * used across the whole binding.
30 * @author Andrew Schofield - Initial contribution
33 public class DraytonWiserBindingConstants {
35 public static final String BINDING_ID = "draytonwiser";
37 public static final String REFRESH_INTERVAL = "refresh";
38 public static final int DEFAULT_REFRESH_SECONDS = 60;
40 public static final int OFFLINE_TEMPERATURE = -32768;
42 // Web Service Endpoints
43 public static final String DEVICE_ENDPOINT = "data/domain/Device/";
44 public static final String ROOMSTATS_ENDPOINT = "data/domain/RoomStat/";
45 public static final String TRVS_ENDPOINT = "data/domain/SmartValve/";
46 public static final String ROOMS_ENDPOINT = "data/domain/Room/";
47 public static final String HEATCHANNELS_ENDPOINT = "data/domain/HeatingChannel/";
48 public static final String SYSTEM_ENDPOINT = "data/domain/System/";
49 public static final String STATION_ENDPOINT = "data/network/Station/";
50 public static final String DOMAIN_ENDPOINT = "data/domain/";
51 public static final String HOTWATER_ENDPOINT = "data/domain/HotWater/";
52 public static final String SMARTPLUG_ENDPOINT = "data/domain/SmartPlug/";
55 public static final ThingTypeUID THING_TYPE_BRIDGE = new ThingTypeUID(BINDING_ID, "heathub");
57 // List of all Thing Type UIDs
58 public static final ThingTypeUID THING_TYPE_CONTROLLER = new ThingTypeUID(BINDING_ID, "boiler-controller");
59 public static final ThingTypeUID THING_TYPE_ROOM = new ThingTypeUID(BINDING_ID, "room");
60 public static final ThingTypeUID THING_TYPE_ROOMSTAT = new ThingTypeUID(BINDING_ID, "roomstat");
61 public static final ThingTypeUID THING_TYPE_ITRV = new ThingTypeUID(BINDING_ID, "itrv");
62 public static final ThingTypeUID THING_TYPE_HOTWATER = new ThingTypeUID(BINDING_ID, "hotwater");
63 public static final ThingTypeUID THING_TYPE_SMARTPLUG = new ThingTypeUID(BINDING_ID, "smart-plug");
66 public static final String PROP_ADDRESS = "networkAddress";
67 public static final String PROP_SERIAL_NUMBER = "serialNumber";
68 public static final String PROP_NAME = "name";
69 public static final String PROP_ID = "id";
71 // List of all Channel ids
72 public static final String CHANNEL_CURRENT_TEMPERATURE = "currentTemperature";
73 public static final String CHANNEL_CURRENT_HUMIDITY = "currentHumidity";
74 public static final String CHANNEL_CURRENT_SETPOINT = "currentSetPoint";
75 public static final String CHANNEL_CURRENT_BATTERY_VOLTAGE = "currentBatteryVoltage";
76 public static final String CHANNEL_CURRENT_BATTERY_LEVEL = "currentBatteryLevel";
77 public static final String CHANNEL_CURRENT_WISER_BATTERY_LEVEL = "currentWiserBatteryLevel";
78 public static final String CHANNEL_CURRENT_DEMAND = "currentDemand";
79 public static final String CHANNEL_HEAT_REQUEST = "heatRequest";
80 public static final String CHANNEL_CURRENT_SIGNAL_RSSI = "currentSignalRSSI";
81 public static final String CHANNEL_CURRENT_SIGNAL_LQI = "currentSignalLQI";
82 public static final String CHANNEL_CURRENT_SIGNAL_STRENGTH = "currentSignalStrength";
83 public static final String CHANNEL_CURRENT_WISER_SIGNAL_STRENGTH = "currentWiserSignalStrength";
84 public static final String CHANNEL_HEATING_OVERRIDE = "heatingOverride";
85 public static final String CHANNEL_HOT_WATER_OVERRIDE = "hotWaterOverride";
86 public static final String CHANNEL_HEATCHANNEL_1_DEMAND = "heatChannel1Demand";
87 public static final String CHANNEL_HEATCHANNEL_2_DEMAND = "heatChannel2Demand";
88 public static final String CHANNEL_HEATCHANNEL_1_DEMAND_STATE = "heatChannel1DemandState";
89 public static final String CHANNEL_HEATCHANNEL_2_DEMAND_STATE = "heatChannel2DemandState";
90 public static final String CHANNEL_HOTWATER_DEMAND_STATE = "hotWaterDemandState";
91 public static final String CHANNEL_AWAY_MODE_STATE = "awayModeState";
92 public static final String CHANNEL_ECO_MODE_STATE = "ecoModeState";
93 public static final String CHANNEL_MANUAL_MODE_STATE = "manualModeState";
94 public static final String CHANNEL_ZIGBEE_CONNECTED = "zigbeeConnected";
95 public static final String CHANNEL_HOT_WATER_SETPOINT = "hotWaterSetPoint";
96 public static final String CHANNEL_HOT_WATER_BOOST_DURATION = "hotWaterBoostDuration";
97 public static final String CHANNEL_HOT_WATER_BOOSTED = "hotWaterBoosted";
98 public static final String CHANNEL_HOT_WATER_BOOST_REMAINING = "hotWaterBoostRemaining";
99 public static final String CHANNEL_ROOM_BOOST_DURATION = "roomBoostDuration";
100 public static final String CHANNEL_ROOM_BOOSTED = "roomBoosted";
101 public static final String CHANNEL_ROOM_BOOST_REMAINING = "roomBoostRemaining";
102 public static final String CHANNEL_ROOM_WINDOW_STATE_DETECTION = "windowStateDetection";
103 public static final String CHANNEL_ROOM_WINDOW_STATE = "windowState";
104 public static final String CHANNEL_DEVICE_LOCKED = "deviceLocked";
105 public static final String CHANNEL_SMARTPLUG_OUTPUT_STATE = "plugOutputState";
106 public static final String CHANNEL_SMARTPLUG_AWAY_ACTION = "plugAwayAction";
107 public static final String CHANNEL_COMFORT_MODE_STATE = "comfortModeState";
109 public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections
110 .unmodifiableSet(new HashSet<>(Arrays.asList(THING_TYPE_CONTROLLER, THING_TYPE_ROOM, THING_TYPE_ROOMSTAT,
111 THING_TYPE_BRIDGE, THING_TYPE_ITRV, THING_TYPE_HOTWATER, THING_TYPE_SMARTPLUG)));
113 // Lookups from text representations to useful values
115 public enum SignalStrength {
122 private final int signalStrength;
124 SignalStrength(final int signalStrength) {
125 this.signalStrength = signalStrength;
128 public static State toSignalStrength(final String strength) {
130 return new DecimalType(SignalStrength.valueOf(strength.toUpperCase()).signalStrength);
131 } catch (final IllegalArgumentException e) {
132 // Catch unrecognized values.
133 return UnDefType.UNDEF;
138 public enum BatteryLevel {
146 private final int batteryLevel;
148 private BatteryLevel(final int batteryLevel) {
149 this.batteryLevel = batteryLevel;
152 public static State toBatteryLevel(final String level) {
154 return new DecimalType(BatteryLevel.valueOf(level.toUpperCase()).batteryLevel);
155 } catch (final IllegalArgumentException e) {
156 // Catch unrecognized values.
157 return UnDefType.UNDEF;