OpenWeatherMap condition icon

I have made a dirty fix to my original need, one-line forecast with icon. This does not include any day/night niceties.

Icons
As I previously used Yahoo weather in OH1, I chose to re-use the same icons. These can be found on the web and old OH1 tutorials.
So, in my conf/icons/classic/ folder I now have yweather-0.png, yweather-2.png, and so on. Don’t forget to provide a default yweather.png - perhaps a question mark, suitable for undefined.

Items
I assign two Items to be bound to the OpenWeatherMap channels for condition (long text) and condition-id (numeric) to get the forecast data that I’m interested in.
I have another Number item to accept the new combination.

String ForecastCondition "Forecast condition [%s]"  { channel="openweathermap:weather-and-forecast:api:local:forecastHours06#condition" }
String ForecastConditionID "Forecast condition ID [%s]"  { channel="openweathermap:weather-and-forecast:api:local:forecastHours06#condition-id" }
Number ForecastCombo "Forecast" <yweather>

Now for a magic part. I use a SCALE transformation to convert OWM condition ID codes into Yahoo compatible codes. This file ges into conf/transform

owm.scale

#thunderstorm
[200..232]=3
#drizzle
[300..321]=9
#rain
[500..504]=9
#freezing rain
[..511]=10
#showers
[520..521]=11
#snow
[600..602]=16
#sleet
[611..616]=18
#flurries
[620..622]=13
#foggy
[701..762]=20
#tornado
[771..781]=0
#clear
[..800]=32
#light cloud
[..801]=30
#broken cloud
[802..803]=28
#overcast
[803..804]=26

A rule is needed to make at all happen, converting OWM ID to a Yahoo number, and updating the combo item with the long text description

rule "Weather summary"
when
	System started or
	Item ForecastConditionID changed
then
	if (ForecastConditionID.state == NULL || ForecastConditionID.state == UNDEF) {
		ForecastCombo.label = "Awaiting forecast"
		ForecastCombo.postUpdate(NULL)
	} else {
		val id = transform("SCALE", "owm.scale", ForecastConditionID.state.toString)
		ForecastCombo.label = "6hr Forecast - " + ForecastCondition.state  // description
		ForecastCombo.postUpdate(id) // numeric for icon
	}
end

And at last, ready for a sitemap entry

	Text item=ForecastCombo

weathercombo

3 Likes