Hi,
I have a HABApp rule to open/close blinds on sunrise/sunset.
I’m finding that both are triggering a little too early for my liking, so thought I’d put in a delay using countdown:
This should, on sunrise, trigger a 900 second countdown, which will then call my “SunriseTriggered” function.
However, it doesn’t.
This is similar to code I use for handling lights connected to motion sensors and that works as expected.
I suspect I’m missing something obvious, but I can’t see it.
Any ideas?
Hi,
In the northwest of the UK sunset today was 4pm, so “Night Mode” should have triggered at 4:15pm (the 15 minute offset), however, it triggered at 4pm - ignoring the offset.
This is the code used:
class DayNightMode(HABApp.Rule):
def __init__(self):
super().__init__()
self.run.on_sunrise(self.DayTriggered).offset(timedelta(minutes=15))
self.run.on_sunset(self.NightTriggered).offset(timedelta(minutes=15))
def DayTriggered(self):
# Day
log.info( f'Day Mode initiated.')
def NightTriggered(self):
# Night
log.info( f'Night Mode initiated.')
Am I missing something?
Update: as ive now found that i was only running habapp 1.0.3 (which I’ve now resolved), I wonder if it will work - assuming the offset functionality didn’t exist in v1.0.3?
You’ll get the next execution time with get_next_run.
You can print it before you apply the offset and afterwards and you’ll see that the offset works.
Be aware that the sunset is defined as when the sun goes below the horizon so you’ll still have some daylight left.
Hi,
I’ve done some testing and it works.
I did some more digging into my config and found an error in my lat/long entries in my config.yaml file that didn’t match OpenHab.
Once I updated that and restarted HabApp I was getting it working as expected.