2 * Copyright (c) 2010-2023 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.modbus.studer.internal;
15 import static org.openhab.core.library.unit.MetricPrefix.KILO;
16 import static org.openhab.core.library.unit.SIUnits.CELSIUS;
17 import static org.openhab.core.library.unit.Units.*;
19 import java.util.HashMap;
20 import java.util.HashSet;
24 import javax.measure.Unit;
26 import org.eclipse.jdt.annotation.NonNullByDefault;
27 import org.openhab.binding.modbus.ModbusBindingConstants;
28 import org.openhab.core.thing.ThingTypeUID;
31 * The {@link StuderBindingConstants} class defines common constants, which are
32 * used across the whole binding.
34 * @author Giovanni Mirulla - Initial contribution
37 public class StuderBindingConstants {
39 private static final String BINDING_ID = ModbusBindingConstants.BINDING_ID;
41 // List of all Thing Type UIDs
42 public static final ThingTypeUID THING_TYPE_BSP = new ThingTypeUID(BINDING_ID, "bsp");
43 public static final ThingTypeUID THING_TYPE_XTENDER = new ThingTypeUID(BINDING_ID, "xtender");
44 public static final ThingTypeUID THING_TYPE_VARIOTRACK = new ThingTypeUID(BINDING_ID, "variotrack");
45 public static final ThingTypeUID THING_TYPE_VARIOSTRING = new ThingTypeUID(BINDING_ID, "variostring");
47 public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = new HashSet<>();
49 SUPPORTED_THING_TYPES_UIDS.add(THING_TYPE_BSP);
50 SUPPORTED_THING_TYPES_UIDS.add(THING_TYPE_XTENDER);
51 SUPPORTED_THING_TYPES_UIDS.add(THING_TYPE_VARIOTRACK);
52 SUPPORTED_THING_TYPES_UIDS.add(THING_TYPE_VARIOSTRING);
55 // List of all Channel ids
56 public static final String CHANNEL_POWER = "power";
57 public static final String CHANNEL_BATTERY_VOLTAGE = "batteryVoltage";
58 public static final String CHANNEL_BATTERY_CURRENT = "batteryCurrent";
59 public static final String CHANNEL_STATE_OF_CHARGE = "stateOfCharge";
60 public static final String CHANNEL_BATTERY_TEMPERATURE = "batteryTemperature";
62 public static final String CHANNEL_INPUT_VOLTAGE = "inputVoltage";
63 public static final String CHANNEL_INPUT_CURRENT = "inputCurrent";
64 public static final String CHANNEL_INPUT_ACTIVE_POWER = "inputActivePower";
65 public static final String CHANNEL_INPUT_FREQUENCY = "inputFrequency";
66 public static final String CHANNEL_OUTPUT_VOLTAGE = "outputVoltage";
67 public static final String CHANNEL_OUTPUT_CURRENT = "outputCurrent";
68 public static final String CHANNEL_OUTPUT_ACTIVE_POWER = "outputActivePower";
69 public static final String CHANNEL_OUTPUT_FREQUENCY = "outputFrequency";
70 public static final String CHANNEL_OPERATING_STATE = "operatingState";
71 public static final String CHANNEL_STATE_INVERTER = "stateInverter";
73 public static final String CHANNEL_MODEL_VARIOTRACK = "modelVarioTrack";
74 public static final String CHANNEL_VOLTAGE_PV_GENERATOR = "voltagePVGenerator";
75 public static final String CHANNEL_POWER_PV_GENERATOR = "powerPVGenerator";
76 public static final String CHANNEL_PRODUCTION_CURRENT_DAY = "productionCurrentDay";
77 public static final String CHANNEL_OPERATING_MODE = "operatingMode";
78 public static final String CHANNEL_STATE_VARIOTRACK = "stateVarioTrack";
80 public static final String CHANNEL_PV_VOLTAGE = "PVVoltage";
81 public static final String CHANNEL_PV_CURRENT = "PVCurrent";
82 public static final String CHANNEL_PV_POWER = "PVPower";
83 public static final String CHANNEL_PRODUCTION_PV_CURRENT_DAY = "ProductionPVCurrentDay";
84 public static final String CHANNEL_PV_OPERATING_MODE = "PVMode";
85 public static final String CHANNEL_PV1_VOLTAGE = "PV1Voltage";
86 public static final String CHANNEL_PV1_CURRENT = "PV1Current";
87 public static final String CHANNEL_PV1_POWER = "PV1Power";
88 public static final String CHANNEL_PRODUCTION_PV1_CURRENT_DAY = "ProductionPV1CurrentDay";
89 public static final String CHANNEL_PV1_OPERATING_MODE = "PV1Mode";
90 public static final String CHANNEL_PV2_VOLTAGE = "PV2Voltage";
91 public static final String CHANNEL_PV2_CURRENT = "PV2Current";
92 public static final String CHANNEL_PV2_POWER = "PV2Power";
93 public static final String CHANNEL_PRODUCTION_PV2_CURRENT_DAY = "ProductionPV2CurrentDay";
94 public static final String CHANNEL_PV2_OPERATING_MODE = "PV2Mode";
95 public static final String CHANNEL_STATE_VARIOSTRING = "stateVarioString";
98 * Map of the supported BSP channel with their registers
100 public static final Map<Integer, String> CHANNELS_BSP = new HashMap<>();
102 CHANNELS_BSP.put(6, CHANNEL_POWER);
103 CHANNELS_BSP.put(0, CHANNEL_BATTERY_VOLTAGE);
104 CHANNELS_BSP.put(2, CHANNEL_BATTERY_CURRENT);
105 CHANNELS_BSP.put(4, CHANNEL_STATE_OF_CHARGE);
106 CHANNELS_BSP.put(58, CHANNEL_BATTERY_TEMPERATURE);
110 * Map of the supported BSP channel with their unit
112 public static final Map<Integer, Unit<?>> UNIT_CHANNELS_BSP = new HashMap<>();
114 UNIT_CHANNELS_BSP.put(6, WATT);
115 UNIT_CHANNELS_BSP.put(0, VOLT);
116 UNIT_CHANNELS_BSP.put(2, AMPERE);
117 UNIT_CHANNELS_BSP.put(4, PERCENT);
118 UNIT_CHANNELS_BSP.put(58, CELSIUS);
122 * Map of the supported Xtender channel with their registers
124 public static final Map<Integer, String> CHANNELS_XTENDER = new HashMap<>();
126 CHANNELS_XTENDER.put(22, CHANNEL_INPUT_VOLTAGE);
127 CHANNELS_XTENDER.put(24, CHANNEL_INPUT_CURRENT);
128 CHANNELS_XTENDER.put(274, CHANNEL_INPUT_ACTIVE_POWER);
129 CHANNELS_XTENDER.put(168, CHANNEL_INPUT_FREQUENCY);
130 CHANNELS_XTENDER.put(42, CHANNEL_OUTPUT_VOLTAGE);
131 CHANNELS_XTENDER.put(44, CHANNEL_OUTPUT_CURRENT);
132 CHANNELS_XTENDER.put(272, CHANNEL_OUTPUT_ACTIVE_POWER);
133 CHANNELS_XTENDER.put(170, CHANNEL_OUTPUT_FREQUENCY);
134 CHANNELS_XTENDER.put(56, CHANNEL_OPERATING_STATE);
135 CHANNELS_XTENDER.put(98, CHANNEL_STATE_INVERTER);
139 * Map of the supported Xtender channel with their unit
141 public static final Map<Integer, Unit<?>> UNIT_CHANNELS_XTENDER = new HashMap<>();
143 UNIT_CHANNELS_XTENDER.put(22, VOLT);
144 UNIT_CHANNELS_XTENDER.put(24, AMPERE);
145 UNIT_CHANNELS_XTENDER.put(274, KILO(WATT));
146 UNIT_CHANNELS_XTENDER.put(168, HERTZ);
147 UNIT_CHANNELS_XTENDER.put(42, VOLT);
148 UNIT_CHANNELS_XTENDER.put(44, AMPERE);
149 UNIT_CHANNELS_XTENDER.put(272, KILO(WATT));
150 UNIT_CHANNELS_XTENDER.put(170, HERTZ);
154 * Map of the supported VarioTrack channel with their registers
156 public static final Map<Integer, String> CHANNELS_VARIOTRACK = new HashMap<>();
158 CHANNELS_VARIOTRACK.put(30, CHANNEL_MODEL_VARIOTRACK);
159 CHANNELS_VARIOTRACK.put(4, CHANNEL_VOLTAGE_PV_GENERATOR);
160 CHANNELS_VARIOTRACK.put(8, CHANNEL_POWER_PV_GENERATOR);
161 CHANNELS_VARIOTRACK.put(14, CHANNEL_PRODUCTION_CURRENT_DAY);
162 CHANNELS_VARIOTRACK.put(0, CHANNEL_BATTERY_VOLTAGE);
163 CHANNELS_VARIOTRACK.put(2, CHANNEL_BATTERY_CURRENT);
164 CHANNELS_VARIOTRACK.put(32, CHANNEL_OPERATING_MODE);
165 CHANNELS_VARIOTRACK.put(138, CHANNEL_STATE_VARIOTRACK);
169 * Map of the supported VarioTrack channel with their unit
171 public static final Map<Integer, Unit<?>> UNIT_CHANNELS_VARIOTRACK = new HashMap<>();
173 UNIT_CHANNELS_VARIOTRACK.put(4, VOLT);
174 UNIT_CHANNELS_VARIOTRACK.put(8, KILO(WATT));
175 UNIT_CHANNELS_VARIOTRACK.put(14, KILOWATT_HOUR);
176 UNIT_CHANNELS_VARIOTRACK.put(0, VOLT);
177 UNIT_CHANNELS_VARIOTRACK.put(2, AMPERE);
181 * Map of the supported VarioString channel with their registers
183 public static final Map<Integer, String> CHANNELS_VARIOSTRING = new HashMap<>();
185 CHANNELS_VARIOSTRING.put(0, CHANNEL_BATTERY_VOLTAGE);
186 CHANNELS_VARIOSTRING.put(2, CHANNEL_BATTERY_CURRENT);
187 CHANNELS_VARIOSTRING.put(8, CHANNEL_PV_VOLTAGE);
188 CHANNELS_VARIOSTRING.put(14, CHANNEL_PV_CURRENT);
189 CHANNELS_VARIOSTRING.put(20, CHANNEL_PV_POWER);
190 CHANNELS_VARIOSTRING.put(34, CHANNEL_PRODUCTION_PV_CURRENT_DAY);
191 CHANNELS_VARIOSTRING.put(26, CHANNEL_PV_OPERATING_MODE);
192 CHANNELS_VARIOSTRING.put(10, CHANNEL_PV1_VOLTAGE);
193 CHANNELS_VARIOSTRING.put(16, CHANNEL_PV1_CURRENT);
194 CHANNELS_VARIOSTRING.put(22, CHANNEL_PV1_POWER);
195 CHANNELS_VARIOSTRING.put(36, CHANNEL_PRODUCTION_PV1_CURRENT_DAY);
196 CHANNELS_VARIOSTRING.put(28, CHANNEL_PV1_OPERATING_MODE);
197 CHANNELS_VARIOSTRING.put(12, CHANNEL_PV2_VOLTAGE);
198 CHANNELS_VARIOSTRING.put(18, CHANNEL_PV2_CURRENT);
199 CHANNELS_VARIOSTRING.put(24, CHANNEL_PV2_POWER);
200 CHANNELS_VARIOSTRING.put(38, CHANNEL_PRODUCTION_PV2_CURRENT_DAY);
201 CHANNELS_VARIOSTRING.put(30, CHANNEL_PV2_OPERATING_MODE);
202 CHANNELS_VARIOSTRING.put(216, CHANNEL_STATE_VARIOSTRING);
206 * Map of the supported VarioString channel with their unit
208 public static final Map<Integer, Unit<?>> UNIT_CHANNELS_VARIOSTRING = new HashMap<>();
210 UNIT_CHANNELS_VARIOSTRING.put(0, VOLT);
211 UNIT_CHANNELS_VARIOSTRING.put(2, AMPERE);
212 UNIT_CHANNELS_VARIOSTRING.put(8, VOLT);
213 UNIT_CHANNELS_VARIOSTRING.put(14, AMPERE);
214 UNIT_CHANNELS_VARIOSTRING.put(20, KILO(WATT));
215 UNIT_CHANNELS_VARIOSTRING.put(34, KILOWATT_HOUR);
216 UNIT_CHANNELS_VARIOSTRING.put(10, VOLT);
217 UNIT_CHANNELS_VARIOSTRING.put(16, AMPERE);
218 UNIT_CHANNELS_VARIOSTRING.put(22, KILO(WATT));
219 UNIT_CHANNELS_VARIOSTRING.put(36, KILOWATT_HOUR);
220 UNIT_CHANNELS_VARIOSTRING.put(12, VOLT);
221 UNIT_CHANNELS_VARIOSTRING.put(18, AMPERE);
222 UNIT_CHANNELS_VARIOSTRING.put(24, KILO(WATT));
223 UNIT_CHANNELS_VARIOSTRING.put(38, KILOWATT_HOUR);
226 // List of all parameters
227 public static final String SLAVE_ADDRESS = "slaveAddress";
228 public static final String REFRESH = "refresh";