-
-
Notifications
You must be signed in to change notification settings - Fork 1k
SimpleWeatherService: Add sunrise and sunset data #2100
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
base: main
Are you sure you want to change the base?
Conversation
|
Build size and comparison to main:
|
b42424e to
3cf3eb9
Compare
2f6288d to
c7a50f9
Compare
|
Woult it be enough to have the sunset and sunrise in minutes resolution. If so we could define the sunset sunrise timestamps to be in minutes since midnight. Then we only need What do you think? |
|
I like this idea. A quick/naïve implementation would be to truncate the timestamp that Gadgetbridge sends, and we pad it when calculating the actual time, but then the resolution becomes arbitrary. What you're suggesting instead is Gadgetbridge essentially doing something like -long sunriseLocal = weatherSpec.sunRise + Calendar.getOffset("UTC").getTimeInMillis()) / 1000L;
+int sunriseLocal = (weatherSpec.sunRise + Calendar.getOffset("UTC").getTimeInMillis()) / 1000L) / 60;(or whatever the type conversion looks like) I'll give that a try and see what happens. |
|
Ah, nevermind - I see what you're suggesting. Diving the timestamp doesn't really change the size. Math is hard 🤦 |
c7a50f9 to
76a50a4
Compare
76a50a4 to
c57bbee
Compare
c57bbee to
def20a0
Compare
|
To test with InfiniSim with |
def20a0 to
d6ab2e9
Compare
86f3679 to
d06bb24
Compare
d06bb24 to
de7cf7b
Compare
de7cf7b to
a0a9a78
Compare
a0a9a78 to
c302128
Compare
c302128 to
4f2b246
Compare
|
Once this is merged, I'll let the Gadgetbridge folks know so that they can merge the changes on their side (they're waiting for this PR to be merged first). Let me know if there's any change requests here. |
4f2b246 to
7937626
Compare
7937626 to
04b8bc8
Compare
ba22757 to
6d4e51c
Compare
6d4e51c to
91cc0e5
Compare
145a77b to
6360802
Compare
fccc88c to
fa40b48
Compare
|
Thank you very much for creating and maintaining this PR (in InfiniTime, InfiniSim AND Gadgetbridge!) @vkareh ! Could you confirm that these change do not break the compatibility between InfiniTime and companion apps, thanks to the |
|
@JF002 Good question. With regards to Gadgetbridge, it should always works, since it's based on firmware version detection. The API is additive, so either you have sunrise data or you don't, but the preceding bits are not affected. GB only sends v1 weather data to >=0.15 InfiniTime, else it sends v0 weather. This works in both directions (old IT + new GB; old GB, new IT; etc.) With regards to other companion apps, it depends on whether they check the firmware version:
So basically the only situation in which it would break weather functionality is if the companion app sends version 1 weather without checking what version of InfiniTime it is. |
|
Thanks @vkareh, that looks good to me.
Mhm you are right... This looks like something we could improve in the future : expose the version of the weather API so that companion apps have a easier way to know which version of the messages to send. So I guess this is safe to merge this PR and the one on Gadgetbridge side. |
|
Yeah basically all I wanted with that comment was to formalise the protocol for errors/exceptional cases
So polar day would be sunrise at 0, sunset -2, and polar night sunrise -2, sunset 0 |
|
@mark9064 - this could be nice, but it borders on being an edge case. I think implementing it here is fairly easy, but I'm not sure how to accomplish this in Gadgetbridge if the weather provider doesn't support the concept of polar day/night. |
|
I suppose those corner cases could be indicated as 00:00 or 24:00 — i.e., 0 or 1440 minutes. It would be great to follow how the OpenWeather API or other APIs describe those cases. |
|
I honestly don't know if there's a state of the art for handling days/night without sunrise/sunset. I've never had the opportunity to go to such place :p But yeah, @mark9064 suggestion looks reasonable. Looking at OpenWeather API is another good suggestion from @jmlich. I'm not used to working with the OpenWeather API, but here is how sunrise and sunset are documented : So I guess they return an absolute epoch timestamp for the sunrise and sunset, instead of a relative one from midnight. |
fa40b48 to
c4fe253
Compare
|
@JF002 let me know if you want me to implement this as part of this PR. It would require changes to Gadgetbridge as well. The overall logic would probably look something like:
(same logic for sunset) |
|
To flesh it out, do you mean something like: 0<=x<1440 sunrise happens this many minutes into the day 0<x<1440 sunset happens this many minutes into the day So polar day would be 0,-2 and polar night -2,-2 Not permissible: Note: (x,-2) where x >= 0 valid, this corresponds to a day which has sunrise only. (0,x) corresponds to sunset only Sorry to make this so long... all problems involving date and time seem to have horrible edge cases. My goal here is not to make implementation difficult but instead to have a clear protocol that handles all possibilities. The implementations of the protocol don't need to handle all the edge cases! They could choose to bail on the more complex scenarios. But if we have a clear protocol, then we don't need to upgrade it in future if we decide we do care more about those trickier cases |
|
@vkareh we'd really like to get 1.16 out shortly, do you think you'll be able to look at this soon? |
|
Sorry for this late answer, I had some unexpected events at home :) The current API is already nice and covers 99.9% of the use-cases, but yeah, @mark9064 's suggestion allows us to cover > 99.99%, I guess :-) Since we want to release 1.16 "as soon as possible" (you should read : "as soon as it's ready", no pressure involved here!), I think we have 2 options:
So yeah, if you have the opportunity to implement those changes, I think it would be nice! PS : Merry Christmas everyone :) |
2690748 to
3d7afb0
Compare
|
I've implemented the above protocol (previous commit is unchanged, just rebased onto main) This should be compatible with any existing Gadgetbridge implementation, as (0,0) is rejected by the validator and turns into (-1,-1) (unknown). The fields work as before for days with a sunrise and sunset Completely untested @vkareh how does this protocol sound to you? |
3d7afb0 to
00f6495
Compare


This receives sunrise and sunset data from the weather service and adapts weather icons to represent the correct time of day (sun or moon).
It requires a new version of the weather service data byte array.