Skip to content

Commit e654a08

Browse files
committed
Fix complexity
1 parent 4bb7b95 commit e654a08

File tree

1 file changed

+15
-19
lines changed

1 file changed

+15
-19
lines changed

plugwise/data.py

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,8 @@ def _get_entity_data(self, entity_id: str) -> GwEntityData:
198198
# Switching groups data
199199
self._entity_switching_group(entity, data)
200200
# Adam data
201-
self._get_adam_data(entity, data)
201+
if self.smile(ADAM):
202+
self._get_adam_data(entity, data)
202203

203204
# Thermostat data for Anna (presets, temperatures etc)
204205
if self.smile(ANNA) and entity["dev_class"] == "thermostat":
@@ -228,28 +229,23 @@ def _get_adam_data(self, entity: GwEntityData, data: GwEntityData) -> None:
228229
available regulations_modes and thermostat control_states,
229230
and add missing cooling_enabled when required.
230231
"""
231-
if self.smile(ADAM):
232+
if entity["dev_class"] == "heater_central":
232233
# 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-
):
234+
if self._on_off_device and isinstance(self._heating_valves(), int):
238235
data["binary_sensors"]["heating_state"] = self._heating_valves() != 0
239-
240236
# Add cooling_enabled binary_sensor
241-
if entity["dev_class"] == "heater_central" and "binary_sensors" in data:
237+
if "binary_sensors" in data:
242238
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
239+
data["binary_sensors"]["cooling_enabled"] = self._cooling_enabled
240+
241+
# Show the allowed regulation_modes and gateway_modes
242+
if entity["dev_class"] == "gateway":
243+
if self._reg_allowed_modes:
244+
data["regulation_modes"] = self._reg_allowed_modes
245+
self._count += 1
246+
if self._gw_allowed_modes:
247+
data["gateway_modes"] = self._gw_allowed_modes
248+
self._count += 1
253249

254250
def _climate_data(
255251
self,

0 commit comments

Comments
 (0)