OpenWeatherMap daily forecasts with free API using plain OpenHAB rules

Here you are:

  1. openweathermap.items.txt (118.5 KB) → please save as $OPENHAB_CONF/items/openweathermap.items after downloading
  2. openweathermap.rules.txt (21.1 KB) → please save as $OPENHAB_CONF/rules/openweathermap.rules after downloading

As a bonus you’ll see that I now also generate range items that will display the minimum and maximum values in one go (instead of showing them separately), as with:

String Wx_OWM_Forecast_Temperature_Range_Day0 "Temperature [%s]" <temperature>

I use a rule to compute the state (value) of that Item. The only drawback is that you lose UoM conversion capabilities (e.g. wind speed in my locale is expressed in m/s while most of us are more familiarised with wind speeds in km/h (basically multiplying the values by 3.6 and changing the unit). So my sitemap will properly render min and max wind speeds in km/h but my rule hack will express the values in m/s (with 2-digit precision - something else I can’t easily change in rules).

FWIW I don’t think OpenHAB today allows multiple Number UoM values displayed in one Item while using UoM conversion. It would be great if OpenHAB would allow the following Item definitions:

Number:Speed	Wx_OWM_Forecast_Wind_Speed_Range_Day0 "Wind Speed [$1%.0f km/h - $2%.0f km/h]" <wind>	(gWeatherForecastDaily)

effectively referring to 2 Number:Speed values rendered as "[%.0f km/h - %.0f km/h]". But that’s a different story. Back to my OWM daily forecast compilation. Now comes the visualisation part.

In your sitemap:

sitemap home label="Our Home" icon="home" {

	Frame label="Weather" icon="temperature" {
	
		Text item=Wx_OWM_Current_Observation_Time label="Current weather [%1$tA, %1$tb %1$td, %1$tY]" icon="sun_clouds" {
			// Text item=Today label="[%1$tA, %1$tb %1$td, %1$tY]" icon="calendar"
			Frame label="Calendar" icon="calendar" {
				Text item=Wx_OWM_Current_Observation_Time label="Observation for [%1$tA, %1$tb %1$td]" icon="calendar"
				Text item=Wx_OWM_Current_Observation_Time label="Observation at [%1tH:%1$tm]" icon="time"
				Default item=Wx_OWM_Current_Station_Name
				Default item=Wx_OWM_Current_Station_Id
			}

			Frame label="Current weather" icon="sun_clouds" {

				Default item=Wx_OWM_Current_Temperature  label="Temperature [%.1f %unit%]"   valuecolor=[
					>=30="red", >=25="orange", >=15="green", 0="silver", <0="purple", <15="blue"
				]
				Default item=Wx_OWM_Current_Cloudiness
				Default item=Wx_OWM_Current_Humidity			icon="humidity"		label="Humidity [%d %unit%]"
				Default item=Wx_OWM_Current_Pressure
				Default item=Wx_OWM_Current_Wind_Speed			icon="wind"			label="Windspeed [%.0f km/h]"
				Default item=Wx_OWM_Current_Wind_Direction
				Default item=Wx_OWM_Current_Wind_Direction_Simplified
				Default item=Wx_OWM_Current_Rain									label="Rain"
				Default item=Wx_OWM_Current_Snow									label="Snow"
				Default item=Wx_OWM_Current_Condition			icon="sun_clouds"	label="Condition [%s]"
				// Default item=Wx_OWM_Current_Condition_Formatted
				Default item=Wx_OWM_Current_ConditionIcon							label="Icon [%s]"
				Default item=Wx_OWM_Current_ConditionId		icon="settings"		label="Condition ID [%s]"
				// Default item=Wx_OWM_Current_Condition_Img_URL label="Current condition (new image)"
			}
		}

		// If you persist the group "gWeatherCurrent" and use influxdb persistency, then you can generate the following weekly graphs:
		Text label="Graphs [OpenHAB]" icon="chart" {
			Text label="Temperature [°C]"		icon="temperature"
			Chart item=Wx_OWM_Current_Temperature		service="influxdb"	period=W	refresh=500000
			//
			Text label="Wind speed [m/s]"		icon="wind"
			Chart item=Wx_OWM_Current_Wind_Speed		service="influxdb"	period=W	refresh=500000
			//
			Text label="Humidity [%]"		icon="humidity"
			Chart item=Wx_OWM_Current_Humidity			service="influxdb"	period=W	refresh=500000
			//
			Text label="Coud cover [%]"		icon="sun_clouds"
			Chart item=Wx_OWM_Current_Cloudiness		service="influxdb"	period=W	refresh=500000
			//
			Text label="Pressure [mBar]" icon="pressure"
			Chart item=Wx_OWM_Current_Pressure			service="influxdb"	period=W	refresh=500000
			//
			Text label="Rain [mm]" icon="rain"
			Chart item=Wx_OWM_Current_Rain				service="influxdb"	period=W	refresh=500000
			//
			Text label="Snow [mm]" icon="snow"
			Chart item=Wx_OWM_Current_Snow				service="influxdb"	period=W	refresh=500000
			//
		}

		Text item=Wx_OWM_Forecast_Time_96h label="Forecast (4 days) [until %1$tA]" icon="sun_clouds" {
			Frame item=Wx_OWM_Current_Observation_Time label="Today [%1$tA, %1$tb %1$td]" icon="calendar" visibility=[Wx_OWM_Forecast_Day_Offset==ON]  {
				Text label="Warning: OWM Forecast Day Offset is TRUE, not enough forecast data for today" icon="error" // visibility=[Wx_OWM_Forecast_Day_Offset==ON]
			}
			Frame item=Wx_OWM_Current_Observation_Time label="Today [%1$tA, %1$tb %1$td]" icon="calendar" visibility=[Wx_OWM_Forecast_Day_Offset==OFF]  {
				// Text label="OWM Forecast Day Offset is FALSE, enough forecast data for today" icon="settings" // visibility=[Wx_OWM_Forecast_Day_Offset==OFF]
				Default item=Wx_OWM_Forecast_Temperature_Range_Day0
				Default item=Wx_OWM_Forecast_Temperature_Min_Day0  valuecolor=[
					>=30="red", >=25="orange", >=15="green", 0="silver", <0="purple", <15="blue"
				]
				Default item=Wx_OWM_Forecast_Temperature_Max_Day0  valuecolor=[
					>=30="red", >=25="orange", >=15="green", 0="silver", <0="purple", <15="blue"
				]

				Default item=Wx_OWM_Forecast_Rain_Day0

				Default item=Wx_OWM_Forecast_Snow_Day0

				Default item=Wx_OWM_Forecast_Humidity_Range_Day0
				Default item=Wx_OWM_Forecast_Humidity_Min_Day0
				Default item=Wx_OWM_Forecast_Humidity_Max_Day0

				Default item=Wx_OWM_Forecast_Pressure_Range_Day0
				Default item=Wx_OWM_Forecast_Pressure_Min_Day0
				Default item=Wx_OWM_Forecast_Pressure_Max_Day0

				Default item=Wx_OWM_Forecast_Cloudiness_Range_Day0
				Default item=Wx_OWM_Forecast_Cloudiness_Min_Day0
				Default item=Wx_OWM_Forecast_Cloudiness_Max_Day0

				Default item=Wx_OWM_Forecast_Wind_Speed_Range_Day0
				Default item=Wx_OWM_Forecast_Wind_Speed_Min_Day0
				Default item=Wx_OWM_Forecast_Wind_Speed_Max_Day0
			}
			
			Frame item=Wx_OWM_Forecast_Time_24h label="Tomorrow [%1$tA, %1$tb %1$td]" icon="calendar" {
				Default item=Wx_OWM_Forecast_Temperature_Min_Day1  valuecolor=[
					>=30="red", >=25="orange", >=15="green", 0="silver", <0="purple", <15="blue"
				]
				Default item=Wx_OWM_Forecast_Temperature_Max_Day1  valuecolor=[
					>=30="red", >=25="orange", >=15="green", 0="silver", <0="purple", <15="blue"
				]
				Default item=Wx_OWM_Forecast_Temperature_Range_Day1

				Default item=Wx_OWM_Forecast_Rain_Day1

				Default item=Wx_OWM_Forecast_Snow_Day1

				Default item=Wx_OWM_Forecast_Humidity_Range_Day1
				Default item=Wx_OWM_Forecast_Humidity_Min_Day1
				Default item=Wx_OWM_Forecast_Humidity_Max_Day1

				Default item=Wx_OWM_Forecast_Pressure_Range_Day1
				Default item=Wx_OWM_Forecast_Pressure_Min_Day1
				Default item=Wx_OWM_Forecast_Pressure_Max_Day1

				Default item=Wx_OWM_Forecast_Cloudiness_Range_Day1
				Default item=Wx_OWM_Forecast_Cloudiness_Min_Day1
				Default item=Wx_OWM_Forecast_Cloudiness_Max_Day1

				Default item=Wx_OWM_Forecast_Wind_Speed_Range_Day1
				Default item=Wx_OWM_Forecast_Wind_Speed_Min_Day1
				Default item=Wx_OWM_Forecast_Wind_Speed_Max_Day1
			}

			Frame item=Wx_OWM_Forecast_Time_48h label="In 2 days [%1$tA, %1$tb %1$td]" icon="calendar" {
				Default item=Wx_OWM_Forecast_Temperature_Min_Day2  valuecolor=[
					>=30="red", >=25="orange", >=15="green", 0="silver", <0="purple", <15="blue"
				]
				Default item=Wx_OWM_Forecast_Temperature_Max_Day2  valuecolor=[
					>=30="red", >=25="orange", >=15="green", 0="silver", <0="purple", <15="blue"
				]
				Default item=Wx_OWM_Forecast_Temperature_Range_Day2

				Default item=Wx_OWM_Forecast_Rain_Day2

				Default item=Wx_OWM_Forecast_Snow_Day2

				Default item=Wx_OWM_Forecast_Humidity_Range_Day2
				Default item=Wx_OWM_Forecast_Humidity_Min_Day2
				Default item=Wx_OWM_Forecast_Humidity_Max_Day2

				Default item=Wx_OWM_Forecast_Pressure_Range_Day2
				Default item=Wx_OWM_Forecast_Pressure_Min_Day2
				Default item=Wx_OWM_Forecast_Pressure_Max_Day2

				Default item=Wx_OWM_Forecast_Cloudiness_Range_Day2
				Default item=Wx_OWM_Forecast_Cloudiness_Min_Day2
				Default item=Wx_OWM_Forecast_Cloudiness_Max_Day2

				Default item=Wx_OWM_Forecast_Wind_Speed_Range_Day2
				Default item=Wx_OWM_Forecast_Wind_Speed_Min_Day2
				Default item=Wx_OWM_Forecast_Wind_Speed_Max_Day2
			}

			Frame item=Wx_OWM_Forecast_Time_72h label="In 3 days [%1$tA, %1$tb %1$td]" icon="calendar" {
				Default item=Wx_OWM_Forecast_Temperature_Range_Day3
				Default item=Wx_OWM_Forecast_Temperature_Min_Day3  valuecolor=[
					>=30="red", >=25="orange", >=15="green", 0="silver", <0="purple", <15="blue"
				]
				Default item=Wx_OWM_Forecast_Temperature_Max_Day3  valuecolor=[
					>=30="red", >=25="orange", >=15="green", 0="silver", <0="purple", <15="blue"
				]
				Default item=Wx_OWM_Forecast_Rain_Day3

				Default item=Wx_OWM_Forecast_Snow_Day3

				Default item=Wx_OWM_Forecast_Humidity_Range_Day3
				Default item=Wx_OWM_Forecast_Humidity_Min_Day3
				Default item=Wx_OWM_Forecast_Humidity_Max_Day3

				Default item=Wx_OWM_Forecast_Pressure_Range_Day3
				Default item=Wx_OWM_Forecast_Pressure_Min_Day3
				Default item=Wx_OWM_Forecast_Pressure_Max_Day3

				Default item=Wx_OWM_Forecast_Cloudiness_Range_Day3
				Default item=Wx_OWM_Forecast_Cloudiness_Min_Day3
				Default item=Wx_OWM_Forecast_Cloudiness_Max_Day3

				Default item=Wx_OWM_Forecast_Wind_Speed_Range_Day3
				Default item=Wx_OWM_Forecast_Wind_Speed_Min_Day3
				Default item=Wx_OWM_Forecast_Wind_Speed_Max_Day3
			}

			Frame item=Wx_OWM_Forecast_Time_96h label="In 4 days [%1$tA, %1$tb %1$td]" icon="calendar" {
				Default item=Wx_OWM_Forecast_Temperature_Range_Day4
				Default item=Wx_OWM_Forecast_Temperature_Min_Day4  valuecolor=[
					>=30="red", >=25="orange", >=15="green", 0="silver", <0="purple", <15="blue"
				]
				Default item=Wx_OWM_Forecast_Temperature_Max_Day4  valuecolor=[
					>=30="red", >=25="orange", >=15="green", 0="silver", <0="purple", <15="blue"
				]

				Default item=Wx_OWM_Forecast_Rain_Day4

				Default item=Wx_OWM_Forecast_Snow_Day4

				Default item=Wx_OWM_Forecast_Humidity_Range_Day4
				Default item=Wx_OWM_Forecast_Humidity_Max_Day4
				Default item=Wx_OWM_Forecast_Humidity_Min_Day4

				Default item=Wx_OWM_Forecast_Pressure_Range_Day4
				Default item=Wx_OWM_Forecast_Pressure_Min_Day4
				Default item=Wx_OWM_Forecast_Pressure_Max_Day4

				Default item=Wx_OWM_Forecast_Cloudiness_Range_Day4
				Default item=Wx_OWM_Forecast_Cloudiness_Min_Day4
				Default item=Wx_OWM_Forecast_Cloudiness_Max_Day4

				Default item=Wx_OWM_Forecast_Wind_Speed_Range_Day4
				Default item=Wx_OWM_Forecast_Wind_Speed_Min_Day4
				Default item=Wx_OWM_Forecast_Wind_Speed_Max_Day4
			}

		}
	}
	// Add your other home automation stuff
}

I agree. And it would also be much more efficient in terms of resources.