lunar-launcher
lunar-launcher copied to clipboard
Open-Meteo weather provider
Checklist
- [X] I made sure that there are no existing issues - open or closed - which I could contribute my information to.
- [X] I have already checked the WIKI pages and made sure that the feature isn't already exist.
- [X] I have taken the time to fill in all the required details. I understand that the feature request will be dismissed otherwise.
- [X] This issue contains only one feature request.
Feature description
Hello, I would like to help implement the Open-Meteo API in the launcher, as it requires no API key (hence it's more user-friendly). I'm currently the only contributor to the open-meteo-api-kotlin library, and I haven't finished it, but I feel like to could benefit this project. Some "pseudo-code":
- Create an
Endpoint
withGeocodingSearch.context
- Use the geocoding search endpoint to find one matching place
- Get the first (and only) result coordinates (should be saved in the settings -> add ability to use coordinates only*)
- Create an
Endpoint
withForecast.context
- Call the endpoint with
Forecast.Query(latitude, longitude, currentWeather = true, /* units */)
- Get the response current weather:
-
response.currentWeather?.temperature
for the temperature -
response.currentWeather?.weatherCode?.message
for the printable message -
response.currentWeather?.weatherCode?.code
for the wmo int code (see at the end of the docs)
-
If you need the weather forecast, I would recommend to instead:
- Query using the invoke operator:
openMeteo(...)
-
ForecastHourly.Temperature2m
-
ForecastHourly.Weathercode
(convertible withWeatherCode.from(it)
)- Get a printable name (
message
) - Get a
Short
code to map icons (code
)
- Get a printable name (
-
ForecastDaily.Sunrise
andForecastDaily.Sunset
(convertible withTime(it)
)- To know if it's day or night (please note that I'm still working on
TimeZone
usage)
- To know if it's day or night (please note that I'm still working on
-
- Cache all the information needed and update every N hours
*Note: if GPS auto-location were to be implemented, it would be easy to update the coordinates (next version will have var
coordinates)
Additional information
A nice feature of the API is that it provides hourly/daily values up to a week, easing data caching. I'd like also to receive some inputs on how I could make the library more accessible to other developers (I know that the documentation and tests are completely missing in version 0.2.0-alpha, please have mercy), in order to ease the transaction to it.
What to input as location? Longitude-latitude or city name?
What to input as location? Longitude-latitude or city name?
Currently the client constructor accepts:
- City names as strings (defaulting to 0,0 coordinates)
- Coordinates pair (
coordinates: Pair<Float, Float>
) - latitude and longitude (both floats)
Okay, i'll try it. Thanks for the suggestion.
I did some testing and I realized the library is just overkill for the launcher (1+Â MB = too heavy): I'll work on a fork without implementing the library, but instead implementing the useful parts (protobuf isn't needed, as only one city name is retrieved).
You can open a pull request for a successful implementation, thanks.
if the app can some how get the Longitude-latitude via location and still be able to be on fdroid aka no play services that would be good then the weather could also auto update location
@The-Repo-Club I think, inputting location data manually is more privacy friendly.
ya having the option if wanting to would be nice though doesn't need to be on by default :)