From d17bf507d4adc922f4f213ae6e22344ccc746d4d Mon Sep 17 00:00:00 2001 From: timklge <2026103+timklge@users.noreply.github.com> Date: Sun, 23 Mar 2025 22:38:41 +0100 Subject: [PATCH] Update README sections describing OpenWeatherMap (#77) * Update README sections describing OpenWeatherMap * Use OpenMeteo without dash everywhere --- README.md | 12 +++++++---- app/.gitignore | 2 +- .../timklge/karooheadwind/HeadwindSettings.kt | 2 +- .../karooheadwind/OpenWeatherMapProvider.kt | 20 +++++++++---------- .../karooheadwind/screens/MainScreen.kt | 2 +- .../karooheadwind/screens/SettingsScreen.kt | 2 +- .../karooheadwind/screens/WeatherScreen.kt | 2 +- 7 files changed, 23 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 77c1649..5906be0 100644 --- a/README.md +++ b/README.md @@ -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. - 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. -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 can use OpenMeteo or OpenWeatherMap as providers for live weather data. -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 - 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 [openweathermap.org](https://openweathermap.org) +- Interfaces with [openweathermap.org](https://openweathermap.org) - Uses [karoo-ext](https://github.com/hammerheadnav/karoo-ext) (Apache2-licensed) ## Extension Developers: Headwind Data Type diff --git a/app/.gitignore b/app/.gitignore index e09316a..42afabf 100644 --- a/app/.gitignore +++ b/app/.gitignore @@ -1 +1 @@ -/build!/manifest.json +/build \ No newline at end of file diff --git a/app/src/main/kotlin/de/timklge/karooheadwind/HeadwindSettings.kt b/app/src/main/kotlin/de/timklge/karooheadwind/HeadwindSettings.kt index fd42d85..ea2a21a 100644 --- a/app/src/main/kotlin/de/timklge/karooheadwind/HeadwindSettings.kt +++ b/app/src/main/kotlin/de/timklge/karooheadwind/HeadwindSettings.kt @@ -90,6 +90,6 @@ data class HeadwindSettings( @Serializable 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") } \ No newline at end of file diff --git a/app/src/main/kotlin/de/timklge/karooheadwind/OpenWeatherMapProvider.kt b/app/src/main/kotlin/de/timklge/karooheadwind/OpenWeatherMapProvider.kt index 80dddfd..f0388ce 100644 --- a/app/src/main/kotlin/de/timklge/karooheadwind/OpenWeatherMapProvider.kt +++ b/app/src/main/kotlin/de/timklge/karooheadwind/OpenWeatherMapProvider.kt @@ -102,7 +102,7 @@ class OpenWeatherMapProvider(private val apiKey: String) : WeatherProvider { try { val responseBody = response.body?.let { String(it) } - ?: throw Exception("Respuesta nula de OpenWeatherMap") + ?: throw Exception("Null response from OpenWeatherMap") if (coordinates.size > 1) { @@ -188,14 +188,14 @@ class OpenWeatherMapProvider(private val apiKey: String) : WeatherProvider { } private fun convertWeatherCodeToOpenMeteo(owmCode: Int): Int { - // Mapping OpenWeatherMap a WMO OpenMeteo + // Mapping OpenWeatherMap to WMO OpenMeteo return when (owmCode) { - in 200..299 -> 95 // Tormentas - in 300..399 -> 51 // Llovizna - in 500..599 -> 61 // Lluvia - in 600..699 -> 71 // Nieve - 800 -> 0 // Despejado - in 801..804 -> 1 // Nubosidad + in 200..299 -> 95 // Thunderstorm + in 300..399 -> 51 // Drizzle + in 500..599 -> 61 // Rain + in 600..699 -> 71 // Snow + 800 -> 0 // Clear + in 801..804 -> 1 // Cloudy else -> 0 } } @@ -208,7 +208,7 @@ class OpenWeatherMapProvider(private val apiKey: String) : WeatherProvider { ): HttpResponseState.Complete { return callbackFlow { 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}" + "&appid=$apiKey&units=metric&exclude=minutely,daily,alerts" @@ -245,4 +245,4 @@ class OpenWeatherMapProvider(private val apiKey: String) : WeatherProvider { } }.single() } -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/de/timklge/karooheadwind/screens/MainScreen.kt b/app/src/main/kotlin/de/timklge/karooheadwind/screens/MainScreen.kt index f2bdd3a..6cc5383 100644 --- a/app/src/main/kotlin/de/timklge/karooheadwind/screens/MainScreen.kt +++ b/app/src/main/kotlin/de/timklge/karooheadwind/screens/MainScreen.kt @@ -139,7 +139,7 @@ fun MainScreen(close: () -> Unit) { 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.") } } ) diff --git a/app/src/main/kotlin/de/timklge/karooheadwind/screens/SettingsScreen.kt b/app/src/main/kotlin/de/timklge/karooheadwind/screens/SettingsScreen.kt index d584635..fe3c6b8 100644 --- a/app/src/main/kotlin/de/timklge/karooheadwind/screens/SettingsScreen.kt +++ b/app/src/main/kotlin/de/timklge/karooheadwind/screens/SettingsScreen.kt @@ -284,7 +284,7 @@ fun WeatherProviderSection( ) 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 ) } diff --git a/app/src/main/kotlin/de/timklge/karooheadwind/screens/WeatherScreen.kt b/app/src/main/kotlin/de/timklge/karooheadwind/screens/WeatherScreen.kt index 1515108..425c240 100644 --- a/app/src/main/kotlin/de/timklge/karooheadwind/screens/WeatherScreen.kt +++ b/app/src/main/kotlin/de/timklge/karooheadwind/screens/WeatherScreen.kt @@ -164,7 +164,7 @@ fun WeatherScreen(onFinish: () -> Unit) { ChronoUnit.SECONDS ) - val providerName = stats.lastSuccessfulWeatherProvider?.label ?: "Open-Meteo" + val providerName = stats.lastSuccessfulWeatherProvider?.label ?: "OpenMeteo" Text(