Code Monkey home page Code Monkey logo

heliocron's Issues

Useful utility

Not an issue but I can't find anywhere else to comment, so please delete comment if inappropriate.

I needed exactly this utility and it works a treat. Easily installed by the R Pi binary although I did take a look at Rust and nearly persuaded myself to do it the hard way.

Anyway, to control my living room lamp, I now have an R Pi with heliocron, a bit of Python, MQTT, and wifi to a Chinese switch flashed with Tasmota. What could possibly go wrong 😉

test parsers::tests::test_parse_date ... FAILED

I tried building with the PKGBUILD script in the Arch User Repository and test_parse_date failed:

    Finished release [optimized] target(s) in 58.95s
     Running unittests (target/release/deps/heliocron-da9bfa9da31946ab)

running 23 tests
test calc::tests::test_day_fraction_to_time_underoverflow ... ok
test calc::tests::test_day_length ... ok
test calc::tests::test_day_fraction_to_time ... ok
test calc::tests::test_day_length_24_hour_day ... ok
test calc::tests::test_day_length_24_hour_night ... ok
test enums::tests::test_custom_event_instantiation ... ok
test enums::tests::test_non_custom_event_instantiation ... ok
test enums::tests::test_non_custom_ignores_altitude ... ok
test parsers::tests::test_parse_altitude ... ok
test parsers::tests::test_parse_date_wrong_format_fails ... ok
test parsers::tests::test_parse_event ... ok
test parsers::tests::test_parse_date ... FAILED
test parsers::tests::test_parse_offset ... ok
test report::tests::test_report_content ... ok
test report::tests::test_solar_report_new ... ok
test structs::tests::test_parse_latitude ... ok
test structs::tests::test_parse_longitude ... ok
test report::tests::test_sunrise_sunset ... ok
test traits::tests::test_day_fraction ... ok
test utils::tests::test_wait ... ok
test traits::tests::test_to_juilian_date ... ok
test parsers::tests::test_parse_event_fails ... ok
test parsers::tests::test_parse_date_wrong_tz_fails ... ok

failures:

---- parsers::tests::test_parse_date stdout ----
thread 'parsers::tests::test_parse_date' panicked at 'assertion failed: `(left == right)`
  left: `2020-03-25T12:00:00+00:00`,
 right: `2020-03-25T12:00:00-06:00`', src/parsers.rs:137:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    parsers::tests::test_parse_date

test result: FAILED. 22 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

error: test failed, to rerun pass '--lib'
==> ERROR: A failure occurred in check().
    Aborting...
error making: heliocron

Binary 0.5.0 on arm-unknown (RPi 0) appear broken on RPi0W

I just installed the binary https://github.com/mfreeborn/heliocron/releases/download/v0.5.0/heliocron-v0.5.0-arm-unknown-linux-gnueabi.tar.gz onto a Raspberry Pi 0 WiFi running Raspbian 10 (buster).

When I call heliocron, it always estimates sunrise and sunset to be at 00:00:00 local time (and hence the day is pretty short).

So something isn't working in that release.

Here is a sample output from the RPi0w (from README.md and works fine on another Linux box I tested on):

user@rpi0w:~/heliocron-v0.5.0-arm-unknown-linux-gnueabi $ ./heliocron -d "7 May 2065" -f "%e %B %Y" -l 55.9533N -o 3.1883W report
LOCATION
--------
Latitude: 55.9533N
Longitude: 3.1883W

DATE
----
2065-05-07 12:00:00 +01:00

Solar noon is at:         2065-05-07 00:00:00 +01:00
The day length is:        0h 0m 0s

Sunrise is at:            2065-05-07 00:00:00 +01:00
Sunset is at:             2065-05-07 00:00:00 +01:00

Civil dawn is at:         2065-05-07 00:00:00 +01:00
Civil dusk is at:         2065-05-07 00:00:00 +01:00

Nautical dawn is at:      2065-05-07 00:00:00 +01:00
Nautical dusk is at:      2065-05-07 00:00:00 +01:00

