Skip to content

Commit d1fb6ae

Browse files
committed
Simplify highest setpoint with filter and max default
1 parent 0b04c86 commit d1fb6ae

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

src/evohome_helper/evohome.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,9 @@ def _get_highest_set_point_temp(location: Location) -> float | None:
217217
if not zones:
218218
return None
219219
now = get_current_time(location)
220-
active_setpoints = [_get_active_setpoint(zone, now) for zone in zones]
221-
valid_setpoints = [setpoint for setpoint in active_setpoints if setpoint is not None]
222-
if not valid_setpoints:
223-
return None
224-
return max(valid_setpoints)
220+
active_setpoints = (_get_active_setpoint(zone, now) for zone in zones)
221+
valid_setpoints = filter(lambda setpoint: setpoint is not None, active_setpoints)
222+
return max(valid_setpoints, default=None)
225223

226224

227225
@_retry

0 commit comments

Comments
 (0)