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.ecotouch.internal;
15 import static org.openhab.core.library.unit.MetricPrefix.*;
16 import static org.openhab.core.library.unit.SIUnits.*;
17 import static org.openhab.core.library.unit.Units.*;
19 import java.math.BigDecimal;
20 import java.util.LinkedList;
21 import java.util.List;
23 import javax.measure.Unit;
25 import org.eclipse.jdt.annotation.NonNullByDefault;
26 import org.eclipse.jdt.annotation.Nullable;
29 * Represents all valid commands which could be processed by this binding
31 * @author Sebastian Held - Initial contribution
35 public enum EcoTouchTags {
37 // German: Außentemperatur
38 TYPE_TEMPERATURE_OUTSIDE {
40 command = "temperature_outside";
46 // German: Außentemperatur gemittelt über 1h
47 TYPE_TEMPERATURE_OUTSIDE_1H {
49 command = "temperature_outside_1h";
55 // German: Außentemperatur gemittelt über 24h
56 TYPE_TEMPERATURE_OUTSIDE_24H {
58 command = "temperature_outside_24h";
64 // German: Quelleneintrittstemperatur
65 TYPE_TEMPERATURE_SOURCE_IN {
67 command = "temperature_source_in";
73 // German: Quellenaustrittstemperatur
74 TYPE_TEMPERATURE_SOURCE_OUT {
76 command = "temperature_source_out";
82 // German: Verdampfungstemperatur
83 TYPE_TEMPERATURE_EVAPORATION {
85 command = "temperature_evaporation";
91 // German: Sauggastemperatur
92 TYPE_TEMPERATURE_SUCTION {
94 command = "temperature_suction";
100 // German: Verdampfungsdruck
101 TYPE_PRESSURE_EVAPORATION {
103 command = "pressure_evaporation";
109 // German: Temperatur Rücklauf Soll
110 TYPE_TEMPERATURE_RETURN_SET {
112 command = "temperature_return_set";
118 // German: Temperatur Rücklauf
119 TYPE_TEMPERATURE_RETURN {
121 command = "temperature_return";
127 // German: Temperatur Vorlauf
128 TYPE_TEMPERATURE_FLOW {
130 command = "temperature_flow";
136 // German: Kondensationstemperatur
137 TYPE_TEMPERATURE_CONDENSATION {
139 command = "temperature_condensation";
145 // German: Kondensationsdruck
146 TYPE_PRESSURE_CONDENSATION {
148 command = "pressure_condensation";
154 // German: Speichertemperatur
155 TYPE_TEMPERATURE_STORAGE {
157 command = "temperature_storage";
163 // German: Raumtemperatur
164 TYPE_TEMPERATURE_ROOM {
166 command = "temperature_room";
172 // German: Raumtemperatur gemittelt über 1h
173 TYPE_TEMPERATURE_ROOM_1H {
175 command = "temperature_room_1h";
181 // German: Warmwassertemperatur
182 TYPE_TEMPERATURE_WATER {
184 command = "temperature_water";
190 // German: Pooltemperatur
191 TYPE_TEMPERATURE_POOL {
193 command = "temperature_pool";
199 // German: Solarkollektortemperatur
200 TYPE_TEMPERATURE_SOLAR {
202 command = "temperature_solar";
208 // German: Solarkreis Vorlauf
209 TYPE_TEMPERATURE_SOLAR_FLOW {
211 command = "temperature_solar_flow";
217 // German: Ventilöffnung elektrisches Expansionsventil
218 TYPE_POSITION_EXPANSION_VALVE {
220 command = "position_expansion_valve";
226 // German: elektrische Leistung Verdichter
227 TYPE_POWER_COMPRESSOR {
229 command = "power_compressor";
235 // German: abgegebene thermische Heizleistung der Wärmepumpe
238 command = "power_heating";
244 // German: abgegebene thermische KälteLeistung der Wärmepumpe
247 command = "power_cooling";
253 // German: COP Heizleistung
256 command = "cop_heating";
261 // German: COP Kälteleistungleistung
264 command = "cop_cooling";
269 // German: Aktuelle Heizkreistemperatur
270 TYPE_TEMPERATURE_HEATING {
272 command = "temperature_heating_return";
278 // German: Geforderte Temperatur im Heizbetrieb
279 TYPE_TEMPERATURE_HEATING_SET {
281 command = "temperature_heating_set";
287 // German: Sollwertvorgabe Heizkreistemperatur
288 TYPE_TEMPERATURE_HEATING_SET2 {
290 command = "temperature_heating_set2";
296 // German: Aktuelle Kühlkreistemperatur
297 TYPE_TEMPERATURE_COOLING {
299 command = "temperature_cooling_return";
305 // German: Geforderte Temperatur im Kühlbetrieb
306 TYPE_TEMPERATURE_COOLING_SET {
308 command = "temperature_cooling_set";
314 // German: Sollwertvorgabe Kühlbetrieb
315 TYPE_TEMPERATURE_COOLING_SET2 {
317 command = "temperature_cooling_set2";
323 // German: Sollwert Warmwassertemperatur
324 TYPE_TEMPERATURE_WATER_SET {
326 command = "temperature_water_set";
332 // German: Sollwertvorgabe Warmwassertemperatur
333 TYPE_TEMPERATURE_WATER_SET2 {
335 command = "temperature_water_set2";
341 // German: Sollwert Poolwassertemperatur
342 TYPE_TEMPERATURE_POOL_SET {
344 command = "temperature_pool_set";
350 // German: Sollwertvorgabe Poolwassertemperatur
351 TYPE_TEMPERATURE_POOL_SET2 {
353 command = "temperature_pool_set2";
359 // German: geforderte Verdichterleistung
360 TYPE_COMPRESSOR_POWER {
362 command = "compressor_power";
368 // German: % Heizungsumwälzpumpe
369 TYPE_PERCENT_HEAT_CIRC_PUMP {
371 command = "percent_heat_circ_pump";
377 // German: % Quellenpumpe
378 TYPE_PERCENT_SOURCE_PUMP {
380 command = "percent_source_pump";
386 // German: % Leistung Verdichter
387 TYPE_PERCENT_COMPRESSOR {
389 command = "percent_compressor";
395 // German: Hysterese Heizung
396 TYPE_HYSTERESIS_HEATING {
398 command = "hysteresis_heating";
404 // German: Außentemperatur gemittelt über 1h (scheinbar identisch zu A2)
405 TYPE_TEMPERATURE2_OUTSIDE_1H {
407 command = "temperature2_outside_1h";
413 // German: Heizkurve - nviNormAussen
416 command = "nviNormAussen";
422 // German: Heizkurve - nviHeizkreisNorm
423 TYPE_NVIHEIZKREISNORM {
425 command = "nviHeizkreisNorm";
431 // German: Heizkurve - nviTHeizgrenze
432 TYPE_NVITHEIZGRENZE {
434 command = "nviTHeizgrenze";
440 // German: Heizkurve - nviTHeizgrenzeSoll
441 TYPE_NVITHEIZGRENZESOLL {
443 command = "nviTHeizgrenzeSoll";
449 // German: undokumentiert: Heizkurve max. VL-Temp (??)
452 command = "maxVLTemp";
458 // German: undokumentiert: Heizkreis Soll-Temp bei 0° Aussen
461 command = "tempSet0Deg";
470 command = "tempRoomSet";
476 // German: undokumentiert: Kühlen Einschalt-Temp. Aussentemp (??)
477 TYPE_COOLENABLETEMP {
479 command = "coolEnableTemp";
485 // German: Heizkurve - nviSollKuehlen
486 TYPE_NVITSOLLKUEHLEN {
488 command = "nviSollKuehlen";
494 // German: Temperaturveränderung Heizkreis bei PV-Ertrag
495 TYPE_TEMPCHANGE_HEATING_PV {
497 command = "tempchange_heating_pv";
503 // German: Temperaturveränderung Kühlkreis bei PV-Ertrag
504 TYPE_TEMPCHANGE_COOLING_PV {
506 command = "tempchange_cooling_pv";
512 // German: Temperaturveränderung Warmwasser bei PV-Ertrag
513 TYPE_TEMPCHANGE_WARMWATER_PV {
515 command = "tempchange_warmwater_pv";
521 // German: Temperaturveränderung Pool bei PV-Ertrag
522 TYPE_TEMPCHANGE_POOL_PV {
524 command = "tempchange_pool_pv";
530 // German: undokumentiert: Firmware-Version Regler
531 // value 10401 => 01.04.01
532 TYPE_VERSION_CONTROLLER {
534 command = "version_controller";
541 // German: undokumentiert: Firmware-Build Regler
542 TYPE_VERSION_CONTROLLER_BUILD {
544 command = "version_controller_build";
551 // German: undokumentiert: BIOS-Version
552 // value 620 => 06.20
555 command = "version_bios";
562 // German: undokumentiert: Datum: Tag
565 command = "date_day";
572 // German: undokumentiert: Datum: Monat
575 command = "date_month";
582 // German: undokumentiert: Datum: Jahr
585 command = "date_year";
592 // German: undokumentiert: Uhrzeit: Stunde
595 command = "time_hour";
602 // German: undokumentiert: Uhrzeit: Minute
605 command = "time_minute";
612 // German: Betriebsstunden Verdichter 1
613 TYPE_OPERATING_HOURS_COMPRESSOR1 {
615 command = "operating_hours_compressor1";
623 // German: Betriebsstunden Verdichter 2
624 TYPE_OPERATING_HOURS_COMPRESSOR2 {
626 command = "operating_hours_compressor2";
634 // German: Betriebsstunden Heizungsumwälzpumpe
635 TYPE_OPERATING_HOURS_CIRCULATION_PUMP {
637 command = "operating_hours_circulation_pump";
645 // German: Betriebsstunden Quellenpumpe
646 TYPE_OPERATING_HOURS_SOURCE_PUMP {
648 command = "operating_hours_source_pump";
656 // German: Betriebsstunden Solarkreis
657 TYPE_OPERATING_HOURS_SOLAR {
659 command = "operating_hours_solar";
667 // German: Handabschaltung Heizbetrieb
668 TYPE_ENABLE_HEATING {
670 command = "enable_heating";
677 // German: Handabschaltung Kühlbetrieb
678 TYPE_ENABLE_COOLING {
680 command = "enable_cooling";
687 // German: Handabschaltung Warmwasserbetrieb
688 TYPE_ENABLE_WARMWATER {
690 command = "enable_warmwater";
697 // German: Handabschaltung Pool_Heizbetrieb
700 command = "enable_pool";
707 // German: undokumentiert: vermutlich Betriebsmodus PV 0=Aus, 1=Auto, 2=Ein
710 command = "enable_pv";
717 // German: Status der Wärmepumpenkomponenten
727 // German: Status der Wärmepumpenkomponenten: Quellenpumpe
728 TYPE_STATE_SOURCEPUMP {
730 command = "state_sourcepump";
732 type = Type.Bitfield;
737 // German: Status der Wärmepumpenkomponenten: Heizungsumwälzpumpe
738 TYPE_STATE_HEATINGPUMP {
740 command = "state_heatingpump";
742 type = Type.Bitfield;
747 // German: Status der Wärmepumpenkomponenten: Freigabe Regelung EVD /
751 command = "state_evd";
753 type = Type.Bitfield;
758 // German: Status der Wärmepumpenkomponenten: Verdichter 1
759 TYPE_STATE_compressor1 {
761 command = "state_compressor1";
763 type = Type.Bitfield;
768 // German: Status der Wärmepumpenkomponenten: Verdichter 2
769 TYPE_STATE_compressor2 {
771 command = "state_compressor2";
773 type = Type.Bitfield;
778 // German: Status der Wärmepumpenkomponenten: externer Wärmeerzeuger
779 TYPE_STATE_extheater {
781 command = "state_extheater";
783 type = Type.Bitfield;
788 // German: Status der Wärmepumpenkomponenten: Alarmausgang
791 command = "state_alarm";
793 type = Type.Bitfield;
798 // German: Status der Wärmepumpenkomponenten: Motorventil Kühlbetrieb
801 command = "state_cooling";
803 type = Type.Bitfield;
808 // German: Status der Wärmepumpenkomponenten: Motorventil Warmwasser
811 command = "state_water";
813 type = Type.Bitfield;
818 // German: Status der Wärmepumpenkomponenten: Motorventil Pool
821 command = "state_pool";
823 type = Type.Bitfield;
828 // German: Status der Wärmepumpenkomponenten: Solarbetrieb
831 command = "state_solar";
833 type = Type.Bitfield;
838 // German: Status der Wärmepumpenkomponenten: 4-Wegeventil im Kältekreis
839 TYPE_STATE_cooling4way {
841 command = "state_cooling4way";
843 type = Type.Bitfield;
848 // German: Meldungen von Ausfällen F0xx die zum Wärmepumpenausfall führen
858 // German: Unterbrechungen
861 command = "interruptions";
868 // German: Serviceebene (0: normal, 1: service)
871 command = "state_service";
878 // German: Temperaturanpassung für die Heizung
881 command = "adapt_heating";
884 type = Type.Word; // value range 0..8 => -2K .. +2K
888 // German: Raumeinfluss
889 TYPE_TEMP_ROOM_INFLUENCE {
891 command = "tempRoomInfluence";
894 type = Type.Word; // value range 0..4 => 0%, 50%, 100%, 150%, 200%
898 // German: Handschaltung Heizungspumpe (H-0-A)
899 // H:Handschaltung Ein 0:Aus A:Automatik
900 // Kodierung: 0:? 1:? 2:Automatik
901 TYPE_MANUAL_HEATINGPUMP {
903 command = "manual_heatingpump";
910 // German: Handschaltung Quellenpumpe (H-0-A)
911 TYPE_MANUAL_SOURCEPUMP {
913 command = "manual_sourcepump";
920 // German: Handschaltung Solarpumpe 1 (H-0-A)
921 TYPE_MANUAL_SOLARPUMP1 {
923 command = "manual_solarpump1";
930 // German: Handschaltung Solarpumpe 2 (H-0-A)
931 TYPE_MANUAL_SOLARPUMP2 {
933 command = "manual_solarpump2";
940 // German: Handschaltung Speicherladepumpe (H-0-A)
941 TYPE_MANUAL_TANKPUMP {
943 command = "manual_tankpump";
950 // German: Handschaltung Brauchwasserventil (H-0-A)
953 command = "manual_valve";
960 // German: Handschaltung Poolventil (H-0-A)
961 TYPE_MANUAL_POOLVALVE {
963 command = "manual_poolvalve";
970 // German: Handschaltung Kühlventil (H-0-A)
971 TYPE_MANUAL_COOLVALVE {
973 command = "manual_coolvalve";
980 // German: Handschaltung Vierwegeventil (H-0-A)
981 TYPE_MANUAL_4WAYVALVE {
983 command = "manual_4wayvalve";
990 // German: Handschaltung Multiausgang Ext. (H-0-A)
991 TYPE_MANUAL_MULTIEXT {
993 command = "manual_multiext";
1001 TYPE_TEMPERATURE_SURROUNDING {
1003 command = "temperature_surrounding";
1012 TYPE_TEMPERATURE_SUCTION_AIR {
1014 command = "temperature_suction_air";
1023 TYPE_TEMPERATURE_SUMP {
1025 command = "temperature_sump";
1034 // The following tags are only available, if an Ecovent System is attached to the Ecotouch
1038 // Waterkotte reference: airventilation-temperature-1
1039 TYPE_ECOVENT_TEMP_EXHAUST_AIR {
1041 command = "ecovent_temp_exhaust_air";
1043 tagName = "3:HREG400000";
1050 // Waterkotte reference: airventilation-temperature-2
1051 TYPE_ECOVENT_TEMP_EXIT_AIR {
1053 command = "ecovent_temp_exit_air";
1055 tagName = "3:HREG400002";
1061 // German: Außenluft
1062 // Waterkotte reference: airventilation-temperature-3
1063 TYPE_ECOVENT_TEMP_OUTDOOR_AIR {
1065 command = "ecovent_temp_outdoor_air";
1067 tagName = "3:HREG400004";
1074 // Waterkotte reference: airventilation-temperature-4
1075 TYPE_ECOVENT_TEMP_SUPPLY_AIR {
1077 command = "ecovent_temp_supply_air";
1079 tagName = "3:HREG400006";
1086 // Waterkotte reference: airventilation-co2-value
1087 TYPE_ECOVENT_CO2_VALUE {
1089 command = "ecovent_CO2_value";
1090 unit = PARTS_PER_MILLION;
1091 tagName = "3:HREG400008";
1097 // German: Luftfeuchtigkeit
1098 // Waterkotte reference: airventilation-air-moisture-value
1099 TYPE_ECOVENT_MOISTURE_VALUE {
1101 command = "ecovent_moisture_value";
1102 unit = PARTS_PER_MILLION;
1103 tagName = "3:HREG400010";
1109 // German: Lüfterdrehzahl
1110 // Waterkotte reference: airventilation-analog-output-y1
1111 TYPE_ECOVENT_OUTPUT_Y1 {
1113 command = "ecovent_output_y1";
1115 tagName = "3:HREG400014";
1123 command = "ecovent_mode";
1125 type = Type.Word; // Type.Enum;
1127 stringEnum = new String[] { "Day Mode", "Night Mode", "Timer Mode", "Party Mode", "Vacation Mode",
1135 * Represents the heatpump command as it will be used in *.items
1138 String command = "";
1140 * Represents the internal raw heatpump command as it will be used in
1141 * querying the heat pump
1143 String tagName = "";
1148 * The heatpump always returns 16-bit integers encoded as ASCII. They need
1149 * to be interpreted according to the context.
1150 * The EcoVent unit returns floating point numbers.
1161 * The format of the response of the heat pump
1163 Type type = Type.Analog;
1166 * If \c type is Type.Bitfield, this determines the bit number (0-based)
1171 * If type is anything else than {@link Type#Bitfield} this is used as divisor for the scaled integer.
1172 * Defaults to 10 and should be a power of 10 (e.g. 10, 100, 1000).
1177 * If \c type is Type.Enum, this defines the meaning of the values (0-based)
1179 String @Nullable [] stringEnum = null;
1182 * @return command name (uses in *.items files)
1184 public String getCommand() {
1189 * @return tag name (raw communication with heat pump)
1191 public String getTagName() {
1196 * @return type: how to interpret the response from the heat pump
1198 public Type getType() {
1203 * @return bitnum: if the value is a bit field, this indicates the bit
1206 public int getBitNum() {
1211 * @return Divisor for scaled integer analog values.
1213 public int getDivisor() {
1217 public Unit<?> getUnit() {
1223 * @param bindingConfig
1224 * command e.g. TYPE_TEMPERATURE_OUTSIDE,..
1227 * @return true if item class can bound to heatpumpCommand
1229 // public static boolean validateBinding(EcoTouchTags bindingConfig, Class<? extends Item> itemClass) {
1230 // boolean ret = false;
1231 // for (EcoTouchTags c : EcoTouchTags.values()) {
1232 // if (c.getCommand().equals(bindingConfig.getCommand()) && c.getItemClass().equals(itemClass)) {
1241 * Decode a raw value from the heat pump's ethernet interface into a scaled value
1246 public BigDecimal decodeValue(String rawValue) {
1247 BigDecimal raw = new BigDecimal(rawValue);
1248 if (type == Type.Bitfield) {
1249 // ignore any scaling from \ref divisor
1250 int value = raw.intValue();
1251 if ((value & (1 << bitnum)) != 0) {
1252 return BigDecimal.ONE;
1254 return BigDecimal.ZERO;
1257 BigDecimal result = raw.divide(new BigDecimal(divisor));
1262 * Searches the available heat pump commands and returns the matching one.
1264 * @param heatpumpCommand
1265 * command string e.g. "temperature_outside"
1266 * @return matching EcoTouchTags instance, if available
1268 public static @Nullable EcoTouchTags fromString(String heatpumpCommand) {
1269 if (heatpumpCommand.isEmpty()) {
1272 for (EcoTouchTags c : EcoTouchTags.values()) {
1273 if (c.getCommand().equals(heatpumpCommand)) {
1278 throw new IllegalArgumentException("cannot find EcoTouch tag for '" + heatpumpCommand + "'");
1282 * Searches the available heat pump commands and returns the first matching
1286 * raw heatpump tag e.g. "A1"
1287 * @return first matching EcoTouchTags instance, if available
1289 public static List<EcoTouchTags> fromTag(String tag) {
1290 List<EcoTouchTags> result = new LinkedList<EcoTouchTags>();
1291 for (EcoTouchTags c : EcoTouchTags.values()) {
1292 if (c.getTagName().equals(tag)) {