Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-calulation produces the same result every day? #66

Open
AndKe opened this issue Mar 2, 2021 · 0 comments
Open

Re-calulation produces the same result every day? #66

AndKe opened this issue Mar 2, 2021 · 0 comments

Comments

@AndKe
Copy link

AndKe commented Mar 2, 2021

my application call this funtion every day at 00:01 to update the dusk-dawn data:

def init_light_schedule():
    city = LocationInfo("Tromsø", "Norway", "Europe/Tromsø", 69.66, 18.82)
    s = sun(city.observer)  # , s=datetime.date(2021, 2, 18))

    dawn = (s['dawn'] + datetime.timedelta(hours=1))  # negative hours gives earlier "off"
    dusk = (s['dusk'] + datetime.timedelta(hours=1))  # positive hours postpone "on"
    dawn = dawn.replace(tzinfo=None)  # remove timezone info
    dusk = dusk.replace(tzinfo=None)
    now = datetime.datetime.now()
    # for testing now = datetime.datetime(2021, 2, 17, 2, 00)
    print(time.strftime('%H:%M:%S'), ', light schedule updated')
    print('dawn: ', dawn)
    print('dusk: ', dusk)

but the output does not show new data, it is displaying the data of the first day of the script run:
21:37:08 , light schedule updated <<<<< initial run (manual start)
dawn: 2021-03-01 06:08:20.148169
dusk: 2021-03-01 17:47:39.511878
00:01:00 , light schedule updated <<<< the function was executed on schedule, produced the same time(and date)
dawn: 2021-03-01 06:08:20.148169
dusk: 2021-03-01 17:47:39.511878

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant