Assistance with Yahoo Weather

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?

Make sure you have org.openhab.persistence.rrd4j-1.8.3.jar in your addons folder.

What is the rest of the error message? This is probably related to the previous error but might not be depending on what the “…” said.

You did not post a Compute humidex rule. But the error means you are trying to refer to an Item in that rule (Weather_Humidex) that does not exist.

You are trying to format the String returned from your map file as if it were a floating point number. The label for Condition_Id should be `“Weather is [MAP(yahoo_weather_code.map):%s]”.

Yes, I do have org.openhab.persistence.rrd4j-1.8.3.jar in my addons folder.

Rest of error message:

Error during the execution of startup rule 'Update max and min temperatures': cannot invoke method public abstract org.openhab.core.types.State org.openhab.core.persistence.HistoricItem.getState() on null

For Weather_Humidex, I do not have that item, should I change the item below to be “Weather_Humidex”?

Number        Weather_Humidity       		"Outside Humidity [%d%%]"       <temperature>   (gWeather)              { weather="locationId=home, type=athmosphere, property=humidity" }

OK that error message is clearly caused by OH being unable to query the database. It is indeed related to the other rrd4j error.

What is your default persistence parameter set to?

It depends on what the Compute humidex rule does and what it uses. I suspect it uses Weather_Humidity to calculate Humidex. For now I would comment out the entire rule until you get the other stuff working right.

This is what I have in my rrd4j.persist file:

// persistence strategies have a name and a definition and are referred to in the "Items" section

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
}

I’ve also updated the Weather is to `“Weather is [MAP(yahoo_weather_code.map):%s]” and now I have “Weather is Err” displayed.

The Outside Temperature displays “82] F”

I’ve commented out the weather rules and almost all of the weather items:

/* Weather Items */

String      Condition_Id    "Weather is [MAP(yahoo_weather_code.map):%.s]"       (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"

Thanks for your help!

Get rid of the “.” in the label for Condition_Id.

"Weather is [MAP(yahoo_weather_code.map):%s]"

The 82 indicates that your Weather Binding is actually working. Is the “]” in there a typo? There is no way as far as I can tell from what is posted that it should be printing “82] F” versus “82 °F”.

Nope, it is actually showing the right square bracket.

Now it says Weather is 26 (I guess it displays the temperature in Celcius).

Condition_Id is a number representing the conditions, not temperature. 26 indicates Cloudy.

It is likely that the “.” in Condition_Id’s label was causing the bracket problem. Does the temp display correctly now?

Are you using Designer? It will likely highlight syntax errors like this.

Ahh, got it. Why does it display a number instead of the value? I verified that I have “yahoo.weather.map” in the layouts directory and it does have a line saying a value of 26 is “Cloudy”.

I did remove the “.” and I still have the “]” in outside temperature and I still have the raw html showing with a few graphics once I select “weather is”.

I forgot to add that I am using Designer and none of the lines are showing an error or warning.

It needs to be in the configuration/transform directory.

Ignore the webview for now. One thing at a time.

I moved yahoo.weather.map to the transform directory and restarted openhab. I’m still getting Weather is 26 and Outside Temperature “88] F”.

Short of randomly changing things I don’t know what is wrong. See this thread for a number of working configurations. Maybe you can see either what is different with yours or copy and paste from there.

OK, looking at the examples, where do I put this?


Webview HTML:

<!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}, ${item:Weather_LastUpdate} Sunrise: ${item:Sunrise_Time} / Sunset: ${item:Sunset_Time}</div>

        <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">${item:Weather_Temperature.state}</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>${item:Weather_Pressure}</td>
                                        </tr>
                                </table>
                        </td>
                </tr>
        </table>

        <table id="weather-forecast-table">
                <tr>
                        <td>Today</td>
                        <td>${item:Weather_Forecast_Day_1}</td>
                        <td>${item:Weather_Forecast_Day_2}</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">${item:Weather_Temp_Min} °F</td>
                        <td class="temp-max">${item:Weather_Temp_Min_1} °F</td>
                        <td class="temp-max">${item:Weather_Temp_Min_2} °F</td>
                </tr>
                <tr>
                        <td class="temp-min">${item:Weather_Temp_Max} °F</td>
                        <td class="temp-min">${item:Weather_Temp_Max_1} °F</td>
                        <td class="temp-min">${item:Weather_Temp_Max_2} °F</td>
                </tr>
        </table>

</body>

</html>

That is the webview. It is independent from your Items and Rules and sitemap and it is optional. I’d focus on getting the Items and persistence and charts to work first. Then start to try getting the Webview to work.

The full documentation of the webview is on the wiki page (near the bottom):

I quite using the webview many months ago and don’t remember everything you have to do to get it to work and don’t want to steer you wrong.

OK, I replaced Items, Rules and sitemap to match your comments from 1/13 and I’m still getting the same “Weather is 26” and Outside Temperature “90] F” and my screen looks similar to p0lar’s from 4/29.

I never was able to figure out what may have been wrong. Did you follow the instructions and download the files from the bottom of the wiki page? The one file I posted is the one file you need to change, but it is not the only file you need to make it work. NOTE: I’m making a big assumption that you are using OH 1.8.3 and not OH 2, is that correct?

Try commenting everything out of your sitemap except for the weather stuff. In particular make sure that there is nothing before your weather lines in the sitemap.

Make sure that the permissions on your map file are open to where the openhab user can read the file.

Yes and yes.

New sitemap:

sitemap home label="Highwood Place"
{

//	Frame {
//		Group item=Lights label="All Lighting" icon="hue"
//		Group item=Master_Bedroom label="Master Bedroom" icon="bedroom"
//		Group item=Master_Bathroom label="Master Bathroom" icon="bath"
//		Group item=Office label="Office" icon="office"
//		Group item=Theater label="Theater" icon="video"
//		Group item=Living_Room label="Living Room" icon="sofa"
//		Group item=Kitchen label="Kitchen" icon="kitchen"
//		Group item=Hallway label="Hallway" icon="corridor"
//		Group item=Peggy_Bedroom label="Peggy Bedroom" icon="parents"
//		Group item=Peggy_Office label="Peggy Office" icon="terrace"
//		Group item=Patio label="Patio" icon="sun_clouds"
//		Group item=Peyton_Bedroom label="Peyton Bedroom" icon="boy4"
//		Group item=Outside label="Outside" icon="garden"
//		Group item=Presence label="Presence" icon="present"


//	}
	
// 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://user:password@localhost: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://user:password@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://user:password@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://user:password@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://user:password@localhost:8080/rrdchart.png?items=Weather_Humidity&period=D" refresh=30000 visibility=[Weather_Humidity_Chart_Period==1]
                                                Image url="http://user:password@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://user:password@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://user:password@localhost:8080/rrdchart.png?items=Weather_Pressure&period=D" refresh=30000 visibility=[Weather_Pressure_Chart_Period==1]
                                                Image url="http://user:password@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
                        }

                }
 
}

All I see is the “Weather is 26” and the same issues with the outside temperature.

How do I verify that?

ls -l /etc/openhab/configurations/transform/yahoo_weather_code.map

Make sure the permissions are such that the openhab user can read it.

NOTE: I just noticed you called this file “yahoo.weather.map” above. If that is what you really named the file, then you must use the filename exactly as it is, including case.

"Weather is [MAP(yahoo.weather.map):%.s]"

Yay! Now I get “Weather is Cloudy”.

I still have the outside temperature as “88] degree F”