spacemanspiff2007 / HABApp

Easy home automation with MQTT and/or openHAB
Apache License 2.0
54 stars 23 forks source link

problem with .latest method #410

Closed chris-hunter closed 9 months ago

chris-hunter commented 9 months ago

Dear Spacemanspiff, Thank you for the excellent habapp. I have run into a problem with using the .latest method with an .every job. When I use this, the rule loads ok and the .every job runs fine until the .latest time, but then habapp seems to hang and I have to restart it. There is no error in the logs at this time (all the logs stop logging anything). I am using HABApp version 1.1.2, openhab version 4.0.2, python version 3.10.12 on ubuntu 22.04.3. My rules file is as follows:

import logging
from HABApp import Rule
from datetime import time, timedelta
log = logging.getLogger('RuleLog')

class SchedulerPractice(Rule):
    def __init__(self):
        super().__init__()

        lights_off_job = self.run.every(start_time=time(21, 15, 00), interval=timedelta(
            seconds=30), callback=self.scheduler_practice_method)
        lights_off_job.latest(time(21, 17, 00))

    def scheduler_practice_method(self):
        log.info(f'scheduler_practice_method called')

SchedulerPractice()
spacemanspiff2007 commented 9 months ago

Thank you for your report. I can reproduce this issue.

spacemanspiff2007 commented 9 months ago

I've provided a fix in the dev branch. Can you try it out and confirm everything works as expected?

chris-hunter commented 9 months ago

Thanks - I've tried it and it seems to be working now