Repository: openviess/PyViCare (language: python)

Issue:
Compressor feature 'phase' 
Hi, there is an additional feature to 'active' in heatpump/compressor that is 'phase'.  It can be easily read by adding 

    @handleNotSupported
    def getPhase(self):
        return self.service.getProperty(f"heating.compressors.{self.compressor}")["properties"]["phase"]["value"]

at the end of PyViCareHeatPump.py

I am not familiar with  github and won't mess-up the code. If it is interesting to the crowd, maybe it can be inserted at the next maintenance.


Discussion / hints:
I have seen the values:

- 'off'
- 'preparing' (timer before compressor starts)
- 'heating'
- 'pause' (blocking timer after compressor has stopped)
- 'defrost' (active de-icing)

Obviously, there is 'passive defrost' too, but I haven't seen it yet.

Fix patch:
diff --git a/PyViCare/PyViCareHeatPump.py b/PyViCare/PyViCareHeatPump.py
index 6a15ad71..3c407ba0 100644
--- a/PyViCare/PyViCareHeatPump.py
+++ b/PyViCare/PyViCareHeatPump.py
@@ -138,3 +138,7 @@ def getHoursLoadClass5(self):
     @handleNotSupported
     def getActive(self):
         return self.service.getProperty(f"heating.compressors.{self.compressor}")["properties"]["active"]["value"]
+    
+    @handleNotSupported
+    def getPhase(self):
+        return self.service.getProperty(f"heating.compressors.{self.compressor}")["properties"]["phase"]["value"]


Test patch:
diff --git a/tests/test_Vitocal200.py b/tests/test_Vitocal200.py
index 39edcf1b..202c14c6 100644
--- a/tests/test_Vitocal200.py
+++ b/tests/test_Vitocal200.py
@@ -12,38 +12,42 @@ def setUp(self):
         self.device = HeatPump(self.service)
 
     def test_getCompressorActive(self):
-        self.assertEqual(self.device.compressors[0].getActive(), False)
+        self.assertEqual(self.device.getCompressor(0).getActive(), False)
 
     def test_getCompressorHours(self):
         self.assertAlmostEqual(
-            self.device.compressors[0].getHours(), 13651.9)
+            self.device.getCompressor(0).getHours(), 13651.9)
 
     def test_getAvailableCompressors(self):
         self.assertEqual(self.device.getAvailableCompressors(), ['0'])
 
     def test_getCompressorStarts(self):
         self.assertAlmostEqual(
-            self.device.compressors[0].getStarts(), 6973)
+            self.device.getCompressor(0).getStarts(), 6973)
 
     def test_getCompressorHoursLoadClass1(self):
         self.assertAlmostEqual(
-            self.device.compressors[0].getHoursLoadClass1(), 366)
+            self.device.getCompressor(0).getHoursLoadClass1(), 366)
 
     def test_getCompressorHoursLoadClass2(self):
         self.assertAlmostEqual(
-            self.device.compressors[0].getHoursLoadClass2(), 5579)
+            self.device.getCompressor(0).getHoursLoadClass2(), 5579)
 
     def test_getCompressorHoursLoadClass3(self):
         self.assertAlmostEqual(
-            self.device.compressors[0].getHoursLoadClass3(), 6024)
+            self.device.getCompressor(0).getHoursLoadClass3(), 6024)
 
     def test_getCompressorHoursLoadClass4(self):
         self.assertAlmostEqual(
-            self.device.compressors[0].getHoursLoadClass4(), 659)
+            self.device.getCompressor(0).getHoursLoadClass4(), 659)
 
     def test_getCompressorHoursLoadClass5(self):
         self.assertAlmostEqual(
-            self.device.compressors[0].getHoursLoadClass5(), 715)
+            self.device.getCompressor(0).getHoursLoadClass5(), 715)
+
+    def test_getCompressorPhase(self):
+        self.assertEqual(
+            self.device.getCompressor(0).getPhase(), "off")
 
     def test_getHeatingCurveSlope(self):
         self.assertAlmostEqual(
diff --git a/tests/test_Vitocal250A.py b/tests/test_Vitocal250A.py
index fbc904f4..caa5148c 100644
--- a/tests/test_Vitocal250A.py
+++ b/tests/test_Vitocal250A.py
@@ -124,3 +124,8 @@ def test_getPowerSummaryConsumptionDomesticHotWaterLastSevenDays(self):
     def test_getPowerSummaryConsumptionDomesticHotWaterLastYear(self):
         self.assertEqual(
             self.device.getPowerSummaryConsumptionDomesticHotWaterLastYear(), 177.7)
+        
+    def test_getCompressorPhase(self):
+        self.assertEqual(
+            self.device.getCompressor(0).getPhase(), "ready")
+