Astronomical dawn is at:  2065-05-07 00:00:00 +01:00
Astronomical dusk is at:  2065-05-07 00:00:00 +01:00

I assume something doesn't quite build right on this platform, although I haven't tried to rebuild from source.

Build on MacOs

Hi,

When I try to build (rustc 1.65.0 (897e37553 2022-11-02)) the project (v0.8.1) on arm64-apple-darwin22.1.0 (MacOs 13.0 (22A380)), I get a compilation error for tokio-walltime v0.1.2. Errors are of the kind
error[E0425]: cannot find function `timer_create` in crate libc.
I tried on Linux and I had no problem.

I'm not sure what I should be looking for, I'm not a rust expert.

Otherwise, the plugin seems nice!

Only waits for 1 hour then stops

Heliocron only seems to wait 1 hour then stops, prior to executing script.

syslog shows counting per min for 60 min then halting with no error.

Add support for Jewish dusk

It would be great if the wait command of this project could support "Jewish dusk", more commonly known as the time in the evening when the ritual of havdalah is done. (Other names for this time that you'll find if you look around the web are "tzeit hakochavim" or "the appearance of three stars".) The time for this is not universally agreed upon, but the most commonly used time is when the center of the sun is 8.5 degrees below the horizon.

compilation errors on cubieboard 1

I'm trying to compile heliocorn on a cubieboard1 running armbian, and I'm getting the following errors:

error[E0599]: no method named "as_deref" found for type "std::option::Optionstd::string::String" in the current scope
--> src/config.rs:140:37
|
140 | date_args.time_zone.as_deref(),
| ^^^^^^^^ help: did you mean: "as_ref"

error[E0658]: use of unstable library feature 'range_contains': recently added as per RFC (see issue #32311)
--> src/structs.rs:141:39
|
141 | n if (0.0..=90.0).contains(&n) => Ok(n),
| ^^^^^^^^

error[E0658]: use of unstable library feature "range_contains": recently added as per RFC (see issue #32311)
--> src/structs.rs:197:40
|
197 | n if (0.0..=180.0).contains(&n) => Ok(n),
| ^^^^^^^^

error: aborting due to 3 previous errors

Some errors occurred: E0599, E0658.
For more information about an error, try "rustc --explain E0599".
error: Could not compile "heliocron".

I've tried to understand a bit more about the errrs, but with no luck... do you have any idea?

thanks
rosanna

Read config from `/etc`

Might be useful to read a configuration file from standard locations such as /etc and /usr/local/etc. Would submit a PR myself but don't speak Rust!

Depending on seasons?

Is it possible to allow the definition of heliocron jobs not only in relation to sunrise/sunset times, but also depending on the current season?
For example: a heater must not necessarily be turned on in the summer time.

New Zealand time zone and location seems to fail

So, I ran this command on my server at Midnight or just after, time zone config is in New Zealand Standard Time.
(this is a Debian 10 install - downloaded heliocron binary package)

root@hostname:/date : Tue Jun 28 00:10:45 NZST 2022
Then ran :
root@hostname:/heliocron -l 37.03216S -o 175.1220E wait --event sunrise && banner hello
Which results in this error
Runtime error: The chosen event occurred in the past: 2022-06-27 16:25:35 +12:00. Cannot wait a negative amount of time.

I have tried to run time zones, but all to no avail, even +18 hours results in a fail where it 'can not wait a negative amount of time'
I might be having a dumb moment here, and not seeing something, but just am really puzzled as to what is going on.

I was going to send a private message as it had GPS locations in, but managed to move them enough away into forest land near my house to be happy enough to post..

Could you please suggest anything I could try to see if I could resolve this..
The fish will thank you for their wakeup with the sun and sleep with the setting sun...

TZ issue

hello,
i'm not able to figure out how to set different time zones. for me it just doesn't work as expected:

cargo run -- --latitude 55.7558N --longitude 37.6173E  report # Moscow
LOCATION
--------
Latitude: 55.7558N
Longitude: 37.6173E

DATE
----
2022-01-18 12:00:00 +03:00

Solar noon is at:         2022-01-18 12:39:53 +03:00
The day length is:        7h 48m 15s

Sunrise is at:            2022-01-18 08:45:46 +03:00
Sunset is at:             2022-01-18 16:34:01 +03:00
...

so good so far,

TZ=EST cargo run -- --latitude 40.7128N --longitude 74.0060W  report # New York
LOCATION
--------
Latitude: 40.7128N
Longitude: 74.0060W

DATE
----
2022-01-18 12:00:00 -05:00

Solar noon is at:         2022-01-18 12:06:29 -05:00
The day length is:        9h 40m 11s

Sunrise is at:            2022-01-18 07:16:24 -05:00
Sunset is at:             2022-01-18 16:56:35 -05:00
...

ok

cargo run -- --latitude 40.7128N --longitude 74.0060W  -t -05:00 report # New York
LOCATION
--------
Latitude: 40.7128N
Longitude: 74.0060W

DATE
----
2022-01-18 12:00:00 +03:00

Solar noon is at:         2022-01-18 20:06:23 +03:00
The day length is:        9h 39m 38s

Sunrise is at:            2022-01-18 15:16:34 +03:00
Sunset is at:             2022-01-19 00:56:12 +03:00
...

doesn't work -t -05:00 option

TZ=PST cargo run -- --latitude 37.7749N --longitude 122.4194W  report # San Francisco
LOCATION
--------
Latitude: 37.7749N
Longitude: 122.4194W

DATE
----
2022-01-18 12:00:00 +00:00

Solar noon is at:         2022-01-18 20:20:05 +00:00
The day length is:        9h 54m 43s

Sunrise is at:            2022-01-18 15:22:43 +00:00
Sunset is at:             2022-01-19 01:17:26 +00:00
...

doesn't work even with TZ set to seemed correct PST time zone

could you please point me to where what i missed something? Thanks!

Output ISO8601 dates

Currently heliocron reports events as Never or very similar to date '+%Y-%m-%d %H:%M:%S %:z', this is nonstandard and it would be very easy to output in ISO8601 instead, as chrono::DateTime has a to_rfc3339 method. Furthermore, there is no way to control the timezone of output dates.

Add "poll" mode.

Once nice thing about sunwait is that it lets you ask the question "is it day or night right now" via sunwait poll. This is helpful for setting light vs dark themes. Could heliocron grow such an option?

cannot understand

Hi, thank you for sharing this software.
However i don't understand how i can connect the numbers with the sunrise/set times that i get
from arduino libraries and my domoticz program, they calculate 8.37 sunrise and 16.30 sunset.

i am using it on a raspberry zero raspbian buster.
systemtime reports to be oke. Longitude and latitude are in the config file.

could you give me a hint on what i can do? I also have troubles to understand the +01:00 i see in the rows


Latitude: 51.4000N
Longitude: 5.4670W

DATE

2021-12-15 12:00:00 +01:00

Solar noon is at: 2021-12-15 13:17:05 +01:00
The day length is: 7h 52m 40s

Sunrise is at: 2021-12-15 09:20:45 +01:00
Sunset is at: 2021-12-15 17:13:25 +01:00

Civil dawn is at: 2021-12-15 08:40:42 +01:00
Civil dusk is at: 2021-12-15 17:53:29 +01:00

The chosen event occurred in the past

I have lots of problems to schedule the cron job correctly. All the time I get message:

Runtime error: The chosen event occurred in the past; cannot wait a negative amount of time.

Which is funny, because I trigger event at 02:00, and sunrise is 08:51:11
Same goes for sunset: job scheduled at 12:00, sunset at 14:55.

Apparently, there are some problems when date is today.

I think it's obvious, if I wait for sunrise (without specific --date), I mean the next coming sunrise tomorrow morning. I can't process why this program assumes I care about sunrise which already happened today morning. Maybe some sort of --force flag will do?

Getting Illegal Instruction when attempting to run on Raspberry Pi Zero W with latest OS

I have tried both the full version of the Raspbian OS and the light version and it is happening with both OSes. I think it might be a hardware issue, because the version of heliocron for my Pi3+ runs just fine on the latest OS. This is happening on the prebuilt binary additional for the Pi1/0.

Please let me know if you need any further information.

Feature Request: Add 'tag' or 'comment' parameter.

Because these processes run for a prolonged period of time -- it would be nice to be able to include some sort of 'tag' or 'comment' parameter, so that the purpose of the heliocron process could be identified more easily via 'ps'. The parameter/value doesn't need to actually do anything - but including one currently causes an error for an invalid parameter.

Request: Allow next time each event occurs and not assume system runs continuously.

Mirror of this #25

I would love to integrate heliocron with fcron to execute a script every day regardless of system status (suspend, hibernate, power-down) at sundown and sunrise. The application would be using brightnessctl to automatically dim or engage keyboard backlight or screen backlight.

Heliocron assumes the system does not run continuously. Using fcron to run it, heliocron does not execute past events nor (as in acejacek's and my case) events occurring the same day.

I think this would be a brilliant tool that very many users could appreciate, as it has so much potential to be a battery saver.

README.md needs updating?

I've just noticed that some instructions and examples in README.md file might need updating.
It seems helicron no longer uses symbols N, S, E, and W; instead we should use numerical values only for North (N) and East (E), and a minus sign before numerical values for South (S) and West (W).

Additionaly, the values in the configuration file shouldn't be quoted, and that section should be changed like this:

# set the default location to Buckingham Palace
latitude = 51.5014
longitude = -0.1419

Bug: panic if sunrise/sunset overflows to the next day

When calculating sunset and sunrise, it panics if sunrise or sunset crosses over to the next or previous day. This can happen if you want to find, for example, sunset time somewhere on the opposite side of the world but with your own timezone.

Doesn't seem to be working through cron

Hi,

I've installed heliocron as I have scripts that I'd like to run at sunrise and sunset but they're not running. When I use 'heliocron report' I do get the correct results so I know it's installed properly.

In my crontab, I have the following (I've hidden my lat/long):

00 15 * * * heliocron --latitude xx.xxxx --longitude yyy.yyyy wait --event sunset \ && /usr/local/bin/dim.sh

00 02 * * * heliocron --latitude xx.xxxx --longitude yyy.yyyy wait --event sunrise \ && /usr/local/bin/brighten.sh

I do have the correct lat long configured in .config/heliocron.toml but added them in the cron entries just in case they were specifically needed there. I've tried without as well.

But nothing happens at sunrise or sunset, my scripts aren't run.

Have I missed something really obvious please?

I'm using a Raspberry Pi with Raspbian Stretch. It needs to be Stretch, what I'm running won't work with a later version.

Thanks.

Config File issue

Howdy from Texas!

I stumbled upon Heliocron while working on a timelapse project designed to run on a RPi. I am trying to get it set up to use in crontab for launching my script at sunrise each day.

I love the elegance of your solution, thanks for contributing it to the world!

My issue is with setting my GPS location in the config file I created at ~/.config/heliocron.toml.

# ~/.config/heliocron.toml
# set the default location to Texas Capitol    
latitude = "30.274N"
longitude = "-97.740W"

Perhaps I'm doing something stoopid?

When I run heliocron --version, I get:
Config error: Error parsing TOML file. Ensure that it is of the correct format.

Add support for a config file

Currently heliocron has some hardcoded defaults for parameters such as location. It would be nice to be able to configure this, perhaps so that you can set the default location (and other things) to your own coordinates.

It would be something like a file such as ~/.config/heliocron.conf with key=val entries which are read into heliocron when it runs. These values would override any other defaults.

Multiple instances in cron

I’m using Heliocron to schedule a Timelapse at sunrise, sunset, and with a different exposure after dark. If I kick them all off from a cron, they seem to fail. Or perhaps heliocron is not multithreaded? And only the last one triggered works?

I know the syntax is correct because I can run any of the commands manually from a shell. But if I trigger them all from cron at say 0 1 * * * even staggered by a minute two, they fail.

Do I need to make sure there’s only one sleeping at a time from Cron?

Not showing proper time when using report function?

When using report, the time is reported as local noon time:

LOCATION
--------
Latitude: 
Longitude: 

DATE
----
2023-08-09 12:00:00 -03:00

Solar noon is at:         2023-08-09 13:19:48 -03:00
The day length is:        14h 20m 16s

Sunrise is at:            2023-08-09 06:09:40 -03:00
Sunset is at:             2023-08-09 20:29:56 -03:00

Civil dawn is at:         2023-08-09 05:37:13 -03:00
Civil dusk is at:         2023-08-09 21:02:23 -03:00

Nautical dawn is at:      2023-08-09 04:56:53 -03:00
Nautical dusk is at:      2023-08-09 21:42:43 -03:00

Astronomical dawn is at:  2023-08-09 04:11:40 -03:00
Astronomical dusk is at:  2023-08-09 22:27:56 -03:00

However, when using poll, the time is reported is the same as the system time:

LOCATION
--------
Latitude:  
Longitude: 

DATE
----
2023-08-09 19:00:39 -03:00
Day

Solar elevation: 14.396°
Azimuth angle:   278.083°

Is this correct behavior or should report also give the system time?

(Note: I've removed my latitude and longitude as that would identify where I am located, but are entered in my config.toml file.)

Does not work if system sleeps or is suspended

When my laptop goes to sleep, or is suspended, heliocron sleeps for far too long. I suspect this is because its main std::thread::sleep call does not make progress while the system itself is suspended. This is expected behavior according to the sleep docs, so heliocron shouldn't be using this call. A better alternative would probably be sleep_until from tokio, but that would require an async rewrite.

Feature: Add a simple graph showing solar elevation in the terminal with the report subcommand

It would be great if the report subcommand showed a simple line chart with time on the x axis and solar elevation on the y axis.

It would be even better if the chart could be annotated with, for example, sunrise, sunset and solar noon.

I've had a play around with textplots-rs, but it's missing a few key featrures:

  • specifying y axis range
  • specifying individual axis tick locations
  • time-series axis labels
  • annotations

Here is an example of what I can achieve with it up to its limitations:

Screenshot from 2020-12-28 17-36-35

And, for reference, this is the graph I would like to replicate:

example sunrise chart

Implement the --event flag {sunrise | sunset} as an enum

As per title, it would be much better to have this return an Event enum, rather than a String. From the Reddit thread:

For the enum, you just have to implement FromStr for parsing enum variants (for example matching on "sunrise", "sunset" or return an error), and in Structopt you can specify what are the possible values for a field with the attribute #[structopt(possible_values = &["foo", "bar", "thing"])].

Pre-built binary for 64bit pi OS (aarch64)

Perhaps I'm just misunderstanding, but having issues getting any of the pre-built binaries to run for 64bit raspbian on a raspberry pi 3 (aarch64) - I'm guessing they are 32bit only and the 64bit download is for x86. Thank you for your work on this project, has been a huge help to some custom home automation projects I've been working on!

Add time thresholds

Hi, thanks for this handy tool!

My use case for heliocron is to control window blinds: open at sunrise and shut at sunset. That works fine for the most part of the year, except for the summer.
For example, I would like to wake up at 07:00 in the morning, but if the sun rises at 06:00 or even earlier and the blinds open with sunrise, my morning is ruined... Also in the evening I would like my room to be dark when I go to bed, but sun may be setting much later than that.
I thought, it would be convenient to have 2 more threshold options in heliocron:

  1. "No earlier than". It would prevent sunrise event from firing before specified time. As per example above, if I would like to set a threshold that blinds never open before 07:00. Only at 07:00 or later.
  2. "No later than". Similarly in the evening, the sunset event would be fired no later than specified time. E.g., my blinds would always shut at 22:00 if the sun sets after that time.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.