From d49afa5bed81ddc194eb5b30fcda596640b3c05d Mon Sep 17 00:00:00 2001 From: Linus Dietz <45101649+Dielee@users.noreply.github.com> Date: Mon, 31 Jul 2023 08:56:16 +0200 Subject: [PATCH] Remove done climate timers from "Active schedules" sensor --- src/mqtt.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/mqtt.py b/src/mqtt.py index e4a17c3..af7a4c7 100644 --- a/src/mqtt.py +++ b/src/mqtt.py @@ -138,7 +138,7 @@ def start_climate_timer(d, vin): return None if timer_seconds > 0: - Timer(timer_seconds, start_climate, (vin, )).start() + Timer(timer_seconds, activate_climate_timer, (vin, start_datetime.isoformat(), )).start() active_schedules[vin]["timers"].append(start_datetime.isoformat()) logging.debug("Climate timer set to " + str(start_datetime)) update_car_data() @@ -184,6 +184,12 @@ def stop_climate(vin): update_car_data() +def activate_climate_timer(vin, start_time): + start_climate(vin) + active_schedules[vin]["timers"].remove(start_time) + update_car_data() + + def start_climate(vin): global assumed_climate_state, climate_timer, engine_status # Start the api call in another thread for HA performance