Skip to content

Commit fad2cd4

Browse files
committed
Fix complexity
1 parent 4bb7b95 commit fad2cd4

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

plugwise/data.py

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -228,28 +228,26 @@ def _get_adam_data(self, entity: GwEntityData, data: GwEntityData) -> None:
228228
available regulations_modes and thermostat control_states,
229229
and add missing cooling_enabled when required.
230230
"""
231-
if self.smile(ADAM):
231+
if not self.smile(ADAM):
232+
return
233+
234+
if entity["dev_class"] == "heater_central":
232235
# Indicate heating_state based on valves being open in case of city-provided heating
233-
if (
234-
entity["dev_class"] == "heater_central"
235-
and self._on_off_device
236-
and isinstance(self._heating_valves(), int)
237-
):
236+
if self._on_off_device and isinstance(self._heating_valves(), int):
238237
data["binary_sensors"]["heating_state"] = self._heating_valves() != 0
239-
240238
# Add cooling_enabled binary_sensor
241-
if entity["dev_class"] == "heater_central" and "binary_sensors" in data:
239+
if "binary_sensors" in data:
242240
if "cooling_enabled" not in data["binary_sensors"] and self._cooling_present:
243-
data["binary_sensors"].update({"cooling_enabled": self._cooling_enabled})
244-
245-
# Show the allowed regulation_modes and gateway_modes
246-
if entity["dev_class"] == "gateway":
247-
if self._reg_allowed_modes:
248-
data["regulation_modes"] = self._reg_allowed_modes
249-
self._count += 1
250-
if self._gw_allowed_modes:
251-
data["gateway_modes"] = self._gw_allowed_modes
252-
self._count += 1
241+
data["binary_sensors"]["cooling_enabled"] = self._cooling_enabled
242+
243+
# Show the allowed regulation_modes and gateway_modes
244+
if entity["dev_class"] == "gateway":
245+
if self._reg_allowed_modes:
246+
data["regulation_modes"] = self._reg_allowed_modes
247+
self._count += 1
248+
if self._gw_allowed_modes:
249+
data["gateway_modes"] = self._gw_allowed_modes
250+
self._count += 1
253251

254252
def _climate_data(
255253
self,

0 commit comments

Comments
 (0)