Skip to content
Merged
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Ongoing

- Improve testing: compare internal and code testcounters, line up fixture and test-json format, fix a missed count.

## v1.9.0

- Add support for Anna P1 via PR [#809](https://github.com/plugwise/python-plugwise/pull/809)
Expand Down
22 changes: 15 additions & 7 deletions plugwise/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ def _update_for_cooling(self, entity: GwEntityData) -> None:
and entity["dev_class"] == "thermostat"
):
thermostat = entity["thermostat"]
sensors = entity["sensors"]
temp_dict: ActuatorData = {
"setpoint_low": thermostat["setpoint"],
"setpoint_high": MAX_SETPOINT,
Expand All @@ -139,14 +138,21 @@ def _update_for_cooling(self, entity: GwEntityData) -> None:
"setpoint_low": MIN_SETPOINT,
"setpoint_high": thermostat["setpoint"],
}
thermostat.pop("setpoint")
thermostat.pop("setpoint") # Add 2 keys, remove 1
temp_dict.update(thermostat)
entity["thermostat"] = temp_dict
if "setpoint" in sensors:
sensors.pop("setpoint")

sensors = entity["sensors"]
sensors["setpoint_low"] = temp_dict["setpoint_low"]
sensors["setpoint_high"] = temp_dict["setpoint_high"]
self._count += 2 # add 4, remove 2
# Add 2 more keys, remove 1 when required
if "setpoint" in sensors:
sensors.pop("setpoint")
self._count -= 1

self._count += (
3 # add 4 total, remove 1, count the conditional remove separately
)

def _get_location_data(self, loc_id: str) -> GwEntityData:
"""Helper-function for _all_entity_data() and async_update().
Expand All @@ -164,8 +170,9 @@ def _get_location_data(self, loc_id: str) -> GwEntityData:
):
data["control_state"] = str(ctrl_state)

data["sensors"].pop("setpoint") # remove, only used in _control_state()
self._count -= 1
if "setpoint" in data["sensors"]:
data["sensors"].pop("setpoint") # remove, only used in _control_state()
self._count -= 1

# Thermostat data (presets, temperatures etc)
self._climate_data(loc_id, zone, data)
Expand Down Expand Up @@ -238,6 +245,7 @@ def _get_adam_data(self, entity: GwEntityData, data: GwEntityData) -> None:
and self._cooling_present
):
data["binary_sensors"]["cooling_enabled"] = self._cooling_enabled
self._count += 1

# Show the allowed regulation_modes and gateway_modes
if entity["dev_class"] == "gateway":
Expand Down
3 changes: 2 additions & 1 deletion scripts/tests_and_coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ set +u

if [ -z "${GITHUB_ACTIONS}" ] || [ "$1" == "test_and_coverage" ] ; then
# Python tests (rerun with debug if failures)
PYTHONPATH=$(pwd) pytest -qx tests/ --cov='.' --no-cov-on-fail --cov-report term-missing || PYTHONPATH=$(pwd) pytest -xrpP --log-level debug tests/
# PYTHONPATH=$(pwd) pytest -qx tests/ --cov='.' --no-cov-on-fail --cov-report term-missing ||
PYTHONPATH=$(pwd) pytest -xrpP --log-level debug tests/
handle_command_error "python code testing"
fi

Expand Down
Loading