minor changes to timer code

This commit is contained in:
avollkopf 2023-03-08 06:58:17 +01:00
parent 4d1c24e2c1
commit bffa3c36e3
2 changed files with 5 additions and 7 deletions

View file

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

View file

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