From 95c2a4e72321432f248d9e3e4da75d6392e4c1b8 Mon Sep 17 00:00:00 2001 From: rgc99 Date: Wed, 22 Nov 2023 06:28:02 +0000 Subject: [PATCH] Optimise funtion --- .../irrigation_unlimited/irrigation_unlimited.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/custom_components/irrigation_unlimited/irrigation_unlimited.py b/custom_components/irrigation_unlimited/irrigation_unlimited.py index 32fae19..070c035 100644 --- a/custom_components/irrigation_unlimited/irrigation_unlimited.py +++ b/custom_components/irrigation_unlimited/irrigation_unlimited.py @@ -2638,7 +2638,10 @@ def zone_runs(self, sequence_zone: IUSequenceZone) -> list[IURun]: def run_index(self, run: IURun) -> int: """Extract the index from the supplied run""" - return list(self._runs.keys()).index(run) + for i, key in enumerate(self._runs): + if key == run: + return i + return None def sequence_zone(self, run: IURun) -> IUSequenceZone: """Extract the sequence zone from the run"""