Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make HeatingDevice inherit from Device #356

Merged
merged 6 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions PyViCare/PyViCareElectricalEnergySystem.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
from PyViCare.PyViCareDevice import Device
from PyViCare.PyViCareUtils import handleNotSupported
from PyViCare.PyViCareService import ViCareService


class ElectricalEnergySystem(Device):

def __init__(self, service: ViCareService) -> None:
self.service = service

@handleNotSupported
def getPointOfCommonCouplingTransferPowerExchange(self):
return self.service.getProperty("pcc.transfer.power.exchange")["properties"][
Expand Down
11 changes: 2 additions & 9 deletions PyViCare/PyViCareHeatingDevice.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from contextlib import suppress
from typing import Any, List, Optional

from PyViCare.PyViCareDevice import Device
from PyViCare.PyViCareHeatCurveCalculation import (
heat_curve_formular_variant1, heat_curve_formular_variant2)
from PyViCare.PyViCareService import ViCareService
from PyViCare.PyViCareUtils import (VICARE_DAYS,
PyViCareNotSupportedFeatureError,
ViCareTimer, handleAPICommandErrors,
Expand All @@ -29,20 +29,13 @@
return available_burners


class HeatingDevice:
class HeatingDevice(Device):
"""This is the base class for all heating devices.
This class connects to the Viessmann ViCare API.
The authentication is done through OAuth2.
Note that currently, a new token is generated for each run.
"""

def __init__(self, service: ViCareService) -> None:
self.service = service

@handleNotSupported
def getSerial(self):
return self.service.getProperty("device.serial")["properties"]["value"]["value"]

@property
def circuits(self) -> List[Any]:
return list([self.getCircuit(x) for x in self.getAvailableCircuits()])
Expand Down Expand Up @@ -487,7 +480,7 @@



""" Activate a program

Check failure on line 483 in PyViCare/PyViCareHeatingDevice.py

View workflow job for this annotation

GitHub Actions / build (3.8)

E303 too many blank lines (3)

Check failure on line 483 in PyViCare/PyViCareHeatingDevice.py

View workflow job for this annotation

GitHub Actions / build (3.9)

E303 too many blank lines (3)
NOTE
DEVICE_COMMUNICATION_ERROR can just mean that the program is already on
Parameters
Expand Down
27 changes: 3 additions & 24 deletions tests/test_VitochargeVX3.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,101 +9,80 @@
self.service = ViCareServiceMock('response/VitochargeVX3.json')
self.device = ElectricalEnergySystem(self.service)

def test_getSerial(self):
self.assertEqual(self.device.getSerial(), '################')

def test_getPointOfCommonCouplingTransferPowerExchange(self):
self.assertEqual(self.device.getPointOfCommonCouplingTransferPowerExchange(), 0)


def test_getPhotovoltaicProductionCumulatedUnit(self):
self.assertEqual(self.device.getPhotovoltaicProductionCumulatedUnit(), "wattHour")

def test_getPhotovoltaicProductionCumulatedCurrentDay(self):
self.assertEqual(self.device.getPhotovoltaicProductionCumulatedCurrentDay(), 47440)


def test_getPhotovoltaicProductionCumulatedCurrentWeek(self):
self.assertEqual(self.device.getPhotovoltaicProductionCumulatedCurrentWeek(), 208436)


def test_getPhotovoltaicProductionCumulatedCurrentMonth(self):
self.assertEqual(self.device.getPhotovoltaicProductionCumulatedCurrentMonth(), 487670)


def test_getPhotovoltaicProductionCumulatedCurrentYear(self):
self.assertEqual(self.device.getPhotovoltaicProductionCumulatedCurrentYear(), 487670)


def test_getPhotovoltaicProductionCumulatedLifeCycle(self):
self.assertEqual(self.device.getPhotovoltaicProductionCumulatedLifeCycle(), 487670)


def test_getPhotovoltaicStatus(self):
self.assertEqual(self.device.getPhotovoltaicStatus(), "ready")


def test_getPhotovoltaicProductionCurrent(self):
self.assertEqual(self.device.getPhotovoltaicProductionCurrent(), 0)


def test_getPhotovoltaicProductionCurrentUnit(self):
self.assertEqual(self.device.getPhotovoltaicProductionCurrentUnit(), "kilowatt")


def test_getPointOfCommonCouplingTransferConsumptionTotal(self):
self.assertEqual(self.device.getPointOfCommonCouplingTransferConsumptionTotal(),7700)

Check failure on line 46 in tests/test_VitochargeVX3.py

View workflow job for this annotation

GitHub Actions / build (3.6)

E231 missing whitespace after ','

Check failure on line 46 in tests/test_VitochargeVX3.py

View workflow job for this annotation

GitHub Actions / build (3.8)

E231 missing whitespace after ','

Check failure on line 46 in tests/test_VitochargeVX3.py

View workflow job for this annotation

GitHub Actions / build (3.9)

E231 missing whitespace after ','
CFenner marked this conversation as resolved.
Show resolved Hide resolved


def test_getPointOfCommonCouplingTransferConsumptionTotalUnit(self):
self.assertEqual(self.device.getPointOfCommonCouplingTransferConsumptionTotalUnit(),"wattHour")

Check failure on line 49 in tests/test_VitochargeVX3.py

View workflow job for this annotation

GitHub Actions / build (3.6)

E231 missing whitespace after ','

Check failure on line 49 in tests/test_VitochargeVX3.py

View workflow job for this annotation

GitHub Actions / build (3.8)

E231 missing whitespace after ','

Check failure on line 49 in tests/test_VitochargeVX3.py

View workflow job for this annotation

GitHub Actions / build (3.9)

E231 missing whitespace after ','
CFenner marked this conversation as resolved.
Show resolved Hide resolved


def test_getPointOfCommonCouplingTransferFeedInTotal(self):
self.assertEqual(self.device.getPointOfCommonCouplingTransferFeedInTotal(),298900)

Check failure on line 52 in tests/test_VitochargeVX3.py

View workflow job for this annotation

GitHub Actions / build (3.6)

E231 missing whitespace after ','

Check failure on line 52 in tests/test_VitochargeVX3.py

View workflow job for this annotation

GitHub Actions / build (3.8)

E231 missing whitespace after ','

Check failure on line 52 in tests/test_VitochargeVX3.py

View workflow job for this annotation

GitHub Actions / build (3.9)

E231 missing whitespace after ','
CFenner marked this conversation as resolved.
Show resolved Hide resolved


def test_getPointOfCommonCouplingTransferFeedInTotalUnit(self):
self.assertEqual(self.device.getPointOfCommonCouplingTransferFeedInTotalUnit(),"wattHour")

Check failure on line 55 in tests/test_VitochargeVX3.py

View workflow job for this annotation

GitHub Actions / build (3.6)

E231 missing whitespace after ','

Check failure on line 55 in tests/test_VitochargeVX3.py

View workflow job for this annotation

GitHub Actions / build (3.8)

E231 missing whitespace after ','

Check failure on line 55 in tests/test_VitochargeVX3.py

View workflow job for this annotation

GitHub Actions / build (3.9)

E231 missing whitespace after ','
CFenner marked this conversation as resolved.
Show resolved Hide resolved


def test_getElectricalEnergySystemTransferDischargeCumulatedUnit(self):
self.assertEqual(self.device.getElectricalEnergySystemTransferDischargeCumulatedUnit(),"wattHour")

Check failure on line 58 in tests/test_VitochargeVX3.py

View workflow job for this annotation

GitHub Actions / build (3.6)

E231 missing whitespace after ','

Check failure on line 58 in tests/test_VitochargeVX3.py

View workflow job for this annotation

GitHub Actions / build (3.8)

E231 missing whitespace after ','

Check failure on line 58 in tests/test_VitochargeVX3.py

View workflow job for this annotation

GitHub Actions / build (3.9)

E231 missing whitespace after ','
CFenner marked this conversation as resolved.
Show resolved Hide resolved


def test_getElectricalEnergySystemTransferDischargeCumulatedCurrentDay(self):
self.assertEqual(self.device.getElectricalEnergySystemTransferDischargeCumulatedCurrentDay(),4751)

Check failure on line 61 in tests/test_VitochargeVX3.py

View workflow job for this annotation

GitHub Actions / build (3.6)

E231 missing whitespace after ','

Check failure on line 61 in tests/test_VitochargeVX3.py

View workflow job for this annotation

GitHub Actions / build (3.8)

E231 missing whitespace after ','

Check failure on line 61 in tests/test_VitochargeVX3.py

View workflow job for this annotation

GitHub Actions / build (3.9)

E231 missing whitespace after ','
CFenner marked this conversation as resolved.
Show resolved Hide resolved


def test_getElectricalEnergySystemTransferDischargeCumulatedCurrentWeek(self):
self.assertEqual(self.device.getElectricalEnergySystemTransferDischargeCumulatedCurrentWeek(),29820)

Check failure on line 64 in tests/test_VitochargeVX3.py

View workflow job for this annotation

GitHub Actions / build (3.6)

E231 missing whitespace after ','
CFenner marked this conversation as resolved.
Show resolved Hide resolved

def test_getElectricalEnergySystemTransferDischargeCumulatedCurrentMonth(self):
self.assertEqual(self.device.getElectricalEnergySystemTransferDischargeCumulatedCurrentMonth(),66926)

Check failure on line 67 in tests/test_VitochargeVX3.py

View workflow job for this annotation

GitHub Actions / build (3.6)

E231 missing whitespace after ','
CFenner marked this conversation as resolved.
Show resolved Hide resolved


def test_getElectricalEnergySystemTransferDischargeCumulatedCurrentYear(self):
self.assertEqual(self.device.getElectricalEnergySystemTransferDischargeCumulatedCurrentYear(),66926)

Check failure on line 70 in tests/test_VitochargeVX3.py

View workflow job for this annotation

GitHub Actions / build (3.6)

E231 missing whitespace after ','
CFenner marked this conversation as resolved.
Show resolved Hide resolved


def test_getElectricalEnergySystemTransferDischargeCumulatedLifeCycle(self):
self.assertEqual(self.device.getElectricalEnergySystemTransferDischargeCumulatedLifeCycle(),66926)

Check failure on line 73 in tests/test_VitochargeVX3.py

View workflow job for this annotation

GitHub Actions / build (3.6)

E231 missing whitespace after ','
CFenner marked this conversation as resolved.
Show resolved Hide resolved


def test_getElectricalEnergySystemSOC(self):
self.assertEqual(self.device.getElectricalEnergySystemSOC(),91)


def test_getElectricalEnergySystemSOCUnit(self):
self.assertEqual(self.device.getElectricalEnergySystemSOCUnit(),"percent")


def test_getElectricalEnergySystemPower(self):
self.assertEqual(self.device.getElectricalEnergySystemPower(),700)


def test_getElectricalEnergySystemPowerUnit(self):
self.assertEqual(self.device.getElectricalEnergySystemPowerUnit(),"watt")

def test_getElectricalEnergySystemOperationState(self):
self.assertEqual(self.device.getElectricalEnergySystemOperationState(),"discharge")



Loading