Repository: plugwise/python-plugwise (language: python)

Issue:
chore(deps): update pre-commit hook asottile/pyupgrade to v3.15.0
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [asottile/pyupgrade](https://togithub.com/asottile/pyupgrade) | repository | minor | `v3.14.0` -> `v3.15.0` |

Note: The `pre-commit` manager in Renovate is not supported by the `pre-commit` maintainers or community. Please do not report any problems there, instead [create a Discussion in the Renovate repository](https://togithub.com/renovatebot/renovate/discussions/new) if you have any questions.

---

### Release Notes

<details>
<summary>asottile/pyupgrade (asottile/pyupgrade)</summary>

### [`v3.15.0`](https://togithub.com/asottile/pyupgrade/compare/v3.14.0...v3.15.0)

[Compare Source](https://togithub.com/asottile/pyupgrade/compare/v3.14.0...v3.15.0)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 4am" in timezone Europe/Amsterdam, Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/plugwise/python-plugwise).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4wLjMiLCJ1cGRhdGVkSW5WZXIiOiIzNy4wLjMiLCJ0YXJnZXRCcmFuY2giOiJtYWluIn0=-->



Discussion / hints:

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c54d4eae9..310b0b9b1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,7 @@
 - Repair coverage/fix testing - #294
 - Correct non-unique device names in adam_jip userdata
 - Add domestic_hot_water_setpoint data to anna_heatpump_heating userdata, update relevant test-cases
+- Add raising an error when providing the wrong type of temperature input to set_temperature() with cooling active
 
 ## V0.31.6: Fix domestic_hot_water_setpoint-related bug for Anna + Elga
 
diff --git a/plugwise/__init__.py b/plugwise/__init__.py
index d09e52023..cd759e72f 100644
--- a/plugwise/__init__.py
+++ b/plugwise/__init__.py
@@ -354,8 +354,8 @@ async def connect(self) -> bool:
         dsmrmain = result.find("./module/protocols/dsmrmain")
         if "Plugwise" not in names and dsmrmain is None:  # pragma: no cover
             LOGGER.error(
-                "Connected but expected text not returned, we got %s. Please create \
-                an issue on http://github.com/plugwise/python-plugwise",
+                "Connected but expected text not returned, we got %s. Please create"
+                " an issue on http://github.com/plugwise/python-plugwise",
                 result,
             )
             raise ResponseError
@@ -416,8 +416,8 @@ async def _smile_detect_legacy(
             else:  # pragma: no cover
                 # No cornercase, just end of the line
                 LOGGER.error(
-                    "Connected but no gateway device information found, please create \
-                     an issue on http://github.com/plugwise/python-plugwise"
+                    "Connected but no gateway device information found, please create"
+                    " an issue on http://github.com/plugwise/python-plugwise"
                 )
                 raise ResponseError
 
@@ -442,8 +442,8 @@ async def _smile_detect(self, result: etree, dsmrmain: etree) -> None:
         if model == "Unknown" or self.smile_fw_version is None:  # pragma: no cover
             # Corner case check
             LOGGER.error(
-                "Unable to find model or version information, please create \
-                 an issue on http://github.com/plugwise/python-plugwise"
+                "Unable to find model or version information, please create"
+                " an issue on http://github.com/plugwise/python-plugwise"
             )
             raise UnsupportedDeviceError
 
@@ -452,8 +452,8 @@ async def _smile_detect(self, result: etree, dsmrmain: etree) -> None:
         LOGGER.debug("Plugwise identified as %s", target_smile)
         if target_smile not in SMILES:
             LOGGER.error(
-                'Your version Smile identified as "%s" seems unsupported by our plugin, please \
-                create an issue on http://github.com/plugwise/python-plugwise',
+                "Your version Smile identified as %s seems unsupported by our plugin, please"
+                " create an issue on http://github.com/plugwise/python-plugwise",
                 target_smile,
             )
             raise UnsupportedDeviceError
@@ -682,20 +682,23 @@ async def set_temperature(self, loc_id: str, items: dict[str, float]) -> None:
             setpoint = items["setpoint"]
 
         if self._cooling_present:
-            if "setpoint_high" in items:
-                tmp_setpoint_high = items["setpoint_high"]
-                tmp_setpoint_low = items["setpoint_low"]
+            if "setpoint_high" not in items:
+                raise PlugwiseError(
+                    "Plugwise: failed setting temperature: no valid input provided"
+                )
+            tmp_setpoint_high = items["setpoint_high"]
+            tmp_setpoint_low = items["setpoint_low"]
             if self._cooling_enabled:  # in cooling mode
                 setpoint = tmp_setpoint_high
                 if tmp_setpoint_low != MIN_SETPOINT:
                     raise PlugwiseError(
-                        "Plugwise: heating setpoint cannot be changed when in cooling mode!"
+                        "Plugwise: heating setpoint cannot be changed when in cooling mode"
                     )
             else:  # in heating mode
                 setpoint = tmp_setpoint_low
                 if tmp_setpoint_high != MAX_SETPOINT:
                     raise PlugwiseError(
-                        "Plugwise: cooling setpoint cannot be changed when in heating mode!"
+                        "Plugwise: cooling setpoint cannot be changed when in heating mode"
                     )
 
         if setpoint is None:


Test patch:
diff --git a/tests/test_smile.py b/tests/test_smile.py
index d6c566fb7..f995faef5 100644
--- a/tests/test_smile.py
+++ b/tests/test_smile.py
@@ -486,11 +486,13 @@ async def tinker_switch(
         return tinker_switch_passed
 
     @pytest.mark.asyncio
-    async def tinker_thermostat_temp(self, smile, loc_id, unhappy=False):
+    async def tinker_thermostat_temp(
+        self, smile, loc_id, block_cooling=False, unhappy=False
+    ):
         """Toggle temperature to test functionality."""
         _LOGGER.info("Asserting modifying settings in location (%s):", loc_id)
         test_temp = {"setpoint": 22.9}
-        if smile._cooling_present:
+        if smile._cooling_present and not block_cooling:
             test_temp = {"setpoint_low": 19.5, "setpoint_high": 23.5}
         _LOGGER.info("- Adjusting temperature to %s", test_temp)
         try:
@@ -584,13 +586,16 @@ async def tinker_thermostat(
         schedule_on=True,
         good_schedules=None,
         single=False,
+        block_cooling=False,
         unhappy=False,
     ):
         """Toggle various climate settings to test functionality."""
         if good_schedules is None:  # pragma: no cover
             good_schedules = ["Weekschema"]
 
-        result_1 = await self.tinker_thermostat_temp(smile, loc_id, unhappy)
+        result_1 = await self.tinker_thermostat_temp(
+            smile, loc_id, block_cooling, unhappy
+        )
         result_2 = await self.tinker_thermostat_preset(smile, loc_id, unhappy)
         if smile._schedule_old_states != {}:
             for item in smile._schedule_old_states[loc_id]:
@@ -3928,7 +3933,7 @@ async def test_connect_anna_heatpump_cooling(self):
         assert smile._cooling_enabled
         assert smile._cooling_active
 
-        with pytest.raises(pw_exceptions.PlugwiseError):
+        with pytest.raises(pw_exceptions.PlugwiseError) as exc:
             await self.tinker_thermostat(
                 smile,
                 "c784ee9fdab44e1395b8dee7d7a497d5",
@@ -3936,6 +3941,7 @@ async def test_connect_anna_heatpump_cooling(self):
                     "standaard",
                 ],
             )
+        _LOGGER.debug("ERROR raised: %s", exc.value)
 
         await smile.close_connection()
         await self.disconnect(server, client)
@@ -4376,7 +4382,7 @@ async def test_connect_anna_loria_heating_idle(self):
         )
         assert switch_change
 
-        with pytest.raises(pw_exceptions.PlugwiseError):
+        with pytest.raises(pw_exceptions.PlugwiseError) as exc:
             await self.tinker_thermostat(
                 smile,
                 "15da035090b847e7a21f93e08c015ebc",
@@ -4384,6 +4390,15 @@ async def test_connect_anna_loria_heating_idle(self):
                     "Winter",
                 ],
             )
+        _LOGGER.debug("ERROR raised: %s", exc.value)
+
+        with pytest.raises(pw_exceptions.PlugwiseError) as exc:
+            await self.tinker_thermostat_temp(
+                smile,
+                "15da035090b847e7a21f93e08c015ebc",
+                block_cooling=True,
+            )
+        _LOGGER.debug("ERROR raised: %s", exc.value)
 
         await self.tinker_dhw_mode(smile)