Skip to content

Commit 03892f0

Browse files
committed
Rework to single if with walrus
1 parent b1d989c commit 03892f0

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

plugwise/data.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,12 @@ def _update_gw_entities(self) -> None:
7979
remove_empty_platform_dicts(entity)
8080

8181
# Replace select_dhw_mode with dhw_mode when applicable
82-
if "max_dhw_temperature" in entity:
83-
mode = entity.get("select_dhw_mode")
84-
if mode is not None:
85-
entity.pop("select_dhw_mode")
86-
entity["dhw_mode"] = mode
82+
if (
83+
"max_dhw_temperature" in entity
84+
and (mode := entity.get("select_dhw_mode")) is not None
85+
):
86+
entity.pop("select_dhw_mode")
87+
entity["dhw_mode"] = mode
8788

8889
def _detect_low_batteries(self) -> list[str]:
8990
"""Helper-function updating the low-battery binary_sensor status from a Battery-is-low message."""

0 commit comments

Comments
 (0)