HABApp 25.02.x scheduler - how do I show the execution times?

I’m operating my window blinds with (among other triggers) with the sunset and sunrise triggers:

        self.run.at(self.run.trigger.sunset(), self.run_sunset)
        self.run.at(self.run.trigger.sunrise(), self.run_sunrise)

The code executes successfully, so no issues with that, but how would I go about telling when the next execution would take place?

Ideally, I would have a DatetimeItem on the openHAB side which I could update with the expected execution times. Just using the astro binding would be one possible workaround but I’m looking for the general solution.

self.run.at returns an DateTimeJobControl object.
There you can use .last_run_datetime or .next_run_datetime.
You can also use .to_item(item) to automatically send the next execution time to a HABApp or openHAB item.
So

sunset_job = self.run.at(self.run.trigger.sunset(), self.run_sunset)
sunset_job.to_item(DatetimeItem.get_item('DtItemName'))

That way you can automatically show the next execution time, even if you have complex triggers (e.g. with a trigger group and/or filters).

Thank you, this did work perfectly, especially with a bit of added complexity to the rules so I have more family compliant timings :

# Open the blinds at sunrise, but but earliest at 07:15
sunrise_job = self.run.at(self.run.trigger.sunrise().earliest('07:15:00'), self.run_daily_open)
sunrise_job.to_item(DatetimeItem.get_item('HABApp_Windows_Blinds_Opening_Time'))

# Close the blinds at 15 minutes before sunset
sunset_job = self.run.at(self.run.trigger.sunset().offset(-900), self.run_daily_close)
sunset_job.to_item(DatetimeItem.get_item('HABApp_Windows_Blinds_Closing_Time'))
1 Like