Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "weheat"
version = "2026.9.2"
version = "2026.9.3"
description = "Weheat Backend"
authors = ["Jesper Raemaekers <jesper.raemaekers@wefabricate.com>", "Kjell van Straaten <kjell.van.straaten@wefabricate.com>"]
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# prerequisite: setuptools
# http://pypi.python.org/pypi/setuptools
NAME = "weheat"
VERSION = "2026.9.2"
VERSION = "2026.9.3"
PYTHON_REQUIRES = ">=3.10"
REQUIRES = [
"urllib3 >= 1.25.3, < 3.0.0",
Expand Down
32 changes: 24 additions & 8 deletions tests/test_heat_pump.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,21 +104,37 @@ def test_cooling_start_conditions_without_a_log():


@pytest.mark.parametrize(
("power_in", "power_out", "expected"),
("state", "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),
# heat into the water is what heating is for, so the ratio is positive
(70, 500, 2000, 4.0),
(150, 500, 2000, 4.0),
# heat out of the water is what cooling is for, so that is positive too
(132, 521, -2671, pytest.approx(5.126, abs=0.001)),
# only cooling itself flips: defrosting and the water check take heat out
# of the water too, but not as the point, so they stay negative
(90, 500, -1000, -2.0),
(136, 500, -1000, -2.0),
# heat moving the wrong way for the state stays visible as a negative
# ratio, rather than reading as a good one
(132, 690, 7404, pytest.approx(-10.73, abs=0.01)),
(70, 500, -500, -1.0),
# without a state there is no way to tell, so report what was measured
(None, 500, -500, -1.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)
def test_cop(state, power_in, power_out, expected):
"""Test the coefficient of performance follows the state it was measured in."""
pump = heat_pump(state=state, cm_mass_power_in=power_in, cm_mass_power_out=power_out)

assert pump.cop == expected


def test_cop_without_input_power():
"""Test nothing is drawn, so nothing is moved per unit drawn."""
assert heat_pump(state=40, cm_mass_power_in=0, cm_mass_power_out=0).cop == 0


def test_cooling_available_from():
"""Test the restart delay is counted from the last cooling cycle."""
pump = heat_pump(
Expand Down
2 changes: 1 addition & 1 deletion weheat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
""" # noqa: E501


__version__ = "2026.9.2"
__version__ = "2026.9.3"

# import apis into sdk package
from weheat.api.energy_log_api import EnergyLogApi
Expand Down
21 changes: 16 additions & 5 deletions weheat/abstractions/heat_pump.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,12 +343,23 @@ def cop(self) -> Union[float, None]:
if input is None or output is None:
return None

if input > 0:
# 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
if input <= 0:
return 0

return 0
state = self.heat_pump_state
if state is None:
# Without a known state there is no telling which way the heat is meant
# to go, so report the ratio as measured.
return output / input

# Cooling is the one state where taking heat out of the water is the
# point, so only there does a negative output power give a positive
# ratio. Correcting the sign per state rather than taking the absolute
# value keeps heat that moves the wrong way visible as a negative ratio,
# which happens at the start of a cooling cycle. Defrosting takes heat
# out of the water as well, but as a cost rather than the point, so it
# is left to read as the loss it is.
return (-1 if state is self.State.COOLING else 1) * output / input

@property
def indoor_unit_water_pump_state(self) -> Union[bool, None]:
Expand Down
2 changes: 1 addition & 1 deletion weheat/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.9.2/python'
self.user_agent = 'OpenAPI-Generator/2026.9.3/python'
self.client_side_validation = configuration.client_side_validation

async def __aenter__(self):
Expand Down
2 changes: 1 addition & 1 deletion weheat/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.9.2".\
"SDK Package Version: 2026.9.3".\
format(env=sys.platform, pyversion=sys.version)

def get_host_settings(self):
Expand Down
Loading