From 29fb142e6a52afd42082808438468ebb71d70dc5 Mon Sep 17 00:00:00 2001 From: Anders Alfredsson <30875102+pacive@users.noreply.github.com> Date: Mon, 22 Aug 2022 10:47:44 +0200 Subject: [PATCH] [smhi] Prepare for easier translation (#13305) Signed-off-by: Anders Alfredsson --- bundles/org.openhab.binding.smhi/README.md | 146 +++++++++--------- .../binding/smhi/internal/SmhiHandler.java | 2 +- .../OH-INF/config/forecast-config.xml | 70 ++++----- .../resources/OH-INF/i18n/smhi.properties | 37 +---- 4 files changed, 111 insertions(+), 144 deletions(-) diff --git a/bundles/org.openhab.binding.smhi/README.md b/bundles/org.openhab.binding.smhi/README.md index 881843566..64771eee9 100644 --- a/bundles/org.openhab.binding.smhi/README.md +++ b/bundles/org.openhab.binding.smhi/README.md @@ -18,12 +18,12 @@ This binding does not support automatic discovery. The forecast thing needs to be configured with the latitude and longitude for the location of the forecast. You can also choose for which hours and which days you would like to get forecasts. -| Parameter | Description | Required | -|-----------|-------------|----------| -| Latitude | Latitude of the forecast | Yes | -| Longitute | Longitude of the forecast | Yes | -| Hourly forecasts | The hourly forecasts to display | No | -| Daily forecasts | The daily forecasts to display | No | +| Parameter | Description | Required | +|------------------|---------------------------------|----------| +| Latitude | Latitude of the forecast | Yes | +| Longitude | Longitude of the forecast | Yes | +| Hourly forecasts | The hourly forecasts to display | No | +| Daily forecasts | The daily forecasts to display | No | ## Channels @@ -40,81 +40,81 @@ Examples: #### Basic channels -| channel | type | channel id | description | -|----------|--------|------------|------------------------------| -| Temperature | Number:Temperature | t | Temperature in Celsius | -| Max Temperature | Number:Temperature | tmax | Highest temperature of the day (daily forecast only) | -| Min Temperature | Number:Temperature | tmin | Lowest temperature of the day (daily forecast only) | -| Wind direction | Number:Angle | wd | Wind direction in degrees | -| Wind Speed | Number:Speed | ws | Wind speed in m/s | -| Max Wind Speed | Number:Speed | wsmax | Highest wind speed of the day (daily forecast only) | -| Min Wind Speed | Number:Speed | wsmin | Lowest wind speed of the day (daily forecast only) | -| Wind gust speed | Number:Speed | gust | Wind gust speed in m/s | -| Minimum precipitation | Number:Speed | pmin | Minimum precipitation intensity in mm/h | -| Maximum precipitation | Number:Speed | pmax | Maximum precipitation intensity in mm/h | -| Total precipitation | Number:Length | ptotal | Total amount of precipitation during the day, in mm (daily forecast only) | -| Precipitation category* | Number | pcat | Type of precipitation | -| Air pressure | Number:Pressure | msl | Air pressure in hPa | -| Relative humidity | Number:Dimensionless | r | Relative humidity in percent | -| Total cloud cover | Number:Dimensionless | tcc_mean | Mean value of total cloud cover in percent | -| Weather condition** | Number | wsymb2 | Short description of the weather conditions | +| channel | type | channel id | description | +|-------------------------|----------------------|------------|---------------------------------------------------------------------------| +| Temperature | Number:Temperature | t | Temperature in Celsius | +| Max Temperature | Number:Temperature | tmax | Highest temperature of the day (daily forecast only) | +| Min Temperature | Number:Temperature | tmin | Lowest temperature of the day (daily forecast only) | +| Wind direction | Number:Angle | wd | Wind direction in degrees | +| Wind Speed | Number:Speed | ws | Wind speed in m/s | +| Max Wind Speed | Number:Speed | wsmax | Highest wind speed of the day (daily forecast only) | +| Min Wind Speed | Number:Speed | wsmin | Lowest wind speed of the day (daily forecast only) | +| Wind gust speed | Number:Speed | gust | Wind gust speed in m/s | +| Minimum precipitation | Number:Speed | pmin | Minimum precipitation intensity in mm/h | +| Maximum precipitation | Number:Speed | pmax | Maximum precipitation intensity in mm/h | +| Total precipitation | Number:Length | ptotal | Total amount of precipitation during the day, in mm (daily forecast only) | +| Precipitation category* | Number | pcat | Type of precipitation | +| Air pressure | Number:Pressure | msl | Air pressure in hPa | +| Relative humidity | Number:Dimensionless | r | Relative humidity in percent | +| Total cloud cover | Number:Dimensionless | tcc_mean | Mean value of total cloud cover in percent | +| Weather condition** | Number | wsymb2 | Short description of the weather conditions | #### Advanced channels -| channel | type | channel id | description | -|----------|--------|------------|------------------------------| -| Visibility | Number:Length | vis | Horizontal visibility in km | -| Thunder probability | Number:Dimensionless | tstm | Probability of thunder in percent | -| Frozen precipitation | Number:Dimensionless | spp | Percent of precipitation in frozen form (will be set to UNDEF if there's no precipitation) | -| Low level cloud cover | Number:Dimensionless | lcc_mean | Mean value of low level cloud cover (0-2500 m) in percent | -| Medium level cloud cover | Number:Dimensionless | mcc_mean | Mean value of medium level cloud cover (2500-6000 m) in percent | -| High level cloud cover | Number:Dimensionless | hcc_mean | Mean value of high level cloud cover (> 6000 m) in percent | -| Mean precipitation | Number:Speed | pmean | Mean precipitation intensity in mm/h | -| Median precipitation | Number:Speed | pmedian | Median precipitation intensity in mm/h | +| channel | type | channel id | description | +|--------------------------|----------------------|------------|--------------------------------------------------------------------------------------------| +| Visibility | Number:Length | vis | Horizontal visibility in km | +| Thunder probability | Number:Dimensionless | tstm | Probability of thunder in percent | +| Frozen precipitation | Number:Dimensionless | spp | Percent of precipitation in frozen form (will be set to UNDEF if there's no precipitation) | +| Low level cloud cover | Number:Dimensionless | lcc_mean | Mean value of low level cloud cover (0-2500 m) in percent | +| Medium level cloud cover | Number:Dimensionless | mcc_mean | Mean value of medium level cloud cover (2500-6000 m) in percent | +| High level cloud cover | Number:Dimensionless | hcc_mean | Mean value of high level cloud cover (> 6000 m) in percent | +| Mean precipitation | Number:Speed | pmean | Mean precipitation intensity in mm/h | +| Median precipitation | Number:Speed | pmedian | Median precipitation intensity in mm/h | -\* The precipitation category can have a value from 0-6, representing different types of precipitaion: +\* The precipitation category can have a value from 0-6, representing different types of precipitation: -| Value | Meaning | -|-------|---------| -| 0 | No precipitation| -| 1 | Snow | -| 2 | Snow and rain | -| 3 | Rain | -| 4 | Drizzle | -| 5 | Freezing rain | -| 6 | Freezing drizzle | +| Value | Meaning | +|-------|------------------| +| 0 | No precipitation | +| 1 | Snow | +| 2 | Snow and rain | +| 3 | Rain | +| 4 | Drizzle | +| 5 | Freezing rain | +| 6 | Freezing drizzle | \** The weather condition channel can take values from 1-27, each corresponding to a different weather condition: -| Value | Condition | -|-------|-----------| -| 1 | Clear sky | -| 2 | Nearly clear sky | -| 3 | Variable cloudiness | -| 4 | Halfclear sky | -| 5 | Cloudy sky | -| 6 | Overcast | -| 7 | Fog | -| 8 | Light rain showers | -| 9 | Moderate rain showers | -| 10 | Heavy rain showers | -| 11 | Thunderstorm | -| 12 | Light sleet showers | -| 13 | Moderate sleet showers | -| 14 | Heavy sleet showers | -| 15 | Light snow showers | -| 16 | Moderate snow showers | -| 17 | Heavy snow showers | -| 18 | Light rain | -| 19 | Moderate rain | -| 20 | Heavy rain | -| 21 | Thunder | -| 22 | Light sleet | -| 23 | Moderate sleet | -| 24 | Heavy sleet | -| 25 | Light snowfall | -| 26 | Moderate snowfall | -| 27 | Heavy snowfall | +| Value | Condition | +|-------|------------------------| +| 1 | Clear sky | +| 2 | Nearly clear sky | +| 3 | Variable cloudiness | +| 4 | Half clear sky | +| 5 | Cloudy sky | +| 6 | Overcast | +| 7 | Fog | +| 8 | Light rain showers | +| 9 | Moderate rain showers | +| 10 | Heavy rain showers | +| 11 | Thunderstorm | +| 12 | Light sleet showers | +| 13 | Moderate sleet showers | +| 14 | Heavy sleet showers | +| 15 | Light snow showers | +| 16 | Moderate snow showers | +| 17 | Heavy snow showers | +| 18 | Light rain | +| 19 | Moderate rain | +| 20 | Heavy rain | +| 21 | Thunder | +| 22 | Light sleet | +| 23 | Moderate sleet | +| 24 | Heavy sleet | +| 25 | Light snowfall | +| 26 | Moderate snowfall | +| 27 | Heavy snowfall | ## Full Example diff --git a/bundles/org.openhab.binding.smhi/src/main/java/org/openhab/binding/smhi/internal/SmhiHandler.java b/bundles/org.openhab.binding.smhi/src/main/java/org/openhab/binding/smhi/internal/SmhiHandler.java index 2b494a63a..7189012ff 100644 --- a/bundles/org.openhab.binding.smhi/src/main/java/org/openhab/binding/smhi/internal/SmhiHandler.java +++ b/bundles/org.openhab.binding.smhi/src/main/java/org/openhab/binding/smhi/internal/SmhiHandler.java @@ -317,7 +317,7 @@ public class SmhiHandler extends BaseThingHandler { return; } catch (PointOutOfBoundsException e) { updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, - "Coordinates outside valid area"); + "@text/thing-status.invalidCoordinates"); cancelPolling(); return; } diff --git a/bundles/org.openhab.binding.smhi/src/main/resources/OH-INF/config/forecast-config.xml b/bundles/org.openhab.binding.smhi/src/main/resources/OH-INF/config/forecast-config.xml index 3a5df9736..51c6bee50 100644 --- a/bundles/org.openhab.binding.smhi/src/main/resources/OH-INF/config/forecast-config.xml +++ b/bundles/org.openhab.binding.smhi/src/main/resources/OH-INF/config/forecast-config.xml @@ -19,31 +19,31 @@ The hourly forecasts to display true - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + @@ -51,16 +51,16 @@ The daily forecasts to display true - - - - - - - - - - + + + + + + + + + + diff --git a/bundles/org.openhab.binding.smhi/src/main/resources/OH-INF/i18n/smhi.properties b/bundles/org.openhab.binding.smhi/src/main/resources/OH-INF/i18n/smhi.properties index 31439a690..9efd510b6 100644 --- a/bundles/org.openhab.binding.smhi/src/main/resources/OH-INF/i18n/smhi.properties +++ b/bundles/org.openhab.binding.smhi/src/main/resources/OH-INF/i18n/smhi.properties @@ -82,43 +82,8 @@ thing-type.smhi.forecast.group.hour_9.description = Forecast for 9 hours from no thing-type.config.smhi.forecast.dailyForecasts.label = Daily Forecasts thing-type.config.smhi.forecast.dailyForecasts.description = The daily forecasts to display -thing-type.config.smhi.forecast.dailyForecasts.option.0 = Today -thing-type.config.smhi.forecast.dailyForecasts.option.1 = Tomorrow -thing-type.config.smhi.forecast.dailyForecasts.option.2 = 2 days from now -thing-type.config.smhi.forecast.dailyForecasts.option.3 = 3 days from now -thing-type.config.smhi.forecast.dailyForecasts.option.4 = 4 days from now -thing-type.config.smhi.forecast.dailyForecasts.option.5 = 5 days from now -thing-type.config.smhi.forecast.dailyForecasts.option.6 = 6 days from now -thing-type.config.smhi.forecast.dailyForecasts.option.7 = 7 days from now -thing-type.config.smhi.forecast.dailyForecasts.option.8 = 8 days from now -thing-type.config.smhi.forecast.dailyForecasts.option.9 = 9 days from now thing-type.config.smhi.forecast.hourlyForecasts.label = Hourly Forecasts thing-type.config.smhi.forecast.hourlyForecasts.description = The hourly forecasts to display -thing-type.config.smhi.forecast.hourlyForecasts.option.0 = Current hour -thing-type.config.smhi.forecast.hourlyForecasts.option.1 = Next hour -thing-type.config.smhi.forecast.hourlyForecasts.option.2 = 2 hours from now -thing-type.config.smhi.forecast.hourlyForecasts.option.3 = 3 hours from now -thing-type.config.smhi.forecast.hourlyForecasts.option.4 = 4 hours from now -thing-type.config.smhi.forecast.hourlyForecasts.option.5 = 5 hours from now -thing-type.config.smhi.forecast.hourlyForecasts.option.6 = 6 hours from now -thing-type.config.smhi.forecast.hourlyForecasts.option.7 = 7 hours from now -thing-type.config.smhi.forecast.hourlyForecasts.option.8 = 8 hours from now -thing-type.config.smhi.forecast.hourlyForecasts.option.9 = 9 hours from now -thing-type.config.smhi.forecast.hourlyForecasts.option.10 = 10 hours from now -thing-type.config.smhi.forecast.hourlyForecasts.option.11 = 11 hours from now -thing-type.config.smhi.forecast.hourlyForecasts.option.12 = 12 hours from now -thing-type.config.smhi.forecast.hourlyForecasts.option.13 = 13 hours from now -thing-type.config.smhi.forecast.hourlyForecasts.option.14 = 14 hours from now -thing-type.config.smhi.forecast.hourlyForecasts.option.15 = 15 hours from now -thing-type.config.smhi.forecast.hourlyForecasts.option.16 = 16 hours from now -thing-type.config.smhi.forecast.hourlyForecasts.option.17 = 17 hours from now -thing-type.config.smhi.forecast.hourlyForecasts.option.18 = 18 hours from now -thing-type.config.smhi.forecast.hourlyForecasts.option.19 = 19 hours from now -thing-type.config.smhi.forecast.hourlyForecasts.option.20 = 20 hours from now -thing-type.config.smhi.forecast.hourlyForecasts.option.21 = 21 hours from now -thing-type.config.smhi.forecast.hourlyForecasts.option.22 = 22 hours from now -thing-type.config.smhi.forecast.hourlyForecasts.option.23 = 23 hours from now -thing-type.config.smhi.forecast.hourlyForecasts.option.24 = 24 hours from now thing-type.config.smhi.forecast.latitude.label = Latitude thing-type.config.smhi.forecast.latitude.description = Latitude for the forecast thing-type.config.smhi.forecast.longitude.label = Longitude @@ -215,3 +180,5 @@ channel-type.smhi.wsymb2.state.option.24 = Heavy sleet channel-type.smhi.wsymb2.state.option.25 = Light snowfall channel-type.smhi.wsymb2.state.option.26 = Moderate snowfall channel-type.smhi.wsymb2.state.option.27 = Heavy snowfall + +thing-status.invalidCoordinates = Coordinates outside valid area