Update README sections describing OpenWeatherMap (#77)

* Update README sections describing OpenWeatherMap

* Use OpenMeteo without dash everywhere
This commit is contained in:
timklge 2025-03-23 22:38:41 +01:00 committed by GitHub
parent 973bed718f
commit d17bf507d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 23 additions and 19 deletions

View File

@ -42,16 +42,20 @@ After installing this app on your Karoo and opening it once from the main menu,
- Current weather (graphical, 1x1 field): Shows current weather conditions (same as forecast widget, but only for the current time). Tap on this widget to open the headwind app with a forecast overview. - Current weather (graphical, 1x1 field): Shows current weather conditions (same as forecast widget, but only for the current time). Tap on this widget to open the headwind app with a forecast overview.
- Additionally, data fields that only show the current data value for headwind speed, humidity, cloud cover, absolute wind speed, absolute wind gust speed, absolute wind direction, rainfall and surface pressure can be added if desired. - Additionally, data fields that only show the current data value for headwind speed, humidity, cloud cover, absolute wind speed, absolute wind gust speed, absolute wind direction, rainfall and surface pressure can be added if desired.
This app can use open-meteo service or openweathermap. Use the correct one for your zone, open-meteo is easier to use because you cannot need to introduce an API key. Openweather need to have an API from Openweathermap, it's free for personal use and you don't need to pay for it, but you need to register in https://openweathermap.org/home/sign_in and get the one call API key. The app can use OpenMeteo or OpenWeatherMap as providers for live weather data.
Openweathermap has more local stations and is more accurate than open-meteo for current weather (but it depends of the location).) If you use openweathermap without a correct key, this app will fallback to open-meteo.
The app will automatically attempt to download weather data for your current approximate location API once your device has acquired a GPS fix. The API service is free for non-commercial use. Your location is rounded to approximately two kilometers to maintain privacy. The data is updated when you ride more than two kilometers from the location where the weather data was downloaded or after one hour at the latest. If the app cannot connect to the weather service, it will retry the download every minute. Downloading weather data should work on Karoo 2 if you have a SIM card inserted or on Karoo 3 via your phone's internet connection if you have the Karoo companion app installed. - OpenMeteo is the default provider and does not require any configuration.
- OpenWeatherMap can provide more accurate data for some locations. Forecasts along the loaded route are not available using OpenWeatherMap. OpenWeatherMap is free for personal use, but you need to register at https://openweathermap.org/home/sign_in and obtain a one call API key. If you use OpenWeatherMap without a correct key, the app will fall back to OpenMeteo.
The app will automatically attempt to download weather data from the selected data provider once your device has acquired a GPS fix. Your location is rounded to approximately three kilometers to maintain privacy.
New weather data is downloaded when you ride more than three kilometers from the location where the weather data was downloaded for or after one hour at the latest.
If the app cannot connect to the weather service, it will retry the download every minute. Downloading weather data should work on Karoo 2 if you have a SIM card inserted or on Karoo 3 via your phone's internet connection if you have the Karoo companion app installed.
## Credits ## Credits
- Icons are from [boxicons.com](https://boxicons.com) ([MIT-licensed](icon_credits.txt)) - Icons are from [boxicons.com](https://boxicons.com) ([MIT-licensed](icon_credits.txt))
- Made possible by the generous usage terms of [open-meteo.com](https://open-meteo.com) - Made possible by the generous usage terms of [open-meteo.com](https://open-meteo.com)
- Made possible by the generous usage terms of [openweathermap.org](https://openweathermap.org) - Interfaces with [openweathermap.org](https://openweathermap.org)
- Uses [karoo-ext](https://github.com/hammerheadnav/karoo-ext) (Apache2-licensed) - Uses [karoo-ext](https://github.com/hammerheadnav/karoo-ext) (Apache2-licensed)
## Extension Developers: Headwind Data Type ## Extension Developers: Headwind Data Type

2
app/.gitignore vendored
View File

@ -1 +1 @@
/build!/manifest.json /build

View File

@ -90,6 +90,6 @@ data class HeadwindSettings(
@Serializable @Serializable
enum class WeatherDataProvider(val id: String, val label: String) { enum class WeatherDataProvider(val id: String, val label: String) {
OPEN_METEO("open-meteo", "Open-Meteo"), OPEN_METEO("open-meteo", "OpenMeteo"),
OPEN_WEATHER_MAP("open-weather-map", "OpenWeatherMap") OPEN_WEATHER_MAP("open-weather-map", "OpenWeatherMap")
} }

View File

@ -102,7 +102,7 @@ class OpenWeatherMapProvider(private val apiKey: String) : WeatherProvider {
try { try {
val responseBody = response.body?.let { String(it) } val responseBody = response.body?.let { String(it) }
?: throw Exception("Respuesta nula de OpenWeatherMap") ?: throw Exception("Null response from OpenWeatherMap")
if (coordinates.size > 1) { if (coordinates.size > 1) {
@ -188,14 +188,14 @@ class OpenWeatherMapProvider(private val apiKey: String) : WeatherProvider {
} }
private fun convertWeatherCodeToOpenMeteo(owmCode: Int): Int { private fun convertWeatherCodeToOpenMeteo(owmCode: Int): Int {
// Mapping OpenWeatherMap a WMO OpenMeteo // Mapping OpenWeatherMap to WMO OpenMeteo
return when (owmCode) { return when (owmCode) {
in 200..299 -> 95 // Tormentas in 200..299 -> 95 // Thunderstorm
in 300..399 -> 51 // Llovizna in 300..399 -> 51 // Drizzle
in 500..599 -> 61 // Lluvia in 500..599 -> 61 // Rain
in 600..699 -> 71 // Nieve in 600..699 -> 71 // Snow
800 -> 0 // Despejado 800 -> 0 // Clear
in 801..804 -> 1 // Nubosidad in 801..804 -> 1 // Cloudy
else -> 0 else -> 0
} }
} }
@ -208,7 +208,7 @@ class OpenWeatherMapProvider(private val apiKey: String) : WeatherProvider {
): HttpResponseState.Complete { ): HttpResponseState.Complete {
return callbackFlow { return callbackFlow {
val coordinate = coordinates.first() val coordinate = coordinates.first()
// URL API 3.0 con endpoint onecall // URL API 3.0 with onecall endpoint
val url = "https://api.openweathermap.org/data/3.0/onecall?lat=${coordinate.lat}&lon=${coordinate.lon}" + val url = "https://api.openweathermap.org/data/3.0/onecall?lat=${coordinate.lat}&lon=${coordinate.lon}" +
"&appid=$apiKey&units=metric&exclude=minutely,daily,alerts" "&appid=$apiKey&units=metric&exclude=minutely,daily,alerts"

View File

@ -139,7 +139,7 @@ fun MainScreen(close: () -> Unit) {
Spacer(Modifier.padding(10.dp)) Spacer(Modifier.padding(10.dp))
Text("Please note that this app periodically fetches data from the Open-Meteo API to know the current weather at your approximate location.") Text("Please note that this app periodically fetches data from the OpenMeteo API to know the current weather at your approximate location.")
} }
} }
) )

View File

@ -284,7 +284,7 @@ fun WeatherProviderSection(
) )
Text( Text(
text = "If you want to use OpenWeatherMap, you need to provide an API key. If you don't provide any correct, you'll get OpenMeteo weather data.", text = "If you want to use OpenWeatherMap, you need to provide an API key. If you don't provide a correct key, OpenMeteo is used as a fallback.",
style = MaterialTheme.typography.bodySmall style = MaterialTheme.typography.bodySmall
) )
} }

View File

@ -164,7 +164,7 @@ fun WeatherScreen(onFinish: () -> Unit) {
ChronoUnit.SECONDS ChronoUnit.SECONDS
) )
val providerName = stats.lastSuccessfulWeatherProvider?.label ?: "Open-Meteo" val providerName = stats.lastSuccessfulWeatherProvider?.label ?: "OpenMeteo"
Text( Text(