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

Run script every 5 minutes between sunrise and sunset #70

Open
gls21 opened this issue Apr 4, 2023 · 1 comment
Open

Run script every 5 minutes between sunrise and sunset #70

gls21 opened this issue Apr 4, 2023 · 1 comment

Comments

@gls21
Copy link

gls21 commented Apr 4, 2023

Is it possible to use heliocron to run a script every x amount of minutes between sunrise and sunset, as opposed to using it to trigger a single event relative to sunrise/set?

@bgro82
Copy link

bgro82 commented Jun 27, 2023

I'd probably try to do this with cron calling a script every x minutes and the script using heliocron to evaluate if the current time is between sunrise and sunset. For example I use something like the below in Python to collect the day state from Heliocron into a string:

def daylight_state(lat, lon):
    result = subprocess.run(["/home/pi/heliocron", "-l", str(lat), "-o", str(lon), "poll", "--json"],
                            capture_output=True)
    data = json.loads(result.stdout)
    return data["day_part"]

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

2 participants