2 * Copyright (c) 2010-2021 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;
26 * Represents all valid commands which could be processed by this binding
28 * @author Sebastian Held <sebastian.held@gmx.de> - Initial contribution
31 public enum EcoTouchTags {
33 // German: Außentemperatur
34 TYPE_TEMPERATURE_OUTSIDE {
36 command = "temperature_outside";
42 // German: Außentemperatur gemittelt über 1h
43 TYPE_TEMPERATURE_OUTSIDE_1H {
45 command = "temperature_outside_1h";
51 // German: Außentemperatur gemittelt über 24h
52 TYPE_TEMPERATURE_OUTSIDE_24H {
54 command = "temperature_outside_24h";
60 // German: Quelleneintrittstemperatur
61 TYPE_TEMPERATURE_SOURCE_IN {
63 command = "temperature_source_in";
69 // German: Quellenaustrittstemperatur
70 TYPE_TEMPERATURE_SOURCE_OUT {
72 command = "temperature_source_out";
78 // German: Verdampfungstemperatur
79 TYPE_TEMPERATURE_EVAPORATION {
81 command = "temperature_evaporation";
87 // German: Sauggastemperatur
88 TYPE_TEMPERATURE_SUCTION {
90 command = "temperature_suction";
96 // German: Verdampfungsdruck
97 TYPE_PRESSURE_EVAPORATION {
99 command = "pressure_evaporation";
105 // German: Temperatur Rücklauf Soll
106 TYPE_TEMPERATURE_RETURN_SET {
108 command = "temperature_return_set";
114 // German: Temperatur Rücklauf
115 TYPE_TEMPERATURE_RETURN {
117 command = "temperature_return";
123 // German: Temperatur Vorlauf
124 TYPE_TEMPERATURE_FLOW {
126 command = "temperature_flow";
132 // German: Kondensationstemperatur
133 TYPE_TEMPERATURE_CONDENSATION {
135 command = "temperature_condensation";
141 // German: Kondensationsdruck
142 TYPE_PRESSURE_CONDENSATION {
144 command = "pressure_condensation";
150 // German: Speichertemperatur
151 TYPE_TEMPERATURE_STORAGE {
153 command = "temperature_storage";
159 // German: Raumtemperatur
160 TYPE_TEMPERATURE_ROOM {
162 command = "temperature_room";
168 // German: Raumtemperatur gemittelt über 1h
169 TYPE_TEMPERATURE_ROOM_1H {
171 command = "temperature_room_1h";
177 // German: Warmwassertemperatur
178 TYPE_TEMPERATURE_WATER {
180 command = "temperature_water";
186 // German: Pooltemperatur
187 TYPE_TEMPERATURE_POOL {
189 command = "temperature_pool";
195 // German: Solarkollektortemperatur
196 TYPE_TEMPERATURE_SOLAR {
198 command = "temperature_solar";
204 // German: Solarkreis Vorlauf
205 TYPE_TEMPERATURE_SOLAR_FLOW {
207 command = "temperature_solar_flow";
213 // German: Ventilöffnung elektrisches Expansionsventil
214 TYPE_POSITION_EXPANSION_VALVE {
216 command = "position_expansion_valve";
222 // German: elektrische Leistung Verdichter
223 TYPE_POWER_COMPRESSOR {
225 command = "power_compressor";
231 // German: abgegebene thermische Heizleistung der Wärmepumpe
234 command = "power_heating";
240 // German: abgegebene thermische KälteLeistung der Wärmepumpe
243 command = "power_cooling";
249 // German: COP Heizleistung
252 command = "cop_heating";
257 // German: COP Kälteleistungleistung
260 command = "cop_cooling";
265 // German: Aktuelle Heizkreistemperatur
266 TYPE_TEMPERATURE_HEATING {
268 command = "temperature_heating_return";
274 // German: Geforderte Temperatur im Heizbetrieb
275 TYPE_TEMPERATURE_HEATING_SET {
277 command = "temperature_heating_set";
283 // German: Sollwertvorgabe Heizkreistemperatur
284 TYPE_TEMPERATURE_HEATING_SET2 {
286 command = "temperature_heating_set2";
292 // German: Aktuelle Kühlkreistemperatur
293 TYPE_TEMPERATURE_COOLING {
295 command = "temperature_cooling_return";
301 // German: Geforderte Temperatur im Kühlbetrieb
302 TYPE_TEMPERATURE_COOLING_SET {
304 command = "temperature_cooling_set";
310 // German: Sollwertvorgabe Kühlbetrieb
311 TYPE_TEMPERATURE_COOLING_SET2 {
313 command = "temperature_cooling_set2";
319 // German: Sollwert Warmwassertemperatur
320 TYPE_TEMPERATURE_WATER_SET {
322 command = "temperature_water_set";
328 // German: Sollwertvorgabe Warmwassertemperatur
329 TYPE_TEMPERATURE_WATER_SET2 {
331 command = "temperature_water_set2";
337 // German: Sollwert Poolwassertemperatur
338 TYPE_TEMPERATURE_POOL_SET {
340 command = "temperature_pool_set";
346 // German: Sollwertvorgabe Poolwassertemperatur
347 TYPE_TEMPERATURE_POOL_SET2 {
349 command = "temperature_pool_set2";
355 // German: geforderte Verdichterleistung
356 TYPE_COMPRESSOR_POWER {
358 command = "compressor_power";
364 // German: % Heizungsumwälzpumpe
365 TYPE_PERCENT_HEAT_CIRC_PUMP {
367 command = "percent_heat_circ_pump";
373 // German: % Quellenpumpe
374 TYPE_PERCENT_SOURCE_PUMP {
376 command = "percent_source_pump";
382 // German: % Leistung Verdichter
383 TYPE_PERCENT_COMPRESSOR {
385 command = "percent_compressor";
391 // German: Hysterese Heizung
392 TYPE_HYSTERESIS_HEATING {
394 command = "hysteresis_heating";
400 // German: Außentemperatur gemittelt über 1h (scheinbar identisch zu A2)
401 TYPE_TEMPERATURE2_OUTSIDE_1H {
403 command = "temperature2_outside_1h";
409 // German: Heizkurve - nviNormAussen
412 command = "nviNormAussen";
418 // German: Heizkurve - nviHeizkreisNorm
419 TYPE_NVIHEIZKREISNORM {
421 command = "nviHeizkreisNorm";
427 // German: Heizkurve - nviTHeizgrenze
428 TYPE_NVITHEIZGRENZE {
430 command = "nviTHeizgrenze";
436 // German: Heizkurve - nviTHeizgrenzeSoll
437 TYPE_NVITHEIZGRENZESOLL {
439 command = "nviTHeizgrenzeSoll";
445 // German: undokumentiert: Heizkurve max. VL-Temp (??)
448 command = "maxVLTemp";
454 // German: undokumentiert: Heizkreis Soll-Temp bei 0° Aussen
457 command = "tempSet0Deg";
466 command = "tempRoomSet";
472 // German: undokumentiert: Kühlen Einschalt-Temp. Aussentemp (??)
473 TYPE_COOLENABLETEMP {
475 command = "coolEnableTemp";
481 // German: Heizkurve - nviSollKuehlen
482 TYPE_NVITSOLLKUEHLEN {
484 command = "nviSollKuehlen";
490 // German: Temperaturveränderung Heizkreis bei PV-Ertrag
491 TYPE_TEMPCHANGE_HEATING_PV {
493 command = "tempchange_heating_pv";
499 // German: Temperaturveränderung Kühlkreis bei PV-Ertrag
500 TYPE_TEMPCHANGE_COOLING_PV {
502 command = "tempchange_cooling_pv";
508 // German: Temperaturveränderung Warmwasser bei PV-Ertrag
509 TYPE_TEMPCHANGE_WARMWATER_PV {
511 command = "tempchange_warmwater_pv";
517 // German: Temperaturveränderung Pool bei PV-Ertrag
518 TYPE_TEMPCHANGE_POOL_PV {
520 command = "tempchange_pool_pv";
526 // German: undokumentiert: Firmware-Version Regler
527 // value 10401 => 01.04.01
528 TYPE_VERSION_CONTROLLER {
530 command = "version_controller";
537 // German: undokumentiert: Firmware-Build Regler
538 TYPE_VERSION_CONTROLLER_BUILD {
540 command = "version_controller_build";
547 // German: undokumentiert: BIOS-Version
548 // value 620 => 06.20
551 command = "version_bios";
558 // German: undokumentiert: Datum: Tag
561 command = "date_day";
568 // German: undokumentiert: Datum: Monat
571 command = "date_month";
578 // German: undokumentiert: Datum: Jahr
581 command = "date_year";
588 // German: undokumentiert: Uhrzeit: Stunde
591 command = "time_hour";
598 // German: undokumentiert: Uhrzeit: Minute
601 command = "time_minute";
608 // German: Betriebsstunden Verdichter 1
609 TYPE_OPERATING_HOURS_COMPRESSOR1 {
611 command = "operating_hours_compressor1";
619 // German: Betriebsstunden Verdichter 2
620 TYPE_OPERATING_HOURS_COMPRESSOR2 {
622 command = "operating_hours_compressor2";
630 // German: Betriebsstunden Heizungsumwälzpumpe
631 TYPE_OPERATING_HOURS_CIRCULATION_PUMP {
633 command = "operating_hours_circulation_pump";
641 // German: Betriebsstunden Quellenpumpe
642 TYPE_OPERATING_HOURS_SOURCE_PUMP {
644 command = "operating_hours_source_pump";
652 // German: Betriebsstunden Solarkreis
653 TYPE_OPERATING_HOURS_SOLAR {
655 command = "operating_hours_solar";
663 // German: Handabschaltung Heizbetrieb
664 TYPE_ENABLE_HEATING {
666 command = "enable_heating";
673 // German: Handabschaltung Kühlbetrieb
674 TYPE_ENABLE_COOLING {
676 command = "enable_cooling";
683 // German: Handabschaltung Warmwasserbetrieb
684 TYPE_ENABLE_WARMWATER {
686 command = "enable_warmwater";
693 // German: Handabschaltung Pool_Heizbetrieb
696 command = "enable_pool";
703 // German: undokumentiert: vermutlich Betriebsmodus PV 0=Aus, 1=Auto, 2=Ein
706 command = "enable_pv";
713 // German: Status der Wärmepumpenkomponenten
723 // German: Status der Wärmepumpenkomponenten: Quellenpumpe
724 TYPE_STATE_SOURCEPUMP {
726 command = "state_sourcepump";
728 type = Type.Bitfield;
733 // German: Status der Wärmepumpenkomponenten: Heizungsumwälzpumpe
734 TYPE_STATE_HEATINGPUMP {
736 command = "state_heatingpump";
738 type = Type.Bitfield;
743 // German: Status der Wärmepumpenkomponenten: Freigabe Regelung EVD /
747 command = "state_evd";
749 type = Type.Bitfield;
754 // German: Status der Wärmepumpenkomponenten: Verdichter 1
755 TYPE_STATE_compressor1 {
757 command = "state_compressor1";
759 type = Type.Bitfield;
764 // German: Status der Wärmepumpenkomponenten: Verdichter 2
765 TYPE_STATE_compressor2 {
767 command = "state_compressor2";
769 type = Type.Bitfield;
774 // German: Status der Wärmepumpenkomponenten: externer Wärmeerzeuger
775 TYPE_STATE_extheater {
777 command = "state_extheater";
779 type = Type.Bitfield;
784 // German: Status der Wärmepumpenkomponenten: Alarmausgang
787 command = "state_alarm";
789 type = Type.Bitfield;
794 // German: Status der Wärmepumpenkomponenten: Motorventil Kühlbetrieb
797 command = "state_cooling";
799 type = Type.Bitfield;
804 // German: Status der Wärmepumpenkomponenten: Motorventil Warmwasser
807 command = "state_water";
809 type = Type.Bitfield;
814 // German: Status der Wärmepumpenkomponenten: Motorventil Pool
817 command = "state_pool";
819 type = Type.Bitfield;
824 // German: Status der Wärmepumpenkomponenten: Solarbetrieb
827 command = "state_solar";
829 type = Type.Bitfield;
834 // German: Status der Wärmepumpenkomponenten: 4-Wegeventil im Kältekreis
835 TYPE_STATE_cooling4way {
837 command = "state_cooling4way";
839 type = Type.Bitfield;
844 // German: Meldungen von Ausfällen F0xx die zum Wärmepumpenausfall führen
854 // German: Unterbrechungen
857 command = "interruptions";
864 // German: Serviceebene (0: normal, 1: service)
867 command = "state_service";
874 // German: Temperaturanpassung für die Heizung
877 command = "adapt_heating";
880 type = Type.Word; // value range 0..8 => -2K .. +2K
884 // German: Raumeinfluss
885 TYPE_TEMP_ROOM_INFLUENCE {
887 command = "tempRoomInfluence";
890 type = Type.Word; // value range 0..4 => 0%, 50%, 100%, 150%, 200%
894 // German: Handschaltung Heizungspumpe (H-0-A)
895 // H:Handschaltung Ein 0:Aus A:Automatik
896 // Kodierung: 0:? 1:? 2:Automatik
897 TYPE_MANUAL_HEATINGPUMP {
899 command = "manual_heatingpump";
906 // German: Handschaltung Quellenpumpe (H-0-A)
907 TYPE_MANUAL_SOURCEPUMP {
909 command = "manual_sourcepump";
916 // German: Handschaltung Solarpumpe 1 (H-0-A)
917 TYPE_MANUAL_SOLARPUMP1 {
919 command = "manual_solarpump1";
926 // German: Handschaltung Solarpumpe 2 (H-0-A)
927 TYPE_MANUAL_SOLARPUMP2 {
929 command = "manual_solarpump2";
936 // German: Handschaltung Speicherladepumpe (H-0-A)
937 TYPE_MANUAL_TANKPUMP {
939 command = "manual_tankpump";
946 // German: Handschaltung Brauchwasserventil (H-0-A)
949 command = "manual_valve";
956 // German: Handschaltung Poolventil (H-0-A)
957 TYPE_MANUAL_POOLVALVE {
959 command = "manual_poolvalve";
966 // German: Handschaltung Kühlventil (H-0-A)
967 TYPE_MANUAL_COOLVALVE {
969 command = "manual_coolvalve";
976 // German: Handschaltung Vierwegeventil (H-0-A)
977 TYPE_MANUAL_4WAYVALVE {
979 command = "manual_4wayvalve";
986 // German: Handschaltung Multiausgang Ext. (H-0-A)
987 TYPE_MANUAL_MULTIEXT {
989 command = "manual_multiext";
997 TYPE_TEMPERATURE_SURROUNDING {
999 command = "temperature_surrounding";
1008 TYPE_TEMPERATURE_SUCTION_AIR {
1010 command = "temperature_suction_air";
1019 TYPE_TEMPERATURE_SUMP {
1021 command = "temperature_sump";
1030 // The following tags are only available, if an Ecovent System is attached to the Ecotouch
1034 // Waterkotte reference: airventilation-temperature-1
1035 TYPE_ECOVENT_TEMP_EXHAUST_AIR {
1037 command = "ecovent_temp_exhaust_air";
1039 tagName = "3:HREG400000";
1046 // Waterkotte reference: airventilation-temperature-2
1047 TYPE_ECOVENT_TEMP_EXIT_AIR {
1049 command = "ecovent_temp_exit_air";
1051 tagName = "3:HREG400002";
1057 // German: Außenluft
1058 // Waterkotte reference: airventilation-temperature-3
1059 TYPE_ECOVENT_TEMP_OUTDOOR_AIR {
1061 command = "ecovent_temp_outdoor_air";
1063 tagName = "3:HREG400004";
1070 // Waterkotte reference: airventilation-temperature-4
1071 TYPE_ECOVENT_TEMP_SUPPLY_AIR {
1073 command = "ecovent_temp_supply_air";
1075 tagName = "3:HREG400006";
1082 // Waterkotte reference: airventilation-co2-value
1083 TYPE_ECOVENT_CO2_VALUE {
1085 command = "ecovent_CO2_value";
1086 unit = PARTS_PER_MILLION;
1087 tagName = "3:HREG400008";
1093 // German: Luftfeuchtigkeit
1094 // Waterkotte reference: airventilation-air-moisture-value
1095 TYPE_ECOVENT_MOISTURE_VALUE {
1097 command = "ecovent_moisture_value";
1098 unit = PARTS_PER_MILLION;
1099 tagName = "3:HREG400010";
1105 // German: Lüfterdrehzahl
1106 // Waterkotte reference: airventilation-analog-output-y1
1107 TYPE_ECOVENT_OUTPUT_Y1 {
1109 command = "ecovent_output_y1";
1111 tagName = "3:HREG400014";
1119 command = "ecovent_mode";
1121 type = Type.Word; // Type.Enum;
1123 stringEnum = new String[] { "Day Mode", "Night Mode", "Timer Mode", "Party Mode", "Vacation Mode",
1131 * Represents the heatpump command as it will be used in *.items
1136 * Represents the internal raw heatpump command as it will be used in
1137 * querying the heat pump
1144 * The heatpump always returns 16-bit integers encoded as ASCII. They need
1145 * to be interpreted according to the context.
1146 * The EcoVent unit returns floating point numbers.
1157 * The format of the response of the heat pump
1159 Type type = Type.Analog;
1162 * If \c type is Type.Bitfield, this determines the bit number (0-based)
1167 * If type is anything else than {@link Type#Bitfield} this is used as divisor for the scaled integer.
1168 * Defaults to 10 and should be a power of 10 (e.g. 10, 100, 1000).
1173 * If \c type is Type.Enum, this defines the meaning of the values (0-based)
1175 String[] stringEnum = null;
1178 * @return command name (uses in *.items files)
1180 public String getCommand() {
1185 * @return tag name (raw communication with heat pump)
1187 public String getTagName() {
1192 * @return type: how to interpret the response from the heat pump
1194 public Type getType() {
1199 * @return bitnum: if the value is a bit field, this indicates the bit
1202 public int getBitNum() {
1207 * @return Divisor for scaled integer analog values.
1209 public int getDivisor() {
1213 public Unit<?> getUnit() {
1219 * @param bindingConfig
1220 * command e.g. TYPE_TEMPERATURE_OUTSIDE,..
1223 * @return true if item class can bound to heatpumpCommand
1225 // public static boolean validateBinding(EcoTouchTags bindingConfig, Class<? extends Item> itemClass) {
1226 // boolean ret = false;
1227 // for (EcoTouchTags c : EcoTouchTags.values()) {
1228 // if (c.getCommand().equals(bindingConfig.getCommand()) && c.getItemClass().equals(itemClass)) {
1237 * Decode a raw value from the heat pump's ethernet interface into a scaled value
1242 public BigDecimal decodeValue(String rawValue) {
1243 BigDecimal raw = new BigDecimal(rawValue);
1244 if (type == Type.Bitfield) {
1245 // ignore any scaling from \ref divisor
1246 int value = raw.intValue();
1247 if ((value & (1 << bitnum)) != 0)
1248 return BigDecimal.ONE;
1250 return BigDecimal.ZERO;
1252 BigDecimal result = raw.divide(new BigDecimal(divisor));
1257 * Searches the available heat pump commands and returns the matching one.
1259 * @param heatpumpCommand
1260 * command string e.g. "temperature_outside"
1261 * @return matching EcoTouchTags instance, if available
1263 public static EcoTouchTags fromString(String heatpumpCommand) {
1264 if ("".equals(heatpumpCommand)) {
1267 for (EcoTouchTags c : EcoTouchTags.values()) {
1268 if (c.getCommand().equals(heatpumpCommand)) {
1273 throw new IllegalArgumentException("cannot find EcoTouch tag for '" + heatpumpCommand + "'");
1277 * Searches the available heat pump commands and returns the first matching
1281 * raw heatpump tag e.g. "A1"
1282 * @return first matching EcoTouchTags instance, if available
1284 public static List<EcoTouchTags> fromTag(String tag) {
1285 List<EcoTouchTags> result = new LinkedList<EcoTouchTags>();
1286 for (EcoTouchTags c : EcoTouchTags.values()) {
1287 if (c.getTagName().equals(tag)) {