Repository: Bouni/python-luxtronik (language: python)

Issue:
SwitchoffFile value '22' seems to be 'No request'
The value `22` is not yet used in the code, but it is used at my heat pump.

From `dump_luxtronik.py`:

Number: 106   Name: ID_WEB_Switchoff_file_Nr0                                    Type: SwitchoffFile        Value: 22
Number: 107   Name: ID_WEB_Switchoff_file_Nr1                                    Type: SwitchoffFile        Value: 22
Number: 108   Name: ID_WEB_Switchoff_file_Nr2                                    Type: SwitchoffFile        Value: 22
Number: 109   Name: ID_WEB_Switchoff_file_Nr3                                    Type: SwitchoffFile        Value: 22
Number: 110   Name: ID_WEB_Switchoff_file_Nr4                                    Type: SwitchoffFile        Value: 22
Number: 111   Name: ID_WEB_Switchoff_file_Time0                                  Type: Timestamp            Value: 2024-10-16 06:34:31
Number: 112   Name: ID_WEB_Switchoff_file_Time1                                  Type: Timestamp            Value: 2024-10-17 08:58:26
Number: 113   Name: ID_WEB_Switchoff_file_Time2                                  Type: Timestamp            Value: 2024-10-18 09:41:10
Number: 114   Name: ID_WEB_Switchoff_file_Time3                                  Type: Timestamp            Value: 2024-10-20 08:28:14
Number: 115   Name: ID_WEB_Switchoff_file_Time4                                  Type: Timestamp            Value: 2024-10-26 12:08:55


From `datalog`:

26.10.24 12:08 keine Anf.;
20.10.24 08:28 keine Anf.;
18.10.24 09:41 keine Anf.;
17.10.24 08:58 keine Anf.;
16.10.24 06:34 keine Anf.;




Discussion / hints:
Yes, newer versions of the firmware have more switch off codes. This is what the firmware reports for the different IDs:
```
0 : "err. HP", 
1 : "err. inst.", 
2 : "OM ZWE", 
3 : "EVU-block", 
5 : "air defr.", 
6 : "TOLmax", 
7 : "TOLmin", 
8 : "LOL", 
9 : "no requ.", 
10 : "ext.ener.", 
11 : "flow rate", 
12 : "p0_break", 
13 : "u0_break", 
14 : "I0_break", 
15 : "D0_break", 
16 : "mode of operation", 
17 : "stop", 
18 : "min.flow cooling", 
19 : "PVmax", 
20 : "h0_break", 
21 : "DSH_break", 
22 : "no requ.", 
23 : "min. heat source out cooling", 
24 : "LPC", 
25 : "Restart", 
```
As you can see, this are mostly abbreviations. In the manual, one can find some explanations:
```
err. HP
 -> heat pump fault
err. inst.
 -> system fault
OM ZWE
 -> mode of operation additional heating generator
EVU-block
 -> el. sup. blockade
Defr. air.
 -> air defrost
TPLmax
 -> temperature limits maximum of application
TPLmin
 -> temperature limits minimum of application
low lim
 -> lower limit of application
no requ.
 -> no request
TEE
 -> External energy source
flow
 -> Flow
p0_break
 -> Low pressure pause
u0_break
 -> Superheating pause
I0_break
 -> Inverter pause
DSH_break
 -> Overheating hot gas pause
h0_break
 -> Hot gas pause
D0_break
 -> Desuperheater pause
OpMode
 -> Operating mode for switching over
Stop
 -> Other shutdown
min. heat source out cooling
 -> Compressor switch off if TWA < 3°C during active cooling
```
Note that these do not exactly coincide with the abbreviations above.

Currently, this is the implemented conversion, see https://github.com/Bouni/python-luxtronik/blob/abd4752b66f8ce9deed676353ac3165eef86ca81/luxtronik/datatypes.py#L667C1-L680C6
```python
    codes = {
        1: "heatpump error",
        2: "system error",
        3: "evu lock",
        4: "operation mode second heat generator",
        5: "air defrost",
        6: "maximal usage temperature",
        7: "minimal usage temperature",
        8: "lower usage limit",
        9: "no request",
        11: "flow rate",
        19: "PV max",
    }
```

Fix patch:
diff --git a/luxtronik/datatypes.py b/luxtronik/datatypes.py
index d8f7435..c7ee504 100755
--- a/luxtronik/datatypes.py
+++ b/luxtronik/datatypes.py
@@ -666,17 +666,31 @@ class SwitchoffFile(SelectionBase):
     datatype_class = "selection"
 
     codes = {
-        1: "heatpump error",
-        2: "system error",
+        0: "heatpump error",
+        1: "system error",
+        2: "operation mode second heat generator",
         3: "evu lock",
-        4: "operation mode second heat generator",
         5: "air defrost",
         6: "maximal usage temperature",
         7: "minimal usage temperature",
         8: "lower usage limit",
         9: "no request",
+        10 : "external energy source",
         11: "flow rate",
+        12 : "low pressure pause",
+        13 : "superheating pause",
+        14 : "inverter pause",
+        15 : "desuperheater pause",
+        16 : "operation mode for switching over",
+        17 : "other shutdown",
+        18 : "min.flow cooling",
         19: "PV max",
+        20 : "hot gas pause",
+        21 : "overheating hot gas pause",
+        22 : "no request",
+        23 : "min. heat source out cooling",
+        24 : "LPC",
+        25 : "restart",
     }
 
 


Test patch:
diff --git a/tests/test_datatypes.py b/tests/test_datatypes.py
index 95ca473..2643c36 100644
--- a/tests/test_datatypes.py
+++ b/tests/test_datatypes.py
@@ -1009,13 +1009,13 @@ def test_init(self):
         assert a.name == "switchoff_file"
         assert a.datatype_class == "selection"
         assert a.datatype_unit is None
-        assert len(a.codes) == 11
+        assert len(a.codes) == 25
 
     def test_options(self):
         """Test cases for options property"""
 
         a = SwitchoffFile("")
-        assert len(a.options()) == 11
+        assert len(a.options()) == 25
         assert a.options() == list(a.codes.values())