diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..0c6b19b --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,29 @@ +name: Test + +# The build workflow needs API credentials, which pull requests from forks do not +# get. These tests decode recorded responses instead, so they need no secrets. +on: + pull_request: + push: + branches: + - main + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.10', '3.12', '3.13'] + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt pytest pytest-asyncio mypy + - name: Test + run: python -m pytest tests -q + - name: Type check + run: mypy -p weheat.abstractions --install-types --non-interactive diff --git a/.gitignore b/.gitignore index 6dfe248..ec7e270 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /venv/ /weheat_backend_client.egg-info/ +/weheat.egg-info/ /build/ /.idea/ *.pyc \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index a470bec..92f0ada 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "weheat" -version = "2026.4.8" +version = "2026.9.2" description = "Weheat Backend" authors = ["Jesper Raemaekers ", "Kjell van Straaten "] license = "MIT" @@ -10,7 +10,7 @@ keywords = ["OpenAPI", "OpenAPI-Generator", "Weheat Backend"] include = ["weheat/py.typed"] [tool.poetry.dependencies] -python = "^3.7" +python = "^3.10" urllib3 = ">= 1.25.3" python-dateutil = ">=2.8.2" diff --git a/setup.py b/setup.py index a5b3151..56d941c 100644 --- a/setup.py +++ b/setup.py @@ -21,8 +21,8 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools NAME = "weheat" -VERSION = "2026.4.8" -PYTHON_REQUIRES = ">=3.7" +VERSION = "2026.9.2" +PYTHON_REQUIRES = ">=3.10" REQUIRES = [ "urllib3 >= 1.25.3, < 3.0.0", "python-dateutil", diff --git a/tests/conftest.py b/tests/conftest.py index 71d9121..1e42620 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,6 +1,5 @@ import pytest from dataclasses import dataclass -from keycloak import KeycloakOpenID def pytest_addoption(parser): # These are used by the STK500 interface @@ -10,42 +9,42 @@ def pytest_addoption(parser): action="store", type=str, help="API url", - required=True, + default=None, ) parser.addoption( "--auth_url", action="store", type=str, help="Authentication url", - required=True, + default=None, ) parser.addoption( "--client_id", action="store", type=str, help="Client id", - required=True, + default=None, ) parser.addoption( "--client_secret", action="store", type=str, help="Client secret", - required=True, + default=None, ) parser.addoption( "--user", action="store", type=str, help="User email", - required=True, + default=None, ) parser.addoption( "--password", action="store", type=str, help="User password", - required=True, + default=None, ) @@ -63,8 +62,17 @@ class ApiInfo: access_token: str +OPTIONS = ("api_url", "auth_url", "client_id", "client_secret", "user", "password") + + @pytest.fixture() def api_fixture(request): + missing = [name for name in OPTIONS if not request.config.getoption(f"--{name}")] + if missing: + pytest.skip(f"needs the API options: {', '.join('--' + name for name in missing)}") + + from keycloak import KeycloakOpenID + api_info = ApiInfo(request.config.getoption('--api_url'), request.config.getoption('--auth_url'), request.config.getoption('--client_id'), request.config.getoption('--client_secret'), request.config.getoption('--user'), request.config.getoption('--password'), "") diff --git a/tests/fixtures/energy_total.json b/tests/fixtures/energy_total.json new file mode 100644 index 0000000..610176d --- /dev/null +++ b/tests/fixtures/energy_total.json @@ -0,0 +1,20 @@ +{ + "totalEInHeating": 5717.358, + "totalEInStandby": 103.82725, + "totalEInDhw": 2143.2793, + "totalEInHeatingDefrost": 36.181, + "totalEInDhwDefrost": 0.045924444, + "totalEInCooling": 832.4635, + "totalEOutHeating": 27152.229, + "totalEOutDhw": 6509.1094, + "totalEOutHeatingDefrost": -799.50616, + "totalEOutDhwDefrost": -1.0773816, + "totalEOutCooling": -4438.936, + "totalEInIUStandby": 245.75871, + "totalEInIUHeating": 426.02554, + "totalEInIUDhw": 252.08315, + "totalEInIUHeatingDefrost": 22.127708, + "totalEInIUDhwDefrost": 0.038020276, + "totalEInIUCooling": 95.72314, + "heatPumpId": "00000000-0000-4000-8000-000000000000" +} diff --git a/tests/fixtures/heat_pump.json b/tests/fixtures/heat_pump.json new file mode 100644 index 0000000..d24f141 --- /dev/null +++ b/tests/fixtures/heat_pump.json @@ -0,0 +1,13 @@ +{ + "controlBoardId": "11111111-1111-4111-8111-111111111111", + "name": null, + "model": 0, + "dhwType": 1, + "boilerType": 1, + "status": 70, + "commissionedAt": "2024-07-05T16:00:00Z", + "serialNumber": "SN-0000-0000", + "partNumber": "2580-2255-2903", + "state": 3, + "id": "00000000-0000-4000-8000-000000000000" +} diff --git a/tests/fixtures/heat_pumps_list.json b/tests/fixtures/heat_pumps_list.json new file mode 100644 index 0000000..602ef79 --- /dev/null +++ b/tests/fixtures/heat_pumps_list.json @@ -0,0 +1,24 @@ +{ + "metadata": { + "totalCount": 1, + "pageSize": 10, + "currentPage": 1, + "totalPages": 1 + }, + "data": [ + { + "firmwareVersion": null, + "controlBoardId": "11111111-1111-4111-8111-111111111111", + "name": null, + "model": 0, + "dhwType": 1, + "boilerType": 1, + "status": 40, + "commissionedAt": "2024-07-05T16:00:00Z", + "serialNumber": "SN-0000-0000", + "partNumber": "2580-2255-2903", + "state": 3, + "id": "00000000-0000-4000-8000-000000000000" + } + ] +} diff --git a/tests/fixtures/log_aggregated_cooling.json b/tests/fixtures/log_aggregated_cooling.json new file mode 100644 index 0000000..4c49653 --- /dev/null +++ b/tests/fixtures/log_aggregated_cooling.json @@ -0,0 +1,122 @@ +{ + "timeBucket": "2026-09-01T12:26:00Z", + "interval": "Minute", + "timeCoveredInInterval": 60, + "heatPumpStateStandby": 0, + "heatPumpStateHeating": 0, + "heatPumpStateCooling": 60, + "heatPumpStateHeatingDefrost": 0, + "heatPumpStateDhwDefrost": 0, + "heatPumpStateDhw": 0, + "heatPumpStateLegionella": 0, + "heatPumpStateManualControl": 0, + "controlBridgeStatusWaterPump": 60, + "controlBridgeStatusDhwValve": 0, + "controlBridgeStatusGasBoiler": 0, + "controlBridgeStatusElectricHeater": 0, + "controlBridgeStatusWaterPump2": 60, + "t1Average": 53.4, + "t1Min": 53.4, + "t1Max": 53.4, + "t2Average": 48.1, + "t2Min": 48.1, + "t2Max": 48.1, + "tAirInAverage": 21.1, + "tAirInMin": 20.9, + "tAirInMax": 21.2, + "tAirOutAverage": 21.4, + "tAirOutMin": 20.4, + "tAirOutMax": 22.2, + "tWaterInAverage": 21.4, + "tWaterInMin": 21.4, + "tWaterInMax": 21.4, + "tWaterOutAverage": 18.8, + "tWaterOutMin": 18.3, + "tWaterOutMax": 19.1, + "tWaterHouseInAverage": 19.7, + "tWaterHouseInMin": 19.2, + "tWaterHouseInMax": 20, + "rpmAverage": 900, + "rpmMin": 900, + "rpmMax": 900, + "thermostatStateOff": 60, + "thermostatStateOn": 0, + "tRoomAverage": 22.1, + "tRoomMin": 22.1, + "tRoomMax": 22.1, + "tRoomTargetAverage": 21, + "tRoomTargetMin": 21, + "tRoomTargetMax": 21, + "tThermostatSetpointAverage": 18, + "tThermostatSetpointMin": 18, + "tThermostatSetpointMax": 18, + "otBoilerFeedTemperatureAverage": null, + "otBoilerFeedTemperatureMin": null, + "otBoilerFeedTemperatureMax": null, + "otBoilerReturnTemperatureAverage": null, + "otBoilerReturnTemperatureMin": null, + "otBoilerReturnTemperatureMax": null, + "centralHeatingFlowAverage": 1.3, + "centralHeatingFlowMin": 1.29, + "centralHeatingFlowMax": 1.32, + "centralHeatingFlowStateStandby": 0, + "centralHeatingFlowStateStandbyNoPwm": 0, + "centralHeatingFlowStateMotorBlocked": 0, + "centralHeatingFlowStatePumping": 60, + "centralHeatingFlowStatePumpingNoPwm": 0, + "centralHeatingFlowStateSuboptimalRunning": 0, + "centralHeatingFlowStateStoppedMomentarily": 0, + "centralHeatingFlowStateStoppedPermanentDamage": 0, + "dhwFlowAverage": null, + "dhwFlowMin": null, + "dhwFlowMax": null, + "dhwFlowStateStandby": 0, + "dhwFlowStateStandbyNoPwm": 60, + "dhwFlowStateMotorBlocked": 0, + "dhwFlowStatePumping": 0, + "dhwFlowStatePumpingNoPwm": 0, + "dhwFlowStateSuboptimalRunning": 0, + "dhwFlowStateStoppedMomentarily": 0, + "dhwFlowStateStoppedPermanentDamage": 0, + "hqMessageVersionMin": 1, + "hqMessageVersionMax": 1, + "dhwControlMethodFixedSetpoint": 0, + "dhwControlMethodManualSchedule": 0, + "dhwControlMethodWeheatIntelligence": 0, + "dhwTargetTemperatureAverage": 55, + "dhwTargetTemperatureMin": 55, + "dhwTargetTemperatureMax": 55, + "coolingExponentialBackoffAverage": 180, + "coolingExponentialBackoffMin": 180, + "coolingExponentialBackoffMax": 180, + "coolingStartConditionsControlMethod": 60, + "coolingStartConditionsDtc": 60, + "coolingStartConditionsOutsideAirTemperature": 60, + "coolingStartConditionsInsideTemperature": 60, + "coolingStartConditionsIndoorUnitConnected": 60, + "coolingStartConditionsWaterToAir": 60, + "coolingStartConditionsDemand": 15, + "coolingStartConditionsWaterTemperature": 60, + "coolingStartConditionsContactNotBlocked": 60, + "coolingStartConditionsExBackoff": 60, + "coolingStartConditionsHeatCoolDelay": 60, + "coolingPauseReasonNone": 60, + "coolingPauseReasonRoomTemperatureTooLow": 0, + "coolingPauseReasonOutsideTemperatureTooLow": 0, + "coolingPauseReasonOutsideColderThenWaterTemperature": 0, + "coolingPauseReasonWaterTemperatureBelowSetpoint": 0, + "coolingPauseReasonHeatPumpControl": 0, + "coolingPauseReasonWaterTemperatureBelowDewpoint": 0, + "coolingPauseReasonContactBlocked": 0, + "coolingPauseReasonDemand": 0, + "coolingStopReasonNone": 60, + "coolingStopReasonDtc": 0, + "coolingStopReasonControlMethod": 0, + "coolingStopReasonNoIndoorUnitCommunication": 0, + "coolingStopReasonHeatPumpControl": 0, + "coolingStopReasonCoolingControl": 0, + "coolingStopReasonSwitchOver": 0, + "coolingStopReasonOtCoolingDisabled": 0, + "lastCoolingTimeMin": null, + "lastCoolingTimeMax": null +} diff --git a/tests/fixtures/log_aggregated_dhw.json b/tests/fixtures/log_aggregated_dhw.json new file mode 100644 index 0000000..62debd0 --- /dev/null +++ b/tests/fixtures/log_aggregated_dhw.json @@ -0,0 +1,122 @@ +{ + "timeBucket": "2026-09-01T18:36:00Z", + "interval": "Minute", + "timeCoveredInInterval": 60, + "heatPumpStateStandby": 0, + "heatPumpStateHeating": 0, + "heatPumpStateCooling": 0, + "heatPumpStateHeatingDefrost": 0, + "heatPumpStateDhwDefrost": 0, + "heatPumpStateDhw": 60, + "heatPumpStateLegionella": 0, + "heatPumpStateManualControl": 0, + "controlBridgeStatusWaterPump": 60, + "controlBridgeStatusDhwValve": 60, + "controlBridgeStatusGasBoiler": 0, + "controlBridgeStatusElectricHeater": 0, + "controlBridgeStatusWaterPump2": 0, + "t1Average": 51.8, + "t1Min": 51.8, + "t1Max": 51.9, + "t2Average": 39.5, + "t2Min": 39, + "t2Max": 40.1, + "tAirInAverage": 17.9, + "tAirInMin": 17.7, + "tAirInMax": 18.2, + "tAirOutAverage": 15.1, + "tAirOutMin": 13.7, + "tAirOutMax": 16.9, + "tWaterInAverage": 30.4, + "tWaterInMin": 29.8, + "tWaterInMax": 31.1, + "tWaterOutAverage": 33.8, + "tWaterOutMin": 31.7, + "tWaterOutMax": 34.8, + "tWaterHouseInAverage": 19.7, + "tWaterHouseInMin": 19.2, + "tWaterHouseInMax": 20, + "rpmAverage": 2070, + "rpmMin": 1980, + "rpmMax": 2100, + "thermostatStateOff": 60, + "thermostatStateOn": 0, + "tRoomAverage": 22.1, + "tRoomMin": 22.1, + "tRoomMax": 22.1, + "tRoomTargetAverage": 21, + "tRoomTargetMin": 21, + "tRoomTargetMax": 21, + "tThermostatSetpointAverage": 18, + "tThermostatSetpointMin": 18, + "tThermostatSetpointMax": 18, + "otBoilerFeedTemperatureAverage": null, + "otBoilerFeedTemperatureMin": null, + "otBoilerFeedTemperatureMax": null, + "otBoilerReturnTemperatureAverage": null, + "otBoilerReturnTemperatureMin": null, + "otBoilerReturnTemperatureMax": null, + "centralHeatingFlowAverage": null, + "centralHeatingFlowMin": null, + "centralHeatingFlowMax": null, + "centralHeatingFlowStateStandby": 60, + "centralHeatingFlowStateStandbyNoPwm": 0, + "centralHeatingFlowStateMotorBlocked": 0, + "centralHeatingFlowStatePumping": 0, + "centralHeatingFlowStatePumpingNoPwm": 0, + "centralHeatingFlowStateSuboptimalRunning": 0, + "centralHeatingFlowStateStoppedMomentarily": 0, + "centralHeatingFlowStateStoppedPermanentDamage": 0, + "dhwFlowAverage": 1.14, + "dhwFlowMin": 1.14, + "dhwFlowMax": 1.14, + "dhwFlowStateStandby": 0, + "dhwFlowStateStandbyNoPwm": 0, + "dhwFlowStateMotorBlocked": 0, + "dhwFlowStatePumping": 60, + "dhwFlowStatePumpingNoPwm": 0, + "dhwFlowStateSuboptimalRunning": 0, + "dhwFlowStateStoppedMomentarily": 0, + "dhwFlowStateStoppedPermanentDamage": 0, + "hqMessageVersionMin": 1, + "hqMessageVersionMax": 1, + "dhwControlMethodFixedSetpoint": 0, + "dhwControlMethodManualSchedule": 0, + "dhwControlMethodWeheatIntelligence": 0, + "dhwTargetTemperatureAverage": 55, + "dhwTargetTemperatureMin": 55, + "dhwTargetTemperatureMax": 55, + "coolingExponentialBackoffAverage": 180, + "coolingExponentialBackoffMin": 180, + "coolingExponentialBackoffMax": 180, + "coolingStartConditionsControlMethod": 60, + "coolingStartConditionsDtc": 60, + "coolingStartConditionsOutsideAirTemperature": 15, + "coolingStartConditionsInsideTemperature": 60, + "coolingStartConditionsIndoorUnitConnected": 60, + "coolingStartConditionsWaterToAir": 60, + "coolingStartConditionsDemand": 15, + "coolingStartConditionsWaterTemperature": 60, + "coolingStartConditionsContactNotBlocked": 60, + "coolingStartConditionsExBackoff": 0, + "coolingStartConditionsHeatCoolDelay": 60, + "coolingPauseReasonNone": 60, + "coolingPauseReasonRoomTemperatureTooLow": 0, + "coolingPauseReasonOutsideTemperatureTooLow": 0, + "coolingPauseReasonOutsideColderThenWaterTemperature": 0, + "coolingPauseReasonWaterTemperatureBelowSetpoint": 0, + "coolingPauseReasonHeatPumpControl": 0, + "coolingPauseReasonWaterTemperatureBelowDewpoint": 0, + "coolingPauseReasonContactBlocked": 0, + "coolingPauseReasonDemand": 0, + "coolingStopReasonNone": 0, + "coolingStopReasonDtc": 0, + "coolingStopReasonControlMethod": 0, + "coolingStopReasonNoIndoorUnitCommunication": 0, + "coolingStopReasonHeatPumpControl": 60, + "coolingStopReasonCoolingControl": 0, + "coolingStopReasonSwitchOver": 0, + "coolingStopReasonOtCoolingDisabled": 0, + "lastCoolingTimeMin": "2026-09-01T18:08:44Z", + "lastCoolingTimeMax": "2026-09-01T18:08:44Z" +} diff --git a/tests/fixtures/log_aggregated_heating_old_firmware.json b/tests/fixtures/log_aggregated_heating_old_firmware.json new file mode 100644 index 0000000..5a630d6 --- /dev/null +++ b/tests/fixtures/log_aggregated_heating_old_firmware.json @@ -0,0 +1,122 @@ +{ + "timeBucket": "2026-01-01T18:30:00Z", + "interval": "Minute", + "timeCoveredInInterval": 60, + "heatPumpStateStandby": 0, + "heatPumpStateHeating": 60, + "heatPumpStateCooling": 0, + "heatPumpStateHeatingDefrost": 0, + "heatPumpStateDhwDefrost": 0, + "heatPumpStateDhw": 0, + "heatPumpStateLegionella": 0, + "heatPumpStateManualControl": 0, + "controlBridgeStatusWaterPump": 60, + "controlBridgeStatusDhwValve": 60, + "controlBridgeStatusGasBoiler": 0, + "controlBridgeStatusElectricHeater": 0, + "controlBridgeStatusWaterPump2": 60, + "t1Average": 63.5, + "t1Min": 63.5, + "t1Max": 63.5, + "t2Average": 25, + "t2Min": 24.9, + "t2Max": 25, + "tAirInAverage": 4.4, + "tAirInMin": 4.3, + "tAirInMax": 4.4, + "tAirOutAverage": 0.9, + "tAirOutMin": 0.8, + "tAirOutMax": 0.9, + "tWaterInAverage": 24.5, + "tWaterInMin": 24.5, + "tWaterInMax": 24.5, + "tWaterOutAverage": 27.1, + "tWaterOutMin": 27.1, + "tWaterOutMax": 27.1, + "tWaterHouseInAverage": 27.5, + "tWaterHouseInMin": 27.5, + "tWaterHouseInMax": 27.5, + "rpmAverage": 1620, + "rpmMin": 1620, + "rpmMax": 1620, + "thermostatStateOff": 60, + "thermostatStateOn": 0, + "tRoomAverage": 20.7, + "tRoomMin": 20.7, + "tRoomMax": 20.7, + "tRoomTargetAverage": 21, + "tRoomTargetMin": 21, + "tRoomTargetMax": 21, + "tThermostatSetpointAverage": 27.5, + "tThermostatSetpointMin": 27.4, + "tThermostatSetpointMax": 27.5, + "otBoilerFeedTemperatureAverage": null, + "otBoilerFeedTemperatureMin": null, + "otBoilerFeedTemperatureMax": null, + "otBoilerReturnTemperatureAverage": null, + "otBoilerReturnTemperatureMin": null, + "otBoilerReturnTemperatureMax": null, + "centralHeatingFlowAverage": 1.3, + "centralHeatingFlowMin": 1.29, + "centralHeatingFlowMax": 1.32, + "centralHeatingFlowStateStandby": 0, + "centralHeatingFlowStateStandbyNoPwm": 0, + "centralHeatingFlowStateMotorBlocked": 0, + "centralHeatingFlowStatePumping": 60, + "centralHeatingFlowStatePumpingNoPwm": 0, + "centralHeatingFlowStateSuboptimalRunning": 0, + "centralHeatingFlowStateStoppedMomentarily": 0, + "centralHeatingFlowStateStoppedPermanentDamage": 0, + "dhwFlowAverage": null, + "dhwFlowMin": null, + "dhwFlowMax": null, + "dhwFlowStateStandby": 60, + "dhwFlowStateStandbyNoPwm": 0, + "dhwFlowStateMotorBlocked": 0, + "dhwFlowStatePumping": 0, + "dhwFlowStatePumpingNoPwm": 0, + "dhwFlowStateSuboptimalRunning": 0, + "dhwFlowStateStoppedMomentarily": 0, + "dhwFlowStateStoppedPermanentDamage": 0, + "hqMessageVersionMin": null, + "hqMessageVersionMax": null, + "dhwControlMethodFixedSetpoint": null, + "dhwControlMethodManualSchedule": null, + "dhwControlMethodWeheatIntelligence": null, + "dhwTargetTemperatureAverage": null, + "dhwTargetTemperatureMin": null, + "dhwTargetTemperatureMax": null, + "coolingExponentialBackoffAverage": null, + "coolingExponentialBackoffMin": null, + "coolingExponentialBackoffMax": null, + "coolingStartConditionsControlMethod": null, + "coolingStartConditionsDtc": null, + "coolingStartConditionsOutsideAirTemperature": null, + "coolingStartConditionsInsideTemperature": null, + "coolingStartConditionsIndoorUnitConnected": null, + "coolingStartConditionsWaterToAir": null, + "coolingStartConditionsDemand": null, + "coolingStartConditionsWaterTemperature": null, + "coolingStartConditionsContactNotBlocked": null, + "coolingStartConditionsExBackoff": null, + "coolingStartConditionsHeatCoolDelay": null, + "coolingPauseReasonNone": null, + "coolingPauseReasonRoomTemperatureTooLow": null, + "coolingPauseReasonOutsideTemperatureTooLow": null, + "coolingPauseReasonOutsideColderThenWaterTemperature": null, + "coolingPauseReasonWaterTemperatureBelowSetpoint": null, + "coolingPauseReasonHeatPumpControl": null, + "coolingPauseReasonWaterTemperatureBelowDewpoint": null, + "coolingPauseReasonContactBlocked": null, + "coolingPauseReasonDemand": null, + "coolingStopReasonNone": null, + "coolingStopReasonDtc": null, + "coolingStopReasonControlMethod": null, + "coolingStopReasonNoIndoorUnitCommunication": null, + "coolingStopReasonHeatPumpControl": null, + "coolingStopReasonCoolingControl": null, + "coolingStopReasonSwitchOver": null, + "coolingStopReasonOtCoolingDisabled": null, + "lastCoolingTimeMin": null, + "lastCoolingTimeMax": null +} diff --git a/tests/fixtures/log_latest_cooling.json b/tests/fixtures/log_latest_cooling.json new file mode 100644 index 0000000..1a3048c --- /dev/null +++ b/tests/fixtures/log_latest_cooling.json @@ -0,0 +1,40 @@ +{ + "heatPumpId": "00000000-0000-4000-8000-000000000000", + "timestamp": "2026-08-29T12:44:05.9700858Z", + "state": 132, + "controlBridgeStatus": 4286582803, + "controlBridgeStatusDecodedWaterPump": true, + "controlBridgeStatusDecodedDhwValve": true, + "controlBridgeStatusDecodedGasBoiler": false, + "controlBridgeStatusDecodedElectricHeater": false, + "controlBridgeStatusDecodedWaterPump2": true, + "inputStatus": 29, + "t1": 54.4, + "t2": 53.5, + "tAirIn": 23, + "tAirOut": 25, + "tWaterIn": 20.9, + "tWaterOut": 18.5, + "tWaterHouseIn": 19.2, + "rpm": 900, + "cmMassPowerIn": 521, + "cmMassPowerOut": -2671, + "onOffThermostatState": 0, + "tRoom": 22.1, + "tRoomTarget": 21, + "tThermostatSetpoint": 18, + "otBoilerFeedTemperature": null, + "otBoilerReturnTemperature": null, + "centralHeatingFlow": 48, + "dhwFlow": 2, + "hqMessageVersion": 1, + "dhwControlMethod": 1, + "dhwTargetTemperature": 55, + "coolingExponentialBackoff": 60, + "coolingStartConditions": 1983, + "coolingPauseReason": 4, + "coolingStopReason": 0, + "lastCoolingTime": "2026-08-29T10:32:28Z", + "interval": 15, + "isOnline": true +} diff --git a/tests/fixtures/log_latest_standby.json b/tests/fixtures/log_latest_standby.json new file mode 100644 index 0000000..4a5fc57 --- /dev/null +++ b/tests/fixtures/log_latest_standby.json @@ -0,0 +1,40 @@ +{ + "heatPumpId": "00000000-0000-4000-8000-000000000000", + "timestamp": "2026-09-02T07:17:57.5578988Z", + "state": 40, + "controlBridgeStatus": 4286582787, + "controlBridgeStatusDecodedWaterPump": true, + "controlBridgeStatusDecodedDhwValve": true, + "controlBridgeStatusDecodedGasBoiler": false, + "controlBridgeStatusDecodedElectricHeater": false, + "controlBridgeStatusDecodedWaterPump2": false, + "inputStatus": 29, + "t1": 53.7, + "t2": 52.8, + "tAirIn": 17.2, + "tAirOut": 16.2, + "tWaterIn": 22.3, + "tWaterOut": 22.3, + "tWaterHouseIn": 22.3, + "rpm": 0, + "cmMassPowerIn": 10, + "cmMassPowerOut": 0, + "onOffThermostatState": 0, + "tRoom": 21, + "tRoomTarget": 20, + "tThermostatSetpoint": 10, + "otBoilerFeedTemperature": null, + "otBoilerReturnTemperature": null, + "centralHeatingFlow": 2, + "dhwFlow": 2, + "hqMessageVersion": 1, + "dhwControlMethod": 1, + "dhwTargetTemperature": 55, + "coolingExponentialBackoff": 180, + "coolingStartConditions": 2043, + "coolingPauseReason": 0, + "coolingStopReason": 4, + "lastCoolingTime": "2026-09-01T18:08:44Z", + "interval": 15, + "isOnline": true +} diff --git a/tests/test_fixtures.py b/tests/test_fixtures.py new file mode 100644 index 0000000..d1039d8 --- /dev/null +++ b/tests/test_fixtures.py @@ -0,0 +1,181 @@ +"""Tests that decode recorded API responses. + +The fixtures are real responses with identifying fields replaced. They guard +against the generated models silently dropping fields the backend has started +reporting, which the models do because from_dict builds from a fixed key list. +""" +import json +import pathlib + +import pytest + +from weheat.abstractions.heat_pump import HeatPump +from weheat.models import TotalEnergyAggregate +from weheat.models.heat_pump_log_view_dto import HeatPumpLogViewDto +from weheat.models.raw_heatpump_log_and_is_online_dto import RawHeatpumpLogAndIsOnlineDto +from weheat.models.read_all_heat_pump_dto_paged_response import ReadAllHeatPumpDtoPagedResponse +from weheat.models.read_heat_pump_dto import ReadHeatPumpDto + +FIXTURES = pathlib.Path(__file__).parent / "fixtures" + + +def load(name: str) -> dict: + """Return the recorded response with the given name.""" + return json.loads((FIXTURES / name).read_text()) + + +def dropped_fields(payload: dict, decoded: dict) -> set: + """Return the keys the model did not keep.""" + return set(payload) - set(decoded) + + +@pytest.mark.parametrize( + ("name", "model"), + [ + ("log_latest_cooling.json", RawHeatpumpLogAndIsOnlineDto), + ("log_latest_standby.json", RawHeatpumpLogAndIsOnlineDto), + ("energy_total.json", TotalEnergyAggregate), + ("heat_pump.json", ReadHeatPumpDto), + ], +) +def test_no_field_is_dropped(name, model): + """Test the model keeps every field the backend sent. + + from_dict picks keys one by one, so a field the backend adds is discarded + without any error until it is added to the model as well. + """ + payload = load(name) + + assert not dropped_fields(payload, model.from_dict(payload).to_dict()) + + +def test_no_field_is_dropped_from_the_heat_pump_list(): + """Test the paged heat pump list keeps every field the backend sent.""" + payload = load("heat_pumps_list.json") + + decoded = ReadAllHeatPumpDtoPagedResponse.from_dict(payload).to_dict() + + assert not dropped_fields(payload, decoded) + assert not dropped_fields(payload["data"][0], decoded["data"][0]) + + +def test_cooling_log(): + """Test a log recorded while the heat pump was cooling.""" + pump = HeatPump("https://example.invalid", "heat-pump") + pump._last_log = RawHeatpumpLogAndIsOnlineDto.from_dict(load("log_latest_cooling.json")) + + assert pump.heat_pump_state is HeatPump.State.COOLING + assert pump.cooling_activity is HeatPump.CoolingActivity.ACTIVE + assert pump.is_online is True + assert pump.dhw_target_temperature == 55 + assert pump.dhw_control_method is HeatPump.DhwControlMethod.FIXED + # heat is removed from the water while cooling, so the output power is negative + assert pump.power_output == -2671 + assert pump.cop == pytest.approx(5.126, abs=0.001) + # every start condition is met except the demand for cooling + assert pump.cooling_start_conditions["demand"] is False + assert pump.cooling_pause_reason is HeatPump.CoolingPauseReason.WATER_TEMPERATURE_BELOW_SETPOINT + # the restart delay is counted in minutes from the last cooling cycle + assert pump.cooling_available_from.isoformat() == "2026-08-29T11:32:28+00:00" + + +def test_standby_log(): + """Test a log recorded after cooling was stopped for another function.""" + pump = HeatPump("https://example.invalid", "heat-pump") + pump._last_log = RawHeatpumpLogAndIsOnlineDto.from_dict(load("log_latest_standby.json")) + + assert pump.heat_pump_state is HeatPump.State.STANDBY + assert pump.cooling_activity is HeatPump.CoolingActivity.STOPPED + assert pump.cooling_stop_reason is HeatPump.CoolingStopReason.HEAT_PUMP_CONTROL + # only the outside air temperature is holding cooling off + unmet = [name for name, met in pump.cooling_start_conditions.items() if not met] + assert unmet == ["outside_air_temperature"] + # the pump is idle, so it reports no flow through either circuit + assert pump.central_heating_flow_volume == 0 + assert pump.compressor_rpm == 0 + + +def test_energy_total(): + """Test the recorded energy totals add up the way the properties report them.""" + pump = HeatPump("https://example.invalid", "heat-pump") + pump._energy_total = TotalEnergyAggregate.from_dict(load("energy_total.json")) + + assert pump.energy_in_heating == pytest.approx(5717.358) + assert pump.energy_in_defrost == pytest.approx(36.181 + 0.045924444) + # energy removed from the water is reported as a negative amount + assert pump.energy_out_cooling < 0 + assert pump.energy_total == pytest.approx( + 5717.358 + 2143.2793 + 832.4635 + 103.82725 + 36.181 + 0.045924444 + ) + # the indoor unit is metered separately, and is not part of that total + assert pump.energy_in_indoor_unit == pytest.approx( + 426.02554 + 252.08315 + 95.72314 + 245.75871 + 22.127708 + 0.038020276 + ) + assert pump.energy_in_indoor_unit < pump.energy_total + + +@pytest.mark.parametrize( + "name", + [ + "log_aggregated_cooling.json", + "log_aggregated_dhw.json", + "log_aggregated_heating_old_firmware.json", + ], +) +@pytest.mark.xfail( + strict=True, + reason="the aggregated log model predates the cooling and DHW fields, so it " + "drops all of them; regenerating the models from the spec fixes this", +) +def test_no_field_is_dropped_from_the_aggregated_log(name): + """Test the aggregated log model keeps every field the backend sent.""" + payload = load(name) + + assert not dropped_fields(payload, HeatPumpLogViewDto.from_dict(payload).to_dict()) + + +def test_cooling_is_stopped_when_dhw_takes_over(): + """Test the recorded buckets show what stops a cooling cycle. + + The stop reason turns to HeatPumpControl exactly when the heat pump switches + to DHW, which is what that reason means: another function took priority. + """ + cooling = load("log_aggregated_cooling.json") + dhw = load("log_aggregated_dhw.json") + + assert cooling["heatPumpStateCooling"] == 60 + assert cooling["coolingStopReasonNone"] == 60 + assert dhw["heatPumpStateDhw"] == 60 + assert dhw["coolingStopReasonHeatPumpControl"] == 60 + + +def test_older_firmware_reports_the_cooling_fields_as_null(): + """Test the backend sends the cooling fields even for firmware that predates them. + + The fields are present and null rather than missing, which is what lets a + consumer tell "this heat pump does not report cooling" from "this response + is from before cooling existed": both look the same, and both mean no cooling. + """ + payload = load("log_aggregated_heating_old_firmware.json") + current = load("log_aggregated_cooling.json") + + assert set(payload) == set(current) + assert payload["hqMessageVersionMin"] is None + assert current["hqMessageVersionMin"] == 1 + assert all( + payload[key] is None for key in payload if key.startswith("coolingStartConditions") + ) + + +def test_a_heat_pump_without_the_cooling_fields_reports_no_cooling(): + """Test a log from firmware without cooling decodes to no cooling at all.""" + pump = HeatPump("https://example.invalid", "heat-pump") + pump._last_log = RawHeatpumpLogAndIsOnlineDto.model_validate( + {"heat_pump_id": "heat-pump", "timestamp": "2026-01-01T18:30:00+00:00", + "interval": 15, "state": 70} + ) + + assert pump.heat_pump_state is HeatPump.State.HEATING + assert pump.cooling_activity is None + assert pump.cooling_start_conditions is None + assert pump.cooling_available_from is None diff --git a/tests/test_ha_api.py b/tests/test_ha_api.py index 47737f8..1962bac 100644 --- a/tests/test_ha_api.py +++ b/tests/test_ha_api.py @@ -84,7 +84,13 @@ async def test_hp_log(api_fixture, uuid): if heatpump.thermostat_room_temperature is not None: #thermostat may be disconnected assert heatpump.thermostat_room_temperature >= -1 assert heatpump.power_input is None or heatpump.power_input >= 0 - assert heatpump.power_output is None or heatpump.power_output >= 0 + if heatpump.heat_pump_state in (HeatPump.State.COOLING, HeatPump.State.DEFROSTING): + # heat is removed from the water in these states, so the output power is negative + assert heatpump.power_output is None or heatpump.power_output <= 0 + else: + assert heatpump.power_output is None or heatpump.power_output >= 0 + # the coefficient of performance is a positive ratio in every state + assert heatpump.cop is None or heatpump.cop >= 0 assert heatpump.compressor_rpm >= 0 assert heatpump.heat_pump_state in HeatPump.State assert heatpump.energy_in_heating >= 0 diff --git a/tests/test_heat_pump.py b/tests/test_heat_pump.py new file mode 100644 index 0000000..8f15677 --- /dev/null +++ b/tests/test_heat_pump.py @@ -0,0 +1,185 @@ +"""Unit tests for the decoding the HeatPump abstraction does on a log. + +These run without API credentials, unlike the tests in test_ha_api.py. +""" +import pytest + +from weheat.abstractions.heat_pump import HeatPump +from weheat.models.raw_heatpump_log_and_is_online_dto import RawHeatpumpLogAndIsOnlineDto + +BASE_LOG = { + "heat_pump_id": "0000-1111-2222-3333", + "timestamp": "2026-08-31T10:00:00+00:00", + "interval": 15, +} + + +def heat_pump(**fields) -> HeatPump: + """Build a heat pump holding a log with the given fields.""" + pump = HeatPump("https://example.invalid", "0000-1111-2222-3333") + pump._last_log = RawHeatpumpLogAndIsOnlineDto.model_validate({**BASE_LOG, **fields}) + return pump + + +@pytest.mark.parametrize( + ("state", "expected"), + [ + (1, HeatPump.State.OFFLINE), + (40, HeatPump.State.STANDBY), + (70, HeatPump.State.HEATING), + (84, HeatPump.State.DEFROSTING), + (90, HeatPump.State.DEFROSTING), + (120, HeatPump.State.DEFROSTING), + (130, HeatPump.State.COOLING), + (136, HeatPump.State.WATER_CHECK), + (137, HeatPump.State.COOLING), + (138, None), + (150, HeatPump.State.DHW), + (200, HeatPump.State.DEFROSTING), + (239, HeatPump.State.DEFROSTING), + (240, None), + (1010, HeatPump.State.UPDATING), + ], +) +def test_heat_pump_state(state, expected): + """Test the numeric state maps to the state the heat pump is in.""" + assert heat_pump(state=state).heat_pump_state is expected + + +@pytest.mark.parametrize( + ("fields", "expected"), + [ + ({"state": 132, "cooling_pause_reason": 0}, HeatPump.CoolingActivity.ACTIVE), + ({"state": 131, "cooling_pause_reason": 0}, HeatPump.CoolingActivity.STARTING), + ({"state": 136, "cooling_pause_reason": 0}, HeatPump.CoolingActivity.WATER_CHECK), + ({"state": 40, "cooling_pause_reason": 0}, HeatPump.CoolingActivity.WAITING), + ({"state": 40, "cooling_pause_reason": 4}, HeatPump.CoolingActivity.PAUSED), + ( + {"state": 40, "cooling_pause_reason": 0, "cooling_stop_reason": 1}, + HeatPump.CoolingActivity.STOPPED, + ), + # a pause reason only counts while the heat pump is in standby + ({"state": 70, "cooling_pause_reason": 4}, HeatPump.CoolingActivity.WAITING), + # a heat pump that does not do cooling reports no cooling fields at all + ({"state": 70}, None), + ], +) +def test_cooling_activity(fields, expected): + """Test the cooling status says what the heat pump is doing, or why it is not.""" + assert heat_pump(**fields).cooling_activity is expected + + +@pytest.mark.parametrize( + ("status", "expected"), + [ + (0, HeatPump.CoolingStatus.IDLE), + (2, HeatPump.CoolingStatus.ACTIVE), + (4, HeatPump.CoolingStatus.STANDBY), + (99, None), + ], +) +def test_cooling_status(status, expected): + """Test the cooling status the heat pump reports in its log.""" + assert heat_pump(cooling_status=status).cooling_status is expected + + +def test_cooling_status_when_not_reported(): + """Test a heat pump that does not report a cooling status decodes to nothing.""" + assert heat_pump(state=40).cooling_status is None + + +def test_cooling_start_conditions(): + """Test the start conditions decode to a flag per condition.""" + # every condition met except the outside air temperature + conditions = heat_pump(cooling_start_conditions=2043).cooling_start_conditions + + assert conditions["outside_air_temperature"] is False + assert conditions["demand"] is True + assert sum(conditions.values()) == len(HeatPump.COOLING_START_CONDITION_BITS) - 1 + + +def test_cooling_start_conditions_without_a_log(): + """Test a heat pump that reports no start conditions decodes to nothing.""" + assert heat_pump().cooling_start_conditions is None + + +@pytest.mark.parametrize( + ("power_in", "power_out", "expected"), + [ + (500, 2000, 4.0), + # while cooling the output power is negative, the ratio stays positive + (521, -2671, pytest.approx(5.126, abs=0.001)), + (0, 2000, 0), + ], +) +def test_cop(power_in, power_out, expected): + """Test the coefficient of performance is a positive ratio in every state.""" + pump = heat_pump(cm_mass_power_in=power_in, cm_mass_power_out=power_out) + + assert pump.cop == expected + + +def test_cooling_available_from(): + """Test the restart delay is counted from the last cooling cycle.""" + pump = heat_pump( + last_cooling_time="2026-08-31T09:00:00+00:00", cooling_exponential_backoff=180 + ) + + assert pump.cooling_available_from.isoformat() == "2026-08-31T12:00:00+00:00" + + +def test_cooling_available_from_before_any_cooling(): + """Test there is no restart delay before the heat pump has ever cooled.""" + assert heat_pump(cooling_exponential_backoff=180).cooling_available_from is None + + +@pytest.mark.parametrize("code", [99, -1]) +def test_unknown_codes_decode_to_nothing(code): + """Test a code this version does not know does not raise.""" + pump = heat_pump(cooling_pause_reason=code, cooling_stop_reason=code) + + assert pump.cooling_pause_reason is None + assert pump.cooling_stop_reason is None + + +@pytest.mark.parametrize( + ("code", "expected_name"), + [(4, HeatPump.CoolingPauseReason.WATER_TEMPERATURE_BELOW_SETPOINT), (99, None)], +) +def test_a_code_is_reported_even_when_it_cannot_be_named(code, expected_name): + """Test the code is reported whether or not this version can name it. + + That is what lets a consumer tell a heat pump reporting an unknown value + apart from one not reporting the value at all. + """ + pump = heat_pump(cooling_pause_reason=code) + + assert pump.cooling_pause_reason_code == code + assert pump.cooling_pause_reason is expected_name + + +def test_no_code_is_reported_when_the_field_is_absent(): + """Test a heat pump that does not report the field reports no code either.""" + pump = heat_pump(state=40) + + assert pump.cooling_pause_reason_code is None + assert pump.heat_pump_state_code == 40 + + +@pytest.mark.parametrize( + ("code", "expected"), + [ + (0, HeatPump.DhwControlMethod.NONE), + (1, HeatPump.DhwControlMethod.FIXED), + (2, HeatPump.DhwControlMethod.SCHEDULE), + (3, HeatPump.DhwControlMethod.WEHEAT_INTELLIGENCE), + (4, HeatPump.DhwControlMethod.BOOST), + (99, None), + ], +) +def test_dhw_control_method(code, expected): + """Test the control method the DHW vessel runs on.""" + pump = heat_pump(dhw_control_method=code) + + assert pump.dhw_control_method is expected + assert pump.dhw_control_method_code == code diff --git a/weheat/__init__.py b/weheat/__init__.py index cd0b2da..1e43f6d 100644 --- a/weheat/__init__.py +++ b/weheat/__init__.py @@ -14,7 +14,7 @@ """ # noqa: E501 -__version__ = "2026.4.8" +__version__ = "2026.9.2" # import apis into sdk package from weheat.api.energy_log_api import EnergyLogApi diff --git a/weheat/abstractions/heat_pump.py b/weheat/abstractions/heat_pump.py index 079eeb9..0a4ef60 100644 --- a/weheat/abstractions/heat_pump.py +++ b/weheat/abstractions/heat_pump.py @@ -1,7 +1,7 @@ """Weheat heat pump abstraction from the API.""" -from datetime import datetime +from datetime import datetime, timedelta from enum import Enum, auto -from typing import TypeVar, Union, Optional, cast +from typing import Dict, TypeVar, Union, Optional, cast import aiohttp @@ -29,6 +29,105 @@ class State(Enum): DEFROSTING = auto() SELF_TEST = auto() MANUAL_CONTROL = auto() + UPDATING = auto() + + class DhwControlMethod(Enum): + """The control method the heat pump reports for the DHW vessel. + + The portal has an enum of the same name for the installation setting, + which numbers its values differently. This is the one the log uses. + """ + + NONE = 0 + FIXED = 1 + SCHEDULE = 2 + WEHEAT_INTELLIGENCE = 3 + BOOST = 4 + + class CoolingState(Enum): + IDLE = 130 + STARTING = 131 + ACTIVE = 132 + STOPPING = 133 + STANDBY = 134 + PAUSING = 135 + WATER_CHECK = 136 + STANDBY_RUN_CP = 137 + + class CoolingActivity(Enum): + """What the heat pump is doing about cooling, or why it is not cooling.""" + + IDLE = auto() + STARTING = auto() + ACTIVE = auto() + STOPPING = auto() + STANDBY = auto() + PAUSING = auto() + WATER_CHECK = auto() + STANDBY_RUN_CP = auto() + PAUSED = auto() + STOPPED = auto() + WAITING = auto() + + class CoolingStatus(Enum): + """The cooling status the heat pump reports in its log.""" + + IDLE = 0 + STARTING = 1 + ACTIVE = 2 + STOPPING = 3 + STANDBY = 4 + + class CoolingPauseReason(Enum): + NONE = 0 + ROOM_TEMPERATURE_TOO_LOW = 1 + OUTSIDE_TEMPERATURE_TOO_LOW = 2 + OUTSIDE_COLDER_THAN_WATER_TEMPERATURE = 3 + WATER_TEMPERATURE_BELOW_SETPOINT = 4 + HEAT_PUMP_CONTROL = 5 + WATER_TEMPERATURE_BELOW_DEWPOINT = 6 + CONTACT_BLOCKED = 7 + DEMAND = 8 + + class ControlMethod(Enum): + NONE = 0 + HEATING_CURVE = 1 + ON_OFF_THERMOSTAT = 2 + BASE_OPEN_THERM = 3 + SMART_OPEN_THERM = 4 + CLOUD_THERMOSTAT = 5 + MANUAL_POWER = 6 + AUTO_INPUT_SELECT = 7 + MANUAL_SETPOINT = 8 + + class CoolingStopReason(Enum): + NONE = 0 + DTC = 1 + CONTROL_METHOD = 2 + NO_INDOOR_UNIT_COMMUNICATION = 3 + HEAT_PUMP_CONTROL = 4 + COOLING_CONTROL = 5 + CONTACT_SWITCH_OVER = 6 + THERMOSTAT_DISABLED = 7 + + # The numeric states the heat pump reports while cooling, and while defrosting. + DEFROST_STATES = frozenset({84, 90, 100, 110, 120, *range(200, 240)}) + COOLING_STATES = frozenset(state.value for state in CoolingState) + + # Bit masks of the conditions that must all be met before cooling can start. + COOLING_START_CONDITION_BITS = { + "control_method": 1, + "dtc": 2, + "outside_air_temperature": 4, + "inside_temperature": 8, + "indoor_unit_connected": 16, + "water_to_air": 32, + "demand": 64, + "water_temperature": 128, + "contact_not_blocked": 256, + "exponential_backoff": 512, + "heat_cool_delay": 1024, + } def __init__(self, api_url: str, uuid: str, client_session: aiohttp.ClientSession | None = None) -> None: self._api_url = api_url @@ -84,6 +183,7 @@ async def async_get_energy(self, access_token: str) -> None: except Exception as e: self._energy_total = None + raise e def _if_available_and_valid(self, key: str) -> Optional[T]: """Return the value from the last logged value if available and not -1. None otherwise.""" @@ -121,6 +221,31 @@ def __str__(self) -> str: def __repr__(self) -> str: return self.__str__() + @property + def heat_pump_state_code(self) -> Union[int, None]: + """The raw state the heat pump reports, named by heat_pump_state.""" + return self._if_available("state") + + @property + def current_control_method_code(self) -> Union[int, None]: + """The raw control method the heat pump reports, named by current_control_method.""" + return self._if_available("current_control_method") + + @property + def dhw_control_method_code(self) -> Union[int, None]: + """The raw DHW control method, named by dhw_control_method.""" + return self._if_available("dhw_control_method") + + @property + def cooling_pause_reason_code(self) -> Union[int, None]: + """The raw pause reason the heat pump reports, named by cooling_pause_reason.""" + return self._if_available("cooling_pause_reason") + + @property + def cooling_stop_reason_code(self) -> Union[int, None]: + """The raw stop reason the heat pump reports, named by cooling_stop_reason.""" + return self._if_available("cooling_stop_reason") + @property def raw_content(self) -> Optional[dict]: raw = {} @@ -130,6 +255,11 @@ def raw_content(self) -> Optional[dict]: raw.update(vars(self._energy_total)) return raw or None + @property + def is_online(self) -> Union[bool, None]: + """Whether the heat pump was still reporting to the backend at the time of the last log.""" + return self._if_available("is_online") + @property def water_inlet_temperature(self) -> Union[float, None]: """The heat pump water inlet temperature.""" @@ -195,6 +325,11 @@ def dhw_bottom_temperature(self) -> Union[float, None]: """The DHW vessel bottom temperature.""" return self._if_available("t2") + @property + def dhw_target_temperature(self) -> Union[float, None]: + """The DHW vessel target temperature.""" + return self._if_available_and_valid("dhw_target_temperature") + @property def cop(self) -> Union[float, None]: """ @@ -209,7 +344,9 @@ def cop(self) -> Union[float, None]: return None if input > 0: - return output / input + # While cooling or defrosting the output power is negative, as heat is removed from + # the water. The amount of energy moved per unit of input is still a positive ratio. + return abs(output) / input return 0 @@ -264,7 +401,9 @@ def heat_pump_state(self) -> Union[State, None]: return self.State.STANDBY elif numeric_state == 70: return self.State.HEATING - elif numeric_state >= 130 and numeric_state < 140: + elif numeric_state == self.CoolingState.WATER_CHECK.value: + return self.State.WATER_CHECK + elif numeric_state in self.COOLING_STATES: return self.State.COOLING elif numeric_state == 150: return self.State.DHW @@ -274,10 +413,136 @@ def heat_pump_state(self) -> Union[State, None]: return self.State.SELF_TEST elif numeric_state == 180: return self.State.MANUAL_CONTROL - elif numeric_state >= 200 and numeric_state <= 240: + elif numeric_state == 1010: + return self.State.UPDATING + elif numeric_state in self.DEFROST_STATES: return self.State.DEFROSTING return None + @property + def last_cooling_time(self) -> Union[datetime, None]: + """The last completed cooling cycle, which the restart delay is counted from. + + This is not updated while a cooling cycle is running, so during cooling it still + refers to the cycle before it. + """ + return cast(Optional[datetime], self._if_available("last_cooling_time")) + + @property + def current_control_method(self) -> Union["HeatPump.ControlMethod", None]: + """The control method the heat pump is currently running on.""" + value = self._if_available("current_control_method") + if value is None: + return None + try: + return self.ControlMethod(value) + except ValueError: + # The backend may report methods this version does not know about yet. + return None + + @property + def dhw_control_method(self) -> Union["HeatPump.DhwControlMethod", None]: + """The control method the DHW vessel is running on.""" + value = self.dhw_control_method_code + if value is None: + return None + try: + return self.DhwControlMethod(value) + except ValueError: + # The backend may report methods this version does not know about yet. + return None + + @property + def cooling_state(self) -> Union["HeatPump.CoolingState", None]: + """The cooling sub state, only set while the heat pump is in a cooling state.""" + value = self._if_available("state") + if value is None: + return None + try: + return self.CoolingState(value) + except ValueError: + return None + + @property + def cooling_status(self) -> Union["HeatPump.CoolingStatus", None]: + """The cooling status the heat pump reports, if it reports one.""" + value = self._if_available("cooling_status") + if value is None: + return None + try: + return self.CoolingStatus(value) + except ValueError: + # The backend may report a status this version does not know about yet. + return None + + @property + def cooling_activity(self) -> Union["HeatPump.CoolingActivity", None]: + """What the heat pump is doing about cooling, or why it is not cooling. + + The heat pump only reports a cooling state during a cooling cycle, so + outside one this reports whether cooling is paused, stopped, or waiting + for its start conditions. None when the heat pump does not do cooling. + """ + cooling_state = self.cooling_state + if cooling_state is not None: + return self.CoolingActivity[cooling_state.name] + if self._if_available("cooling_pause_reason") is None: + return None + if self.heat_pump_state is self.State.STANDBY: + if self.cooling_pause_reason not in (None, self.CoolingPauseReason.NONE): + return self.CoolingActivity.PAUSED + if self.cooling_stop_reason not in (None, self.CoolingStopReason.NONE): + return self.CoolingActivity.STOPPED + return self.CoolingActivity.WAITING + + @property + def cooling_pause_reason(self) -> Union["HeatPump.CoolingPauseReason", None]: + """The reason cooling is currently held off.""" + value = self._if_available("cooling_pause_reason") + if value is None: + return None + try: + return self.CoolingPauseReason(value) + except ValueError: + # The backend may report reasons this version does not know about yet. + return None + + @property + def cooling_stop_reason(self) -> Union["HeatPump.CoolingStopReason", None]: + """The reason the last cooling cycle was stopped.""" + value = self._if_available("cooling_stop_reason") + if value is None: + return None + try: + return self.CoolingStopReason(value) + except ValueError: + # The backend may report reasons this version does not know about yet. + return None + + @property + def cooling_backoff(self) -> Union[int, None]: + """The minutes to wait after a cooling cycle before cooling may start again.""" + return self._if_available("cooling_exponential_backoff") + + @property + def cooling_available_from(self) -> Union[datetime, None]: + """The moment the wait time after the last cooling cycle expires.""" + last_cooling_time = self.last_cooling_time + if last_cooling_time is None: + return None + return last_cooling_time + timedelta(minutes=self.cooling_backoff or 0) + + @property + def cooling_start_conditions(self) -> Union[Dict[str, bool], None]: + """Each condition for starting cooling, and whether it is currently met.""" + value = self._if_available("cooling_start_conditions") + if value is None: + return None + return { + name: bool(value & bit) + for name, bit in self.COOLING_START_CONDITION_BITS.items() + } + @staticmethod def _pwm_to_volume(pwm: float, max: float) -> Union[float, None]: """Calculate PWM to Volume in m3/h based on the max available volume""" @@ -412,7 +677,11 @@ def energy_out_cooling(self) -> Union[float, None]: @property def energy_total(self) -> Union[float, None]: - """The total used (electrical) energy in kWh.""" + """The total used (electrical) energy of the outdoor unit in kWh. + + This does not include the indoor unit, which the heat pump meters + separately and reports through energy_in_indoor_unit. + """ if self._energy_total is None: return None return float( @@ -421,6 +690,18 @@ def energy_total(self) -> Union[float, None]: self._energy_total.total_ein_heating_defrost + self._energy_total.total_ein_dhw_defrost ) + @property + def energy_in_indoor_unit(self) -> Union[float, None]: + """The total used (electrical) energy of the indoor unit in kWh.""" + if self._energy_total is None: + return None + return float( + self._energy_total.total_ein_iu_heating + self._energy_total.total_ein_iu_dhw + + self._energy_total.total_ein_iu_cooling + self._energy_total.total_ein_iu_standby + + self._energy_total.total_ein_iu_heating_defrost + + self._energy_total.total_ein_iu_dhw_defrost + ) + @property def energy_output(self) -> Union[float, None]: """The total useful generated energy for the house in kWh.""" diff --git a/weheat/api_client.py b/weheat/api_client.py index 15ba96b..1d2c365 100644 --- a/weheat/api_client.py +++ b/weheat/api_client.py @@ -86,7 +86,7 @@ def __init__( self.default_headers[header_name] = header_value self.cookie = cookie # Set default User-Agent. - self.user_agent = 'OpenAPI-Generator/2026.4.8/python' + self.user_agent = 'OpenAPI-Generator/2026.9.2/python' self.client_side_validation = configuration.client_side_validation async def __aenter__(self): diff --git a/weheat/configuration.py b/weheat/configuration.py index 160a41f..59d77cf 100644 --- a/weheat/configuration.py +++ b/weheat/configuration.py @@ -381,7 +381,7 @@ def to_debug_report(self): "OS: {env}\n"\ "Python Version: {pyversion}\n"\ "Version of the API: v1\n"\ - "SDK Package Version: 2026.4.8".\ + "SDK Package Version: 2026.9.2".\ format(env=sys.platform, pyversion=sys.version) def get_host_settings(self): diff --git a/weheat/models/raw_heat_pump_log_dto.py b/weheat/models/raw_heat_pump_log_dto.py index a4ace93..e173b07 100644 --- a/weheat/models/raw_heat_pump_log_dto.py +++ b/weheat/models/raw_heat_pump_log_dto.py @@ -54,6 +54,14 @@ class RawHeatPumpLogDto(BaseModel): ot_boiler_return_temperature: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Return temperature of the OpenTherm boiler", alias="otBoilerReturnTemperature") central_heating_flow: Optional[StrictInt] = Field(default=None, description="Duty cycle read by pwm pump for central heating circuit", alias="centralHeatingFlow") dhw_flow: Optional[StrictInt] = Field(default=None, description="Duty cycle read by pwm pump for DHW circuit", alias="dhwFlow") + hq_message_version: Optional[StrictInt] = Field(default=None, description="Version of the HQ message format used for this log", alias="hqMessageVersion") + dhw_control_method: Optional[StrictInt] = Field(default=None, description="Control method used for the DHW vessel", alias="dhwControlMethod") + dhw_target_temperature: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Target temperature of the DHW vessel", alias="dhwTargetTemperature") + cooling_exponential_backoff: Optional[StrictInt] = Field(default=None, description="Minutes to wait after a cooling cycle before cooling may start again", alias="coolingExponentialBackoff") + cooling_start_conditions: Optional[StrictInt] = Field(default=None, description="Conditions for starting cooling (bitwise encoded)", alias="coolingStartConditions") + cooling_pause_reason: Optional[StrictInt] = Field(default=None, description="Reason cooling is currently paused", alias="coolingPauseReason") + cooling_stop_reason: Optional[StrictInt] = Field(default=None, description="Reason the last cooling cycle stopped", alias="coolingStopReason") + last_cooling_time: Optional[datetime] = Field(default=None, description="Timestamp of the last time the heat pump was cooling", alias="lastCoolingTime") interval: StrictInt = Field(description="Interval for this log in seconds") input_status: Optional[StrictInt] = Field(default=None, description="Raw input status of the heat pump", alias="inputStatus") current_control_method: Optional[StrictInt] = Field(default=None, description="Raw current control method state of the heat pump", alias="currentControlMethod") @@ -102,7 +110,7 @@ class RawHeatPumpLogDto(BaseModel): debug_variable3: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Optional debug variable that can be set to anything in firmware and will be logged as a float float - 4 bytes", alias="debugVariable3") debug_variable4: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Optional debug variable that can be set to anything in firmware and will be logged as a float float - 4 bytes", alias="debugVariable4") debug_variable5: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Optional debug variable that can be set to anything in firmware and will be logged as a float float - 4 bytes", alias="debugVariable5") - __properties: ClassVar[List[str]] = ["heatPumpId", "timestamp", "state", "controlBridgeStatus", "controlBridgeStatusDecodedWaterPump", "controlBridgeStatusDecodedGasBoiler", "controlBridgeStatusDecodedElectricHeater", "controlBridgeStatusDecodedWaterPump2", "t1", "t2", "tAirIn", "tAirOut", "tWaterIn", "tWaterOut", "tWaterHouseIn", "rpm", "onOffThermostatState", "tRoom", "tRoomTarget", "tThermostatSetpoint", "otBoilerFeedTemperature", "otBoilerReturnTemperature", "centralHeatingFlow", "dhwFlow", "interval", "inputStatus", "currentControlMethod", "signalStrength", "rpmLimiter", "rpmLimiterType", "pCompressorIn", "pCompressorOut", "pCompressorInTarget", "tCompressorIn", "tCompressorOut", "tCompressorInTransient", "tCompressorOutTransient", "deltaTCompressorInSuperheat", "fan", "fanPower", "temperatureErrorIntegral", "thermostatStatus", "otBoilerStatus", "centralHeatingPwmRequestedDutyCycle", "dhwPwmRequestedDutyCycle", "sinr", "error", "errorDecodedDtcNone", "errorDecodedDtcContinue", "errorDecodedDtcCompressorOff", "errorDecodedDtcDefrostForbidden", "errorDecodedDtcRequestService", "errorDecodedDtcUseHeatingCurve", "errorDecodedDtcDhwForbidden", "errorDecodedDtcError", "errorDecodedDtcInactive", "controlBridgeStatusDecodedDhwValve", "tBoard", "tInverter", "compressorPowerLowAccuracy", "valve", "inverterInputVoltage", "indoorUnitHeaterTemperature", "indoorUnitInputCurrent", "coolingStatus", "cmMassPowerIn", "cmMassPowerOut", "debugVariable1", "debugVariable2", "debugVariable3", "debugVariable4", "debugVariable5"] + __properties: ClassVar[List[str]] = ["heatPumpId", "timestamp", "state", "controlBridgeStatus", "controlBridgeStatusDecodedWaterPump", "controlBridgeStatusDecodedGasBoiler", "controlBridgeStatusDecodedElectricHeater", "controlBridgeStatusDecodedWaterPump2", "t1", "t2", "tAirIn", "tAirOut", "tWaterIn", "tWaterOut", "tWaterHouseIn", "rpm", "onOffThermostatState", "tRoom", "tRoomTarget", "tThermostatSetpoint", "otBoilerFeedTemperature", "otBoilerReturnTemperature", "centralHeatingFlow", "dhwFlow", "hqMessageVersion", "dhwControlMethod", "dhwTargetTemperature", "coolingExponentialBackoff", "coolingStartConditions", "coolingPauseReason", "coolingStopReason", "lastCoolingTime", "interval", "inputStatus", "currentControlMethod", "signalStrength", "rpmLimiter", "rpmLimiterType", "pCompressorIn", "pCompressorOut", "pCompressorInTarget", "tCompressorIn", "tCompressorOut", "tCompressorInTransient", "tCompressorOutTransient", "deltaTCompressorInSuperheat", "fan", "fanPower", "temperatureErrorIntegral", "thermostatStatus", "otBoilerStatus", "centralHeatingPwmRequestedDutyCycle", "dhwPwmRequestedDutyCycle", "sinr", "error", "errorDecodedDtcNone", "errorDecodedDtcContinue", "errorDecodedDtcCompressorOff", "errorDecodedDtcDefrostForbidden", "errorDecodedDtcRequestService", "errorDecodedDtcUseHeatingCurve", "errorDecodedDtcDhwForbidden", "errorDecodedDtcError", "errorDecodedDtcInactive", "controlBridgeStatusDecodedDhwValve", "tBoard", "tInverter", "compressorPowerLowAccuracy", "valve", "inverterInputVoltage", "indoorUnitHeaterTemperature", "indoorUnitInputCurrent", "coolingStatus", "cmMassPowerIn", "cmMassPowerOut", "debugVariable1", "debugVariable2", "debugVariable3", "debugVariable4", "debugVariable5"] model_config = { "populate_by_name": True, @@ -522,6 +530,14 @@ def from_dict(cls, obj: Dict) -> Self: "otBoilerReturnTemperature": obj.get("otBoilerReturnTemperature"), "centralHeatingFlow": obj.get("centralHeatingFlow"), "dhwFlow": obj.get("dhwFlow"), + "hqMessageVersion": obj.get("hqMessageVersion"), + "dhwControlMethod": obj.get("dhwControlMethod"), + "dhwTargetTemperature": obj.get("dhwTargetTemperature"), + "coolingExponentialBackoff": obj.get("coolingExponentialBackoff"), + "coolingStartConditions": obj.get("coolingStartConditions"), + "coolingPauseReason": obj.get("coolingPauseReason"), + "coolingStopReason": obj.get("coolingStopReason"), + "lastCoolingTime": obj.get("lastCoolingTime"), "interval": obj.get("interval"), "inputStatus": obj.get("inputStatus"), "currentControlMethod": obj.get("currentControlMethod"), diff --git a/weheat/models/raw_heatpump_log_and_is_online_dto.py b/weheat/models/raw_heatpump_log_and_is_online_dto.py index 5163202..0e8f93a 100644 --- a/weheat/models/raw_heatpump_log_and_is_online_dto.py +++ b/weheat/models/raw_heatpump_log_and_is_online_dto.py @@ -54,6 +54,14 @@ class RawHeatpumpLogAndIsOnlineDto(BaseModel): ot_boiler_return_temperature: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Return temperature of the OpenTherm boiler", alias="otBoilerReturnTemperature") central_heating_flow: Optional[StrictInt] = Field(default=None, description="Duty cycle read by pwm pump for central heating circuit", alias="centralHeatingFlow") dhw_flow: Optional[StrictInt] = Field(default=None, description="Duty cycle read by pwm pump for DHW circuit", alias="dhwFlow") + hq_message_version: Optional[StrictInt] = Field(default=None, description="Version of the HQ message format used for this log", alias="hqMessageVersion") + dhw_control_method: Optional[StrictInt] = Field(default=None, description="Control method used for the DHW vessel", alias="dhwControlMethod") + dhw_target_temperature: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Target temperature of the DHW vessel", alias="dhwTargetTemperature") + cooling_exponential_backoff: Optional[StrictInt] = Field(default=None, description="Minutes to wait after a cooling cycle before cooling may start again", alias="coolingExponentialBackoff") + cooling_start_conditions: Optional[StrictInt] = Field(default=None, description="Conditions for starting cooling (bitwise encoded)", alias="coolingStartConditions") + cooling_pause_reason: Optional[StrictInt] = Field(default=None, description="Reason cooling is currently paused", alias="coolingPauseReason") + cooling_stop_reason: Optional[StrictInt] = Field(default=None, description="Reason the last cooling cycle stopped", alias="coolingStopReason") + last_cooling_time: Optional[datetime] = Field(default=None, description="Timestamp of the last time the heat pump was cooling", alias="lastCoolingTime") interval: StrictInt = Field(description="Interval for this log in seconds") input_status: Optional[StrictInt] = Field(default=None, description="Raw input status of the heat pump", alias="inputStatus") current_control_method: Optional[StrictInt] = Field(default=None, description="Raw current control method state of the heat pump", alias="currentControlMethod") @@ -103,7 +111,7 @@ class RawHeatpumpLogAndIsOnlineDto(BaseModel): debug_variable4: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Optional debug variable that can be set to anything in firmware and will be logged as a float float - 4 bytes", alias="debugVariable4") debug_variable5: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Optional debug variable that can be set to anything in firmware and will be logged as a float float - 4 bytes", alias="debugVariable5") is_online: Optional[StrictBool] = Field(default=None, description="A boolean indicating if the heat pump is currently online", alias="isOnline") - __properties: ClassVar[List[str]] = ["heatPumpId", "timestamp", "state", "controlBridgeStatus", "controlBridgeStatusDecodedWaterPump", "controlBridgeStatusDecodedGasBoiler", "controlBridgeStatusDecodedElectricHeater", "controlBridgeStatusDecodedWaterPump2", "t1", "t2", "tAirIn", "tAirOut", "tWaterIn", "tWaterOut", "tWaterHouseIn", "rpm", "onOffThermostatState", "tRoom", "tRoomTarget", "tThermostatSetpoint", "otBoilerFeedTemperature", "otBoilerReturnTemperature", "centralHeatingFlow", "dhwFlow", "interval", "inputStatus", "currentControlMethod", "signalStrength", "rpmLimiter", "rpmLimiterType", "pCompressorIn", "pCompressorOut", "pCompressorInTarget", "tCompressorIn", "tCompressorOut", "tCompressorInTransient", "tCompressorOutTransient", "deltaTCompressorInSuperheat", "fan", "fanPower", "temperatureErrorIntegral", "thermostatStatus", "otBoilerStatus", "centralHeatingPwmRequestedDutyCycle", "dhwPwmRequestedDutyCycle", "sinr", "error", "errorDecodedDtcNone", "errorDecodedDtcContinue", "errorDecodedDtcCompressorOff", "errorDecodedDtcDefrostForbidden", "errorDecodedDtcRequestService", "errorDecodedDtcUseHeatingCurve", "errorDecodedDtcDhwForbidden", "errorDecodedDtcError", "errorDecodedDtcInactive", "controlBridgeStatusDecodedDhwValve", "tBoard", "tInverter", "compressorPowerLowAccuracy", "valve", "inverterInputVoltage", "indoorUnitHeaterTemperature", "indoorUnitInputCurrent", "coolingStatus", "cmMassPowerIn", "cmMassPowerOut", "debugVariable1", "debugVariable2", "debugVariable3", "debugVariable4", "debugVariable5", "isOnline"] + __properties: ClassVar[List[str]] = ["heatPumpId", "timestamp", "state", "controlBridgeStatus", "controlBridgeStatusDecodedWaterPump", "controlBridgeStatusDecodedGasBoiler", "controlBridgeStatusDecodedElectricHeater", "controlBridgeStatusDecodedWaterPump2", "t1", "t2", "tAirIn", "tAirOut", "tWaterIn", "tWaterOut", "tWaterHouseIn", "rpm", "onOffThermostatState", "tRoom", "tRoomTarget", "tThermostatSetpoint", "otBoilerFeedTemperature", "otBoilerReturnTemperature", "centralHeatingFlow", "dhwFlow", "hqMessageVersion", "dhwControlMethod", "dhwTargetTemperature", "coolingExponentialBackoff", "coolingStartConditions", "coolingPauseReason", "coolingStopReason", "lastCoolingTime", "interval", "inputStatus", "currentControlMethod", "signalStrength", "rpmLimiter", "rpmLimiterType", "pCompressorIn", "pCompressorOut", "pCompressorInTarget", "tCompressorIn", "tCompressorOut", "tCompressorInTransient", "tCompressorOutTransient", "deltaTCompressorInSuperheat", "fan", "fanPower", "temperatureErrorIntegral", "thermostatStatus", "otBoilerStatus", "centralHeatingPwmRequestedDutyCycle", "dhwPwmRequestedDutyCycle", "sinr", "error", "errorDecodedDtcNone", "errorDecodedDtcContinue", "errorDecodedDtcCompressorOff", "errorDecodedDtcDefrostForbidden", "errorDecodedDtcRequestService", "errorDecodedDtcUseHeatingCurve", "errorDecodedDtcDhwForbidden", "errorDecodedDtcError", "errorDecodedDtcInactive", "controlBridgeStatusDecodedDhwValve", "tBoard", "tInverter", "compressorPowerLowAccuracy", "valve", "inverterInputVoltage", "indoorUnitHeaterTemperature", "indoorUnitInputCurrent", "coolingStatus", "cmMassPowerIn", "cmMassPowerOut", "debugVariable1", "debugVariable2", "debugVariable3", "debugVariable4", "debugVariable5", "isOnline"] model_config = { "populate_by_name": True, @@ -523,6 +531,14 @@ def from_dict(cls, obj: Dict) -> Self: "otBoilerReturnTemperature": obj.get("otBoilerReturnTemperature"), "centralHeatingFlow": obj.get("centralHeatingFlow"), "dhwFlow": obj.get("dhwFlow"), + "hqMessageVersion": obj.get("hqMessageVersion"), + "dhwControlMethod": obj.get("dhwControlMethod"), + "dhwTargetTemperature": obj.get("dhwTargetTemperature"), + "coolingExponentialBackoff": obj.get("coolingExponentialBackoff"), + "coolingStartConditions": obj.get("coolingStartConditions"), + "coolingPauseReason": obj.get("coolingPauseReason"), + "coolingStopReason": obj.get("coolingStopReason"), + "lastCoolingTime": obj.get("lastCoolingTime"), "interval": obj.get("interval"), "inputStatus": obj.get("inputStatus"), "currentControlMethod": obj.get("currentControlMethod"), diff --git a/weheat/models/total_energy_aggregate.py b/weheat/models/total_energy_aggregate.py index 8154aad..6d8f4c7 100644 --- a/weheat/models/total_energy_aggregate.py +++ b/weheat/models/total_energy_aggregate.py @@ -42,7 +42,13 @@ class TotalEnergyAggregate(BaseModel): total_e_out_heating_defrost: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="totalEOutHeatingDefrost") total_e_out_dhw_defrost: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="totalEOutDhwDefrost") total_e_out_cooling: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="totalEOutCooling") - __properties: ClassVar[List[str]] = ["heatPumpId", "totalEInHeating", "totalEInStandby", "totalEInDhw", "totalEInHeatingDefrost", "totalEInDhwDefrost", "totalEInCooling", "totalEOutHeating", "totalEOutDhw", "totalEOutHeatingDefrost", "totalEOutDhwDefrost", "totalEOutCooling",] + total_ein_iu_standby: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="totalEInIUStandby") + total_ein_iu_heating: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="totalEInIUHeating") + total_ein_iu_dhw: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="totalEInIUDhw") + total_ein_iu_heating_defrost: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="totalEInIUHeatingDefrost") + total_ein_iu_dhw_defrost: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="totalEInIUDhwDefrost") + total_ein_iu_cooling: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="totalEInIUCooling") + __properties: ClassVar[List[str]] = ["heatPumpId", "totalEInHeating", "totalEInStandby", "totalEInDhw", "totalEInHeatingDefrost", "totalEInDhwDefrost", "totalEInCooling", "totalEOutHeating", "totalEOutDhw", "totalEOutHeatingDefrost", "totalEOutDhwDefrost", "totalEOutCooling", "totalEInIUStandby", "totalEInIUHeating", "totalEInIUDhw", "totalEInIUHeatingDefrost", "totalEInIUDhwDefrost", "totalEInIUCooling",] model_config = { "populate_by_name": True, @@ -104,7 +110,13 @@ def from_dict(cls, obj: Dict) -> Self: "totalEOutDhw": obj.get("totalEOutDhw"), "totalEOutHeatingDefrost": obj.get("totalEOutHeatingDefrost"), "totalEOutDhwDefrost": obj.get("totalEOutDhwDefrost"), - "totalEOutCooling": obj.get("totalEOutCooling") + "totalEOutCooling": obj.get("totalEOutCooling"), + "totalEInIUStandby": obj.get("totalEInIUStandby"), + "totalEInIUHeating": obj.get("totalEInIUHeating"), + "totalEInIUDhw": obj.get("totalEInIUDhw"), + "totalEInIUHeatingDefrost": obj.get("totalEInIUHeatingDefrost"), + "totalEInIUDhwDefrost": obj.get("totalEInIUDhwDefrost"), + "totalEInIUCooling": obj.get("totalEInIUCooling") }) return _obj