timer fix

This commit is contained in:
avollkopf 2023-03-08 19:21:07 +01:00
parent bffa3c36e3
commit f5e6b22f01
2 changed files with 5 additions and 3 deletions

View file

@ -1,3 +1,3 @@
__version__ = "4.1.6.b4"
__version__ = "4.1.6.b5"
__codename__ = "Groundhog Day"

View file

@ -27,9 +27,10 @@ class AlarmTimer(CBPiSensor):
self.stopped=False
self.time = float(time)
self.value=self.calculate_time(self.time)
if self.timer is None:
if self.timer is not None:
await self.timer.stop()
self.timer = Timer(int(self.time * 60), on_update=self.on_timer_update, on_done=self.on_timer_done)
await self.timer.stop()
self.timer.is_running = False
logging.info("Set Timer")
@ -55,10 +56,11 @@ class AlarmTimer(CBPiSensor):
@action(key="Reset Timer", parameters=[])
async def Reset(self , **kwargs):
self.stopped=False
if self.timer is None:
if self.timer is not None:
await self.timer.stop()
self.value=self.calculate_time(self.time)
self.timer = Timer(int(self.time * 60), on_update=self.on_timer_update, on_done=self.on_timer_done)
await self.timer.stop()
self.timer.is_running = False
logging.info("Reset Timer")