I’ve been trying to get the weather binding to work for several weeks now with no luck. I found another thread that was a bit old and copied data, but I think I’m still getting something wrong.
Here is what I have in each file:
openhab.cfg: (it is my understanding though that lat/long are not needed, but I put them in just in case)
weather:location.home.name=home
weather:location.home.woeid=2516542
weather:location.home.latitude=<my actual lat>
weather:location.home.longitude=<my actual long>
weather:location.home.provider=Yahoo
weather:location.home.language=en
weather:location.home.updateInterval=10
home.items:
/* Weather Items */
String Condition_Id "Weather is [MAP(yahoo_weather_code.map):%.0f °F]" (Weather) { weather="locationId=home, type=condition, property=id" }
// Weather panel
Group gWeather_Chart (gWeather)
Number Weather_Temperature "Outside Temperature [%.0f] °F" <temperature> (gWeather_Chart) { weather="locationId=home, type=temperature, property=current, unit=fahrenheit" }
Number Weather_Humidity "Outside Humidity [%d%%]" <temperature> (gWeather) { weather="locationId=home, type=athmosphere, property=humidity" }
Number Weather_Pressure "Barometric Pressure [%.2f in]" <temperature> (gWeather) { weather="locationId=home, type=athmosphere, property=pressure, unit=inches" }
Number Weather_Pressure_Chart_Period "Chart Period"
Number Weather_Temp_Min "Today's Minimum [%.0f] °F" <temperature> (gWeather_Chart)
Number Weather_Temp_Max "Today's Maximum [%.0f] °F" <temperature> (gWeather_Chart)
Number Weather_Chart_Period "Chart Period"
DateTime Weather_LastUpdate "Last Update [%1$ta %1$tr]" <clock>
Number Weather_Humidity_Chart_Period "Chart Period"
rrd4j.persist:
Strategies {
everyMinute : "0 * * * * ?"
everyHour : "0 0 * * * ?"
everyDay : "0 0 0 * * ?"
// if no strategy is specified for an item entry below, the default list will be used
default = everyMinute
}
Items {
// Persist ALL items in the persist GROUP
persist* : strategy = everyMinute, everyChange, restoreOnStartup
}
home.sitemap:
// Weather
Text item=Condition_Id icon="yahoo_weather" {
Frame {
Webview url="/weather?locationId=home&layout=example&iconset=colorful" height=13
Text item=Weather_LastUpdate visibility=[Weather_LastUpdate>30] valuecolor=[Weather_LastUpdate>120="orange", Weather_LastUpdate>300="red"]
Text item=Weather_Temperature valuecolor=[Weather_LastUpdate=="Uninitialized"="lightgray",Weather_LastUpdate>90="lightgray",>77="orange",>60="green",>40="aqua",<=40="blue"]{
Frame {
Text item=Weather_Temp_Max valuecolor=[>77="orange",>60="green",>40="aqua",<=40="blue"]
Text item=Weather_Temp_Min valuecolor=[>77="orange",>60="green",>40="aqua",<=40="blue"]
}
Frame {
Switch item=Weather_Chart_Period label="Period" mappings=[0="Hour", 1="Day", 2="Week"]
Image url="http://<pi ip>:8080/rrdchart.png?items=Weather_Temperature,Weather_Temp_Max,Weather_Temp_Min&period=h" refresh=6000 visibility=[Weather_Chart_Period==0, Weather_Chart_Period=="Uninitialized"]
Image url="http://<pi ip>@localhost:8080/rrdchart.png?items=Weather_Temperature,Weather_Temp_Max,Weather_Temp_Min&period=D" refresh=30000 visibility=[Weather_Chart_Period==1]
Image url="http://<pi ip>@localhost:8080/rrdchart.png?items=Weather_Temperature,Weather_Temp_Max,Weather_Temp_Min&period=W" refresh=30000 visibility=[Weather_Chart_Period==2]
}
}
Text item=Weather_Humidity {
Frame {
Switch item=Weather_Humidity_Chart_Period label="Period" mappings=[0="Hour", 1="Day", 2="Week"]
Image url="http://<pi ip>@localhost:8080/rrdchart.png?items=Weather_Humidity&period=h" refresh=6000 visibility=[Weather_Humidity_Chart_Period==0, Weather_Humidity_Chart_Period=="Uninitialized"]
Image url="http://<pi ip>@localhost:8080/rrdchart.png?items=Weather_Humidity&period=D" refresh=30000 visibility=[Weather_Humidity_Chart_Period==1]
Image url="http://<pi ip>@localhost:8080/rrdchart.png?items=Weather_Humidity&period=W" refresh=30000 visibility=[Weather_Humidity_Chart_Period==2]
}
}
Text item=Weather_Pressure {
Frame {
Switch item=Weather_Pressure_Chart_Period label="Period" mappings=[0="Hour", 1="Day", 2="Week"]
Image url="http://<pi ip>@localhost:8080/rrdchart.png?items=Weather_Pressure&period=h" refresh=6000 visibility=[Weather_Pressure_Chart_Period==0, Weather_Pressure_Chart_Period=="Uninitialized"]
Image url="http://<pi ip>@localhost:8080/rrdchart.png?items=Weather_Pressure&period=D" refresh=30000 visibility=[Weather_Pressure_Chart_Period==1]
Image url="http://<pi ip>@localhost:8080/rrdchart.png?items=Weather_Pressure&period=W" refresh=30000 visibility=[Weather_Pressure_Chart_Period==2]
}
}
Text item=Sunrise_Time
Text item=Sunset_Time
Text item=Twilight_Time
}
}
home.rules:
import org.openhab.core.library.types.*
rule "Update max and min temperatures"
when
Item Weather_Temperature changed or
Time cron "1 0 0 * * ?" or
System started
then
val startOfDay = now.withTimeAtStartOfDay
if(Weather_Temperature != null) {
postUpdate(Weather_Temp_Max, Weather_Temperature.maximumSince(startOfDay).state)
postUpdate(Weather_Temp_Min, Weather_Temperature.minimumSince(startOfDay).state)
}
end
yahoo.weather.map:
-=Unknown
0=Tornado
1=Tropical Storm
2=Hurricane
3=Severe Thunderstorms
4=Thunderstorms
5=Mixed Rain and Snow
6=mixed Rain and Sleet
7=mixed Snow and Sleet
8=Freezing Drizzle
9=Drizzle
10=Freezing Rain
11=Showers
12=Showers
13=Snow Flurries
14=Light Snow Showers
15=Blowing Snow
16=Snow
17=Hail
18=Sleet
19=Dust
20=Foggy
21=Haze
22=Smoky
23=Blustery
24=Windy
25=Cold
26=Cloudy
27=Mostly Cloudy (Night)
28=Mostly Cloudy (Day)
29=Partly Cloudy (Night)
30=Partly Cloudy (Day)
31=Clear (Night)
32=Sunny
33=Fair (Night)
34=Fair (Day)
35=Mixed Rain and Hail
36=Hot
37=Isolated Thunderstorms
38=Scattered Thunderstorms
39=Scattered Thunderstorms
40=Scattered Showers
41=Heavy Snow
42=Scattered Snow Showers
43=Heavy Snow
44=Partly Cloudy
45=Thundershowers
46=Snow Showers
47=Isolated Thundershowers
index.html (in webapps/weather-data/layouts:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" CONTENT="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="weather-data/layouts/example.css" />
<script type="text/javascript" src="weather-data/layouts/example.js"></script>
</head>
<body id="weather-body" onload="formatIframe()">
<div id="weather-location-name">${config:name}, ${weather:condition.observationTime(%1$td/%1$tm/%1$tY %1$tH:%1$tM)}
<table id="weather-table">
<tr>
<td rowspan="2"><img id="weather-icon" src="weather-data/images/${param:iconset}/${weather:condition.commonId}.png"/></td>
<td id="weather-temp">${weather:temperature.current(%.1f)[fahrenheit]}</td>
<td id="weather-temp-sign">°F</td>
</tr>
<tr>
<td colspan="2">
<table id="weather-table-details">
<tr>
<td>Humidity:</td>
<td>${weather:atmosphere.humidity}%</td>
</tr>
<tr>
<td>Pressure:</td>
<td>${weather:atmosphere.pressure(%.2f)[inches]} in</td>
</tr>
</table>
</td>
</tr>
</table>
<table id="weather-forecast-table">
<tr>
<td>Today</td>
<td>${forecast(1):condition.observationTime(%1$tA)}</td>
<td>${forecast(2):condition.observationTime(%1$tA)}</td>
</tr>
<tr>
<td><img src="weather-data/images/${param:iconset}/${forecast(0):condition.commonId}.png"/></td>
<td><img src="weather-data/images/${param:iconset}/${forecast(1):condition.commonId}.png"/></td>
<td><img src="weather-data/images/${param:iconset}/${forecast(2):condition.commonId}.png"/></td>
</tr>
<tr>
<td class="temp-max">${forecast(0):temperature.max(%.2f)[fahrenheit]} °F</td>
<td class="temp-max">${forecast(1):temperature.max(%.2f)[fahrenheit]} °F</td>
<td class="temp-max">${forecast(2):temperature.max(%.2f)[fahrenheit]} °F</td>
</tr>
<tr>
<td class="temp-min">${forecast(0):temperature.min(%.2f)[fahrenheit]} °F</td>
<td class="temp-min">${forecast(1):temperature.min(%.2f)[fahrenheit]} °F</td>
<td class="temp-min">${forecast(2):temperature.min(%.2f)[fahrenheit]} °F</td>
</tr>
</table>
</body>
</html>
In the log, there is a warning about “no queryable persistence service registered with the name ‘rrd4j’” and an "Error during the execution of startup rule “Update max and min temperatures; cannot invoke method public abstract…”.
There is also “Error during the execution of rule ‘Compute humidex’: The name ‘Weather Humidex’ cannot be resolved to an item or type.”
When I open the app, I receive the error below in the log:
Exception while formatting value '28' of item Condition_Id with format 'MAP(yahoo_weather_code.map):%.0f °F': java.util.IllegalFormatConversionException: f != java.lang.String
2016-09-12 13:15:25.041 [ERROR] [b.w.i.gfx.WeatherTokenResolver] - Invalid weather token: item:Weather_Temp_Max_1
java.lang.RuntimeException: Invalid weather token: item:Weather_Temp_Max_1
The app has a bar with “Weather is Err” and the html has some pictures, but mostly displays HTML.
I’m really lost at this point, can someone please assist?