From f088a23da771d1d1251dbb756bd738d9e52280d1 Mon Sep 17 00:00:00 2001 From: John Lancaster <32917998+jsl12@users.noreply.github.com> Date: Fri, 8 Dec 2023 16:36:22 -0600 Subject: [PATCH] maybe this time? --- room_control.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/room_control.py b/room_control.py index d57e9e7..6db197b 100755 --- a/room_control.py +++ b/room_control.py @@ -99,7 +99,7 @@ class RoomController(Hass, Mqtt): yield state states = [s async for s in gen()] - # states = sorted(states, key=lambda s: s['time'], reverse=True) + states = sorted(states, key=lambda s: s['time'], reverse=True) return states async def current_state(self, time: time = None): @@ -115,7 +115,7 @@ class RoomController(Hass, Mqtt): time = time or (await self.get_now()).time() time_fmt = "%I:%M %p" self.log(f'Getting state before: {time.strftime(time_fmt)}') - for state in self.states[::-1]: + for state in self.states: time_str = state["time"].strftime(time_fmt) if state['time'] <= time: self.log(f'Selected state from {time_str}')