Template Example: Weather Binding

Using the Icon codes makes it much easier than relying on the description to be consistent…

My XML is pulled from here: (yours would be different)
ftp://ftp.bom.gov.au/anon/gen/fwo/IDV10753.xml

Here’s a snip from the XML

<forecast-period index="1" start-time-local="2018-08-30T00:00:00+10:00" end-time-local="2018-08-31T00:00:00+10:00" start-time-utc="2018-08-29T14:00:00Z" end-time-utc="2018-08-30T14:00:00Z">

<element type="forecast_icon_code">12</element>

<element type="precipitation_range">0 to 2 mm</element>
<element type="air_temperature_minimum" units="Celsius">2</element>
<element type="air_temperature_maximum" units="Celsius">13</element>
<text type="precis">Patchy rain developing.</text>
<text type="probability_of_precipitation">50%</text>
</forecast-period>

Icon codes are referenced here:
http://reg.bom.gov.au/info/forecast_icons.shtml

I referenced this page and your array, and manually renamed the files to match. There were lots of left over files as not all files had a matching code. I do remember seeing a .bat file to do it once, but it took me less than 5 minutes to rename them.

I haven’t moved the XML parsing into OpenHAB yet, I’m still running the Python script to pull the data from BOM and put it into the OpenHAB api every hour. Below is one of the lines in the Python script that sets the Icon code to your OpenHAB item. (I have 7 lines, one for each forecast day)

setFWOItem("forecast_icon_code","BOM_Forecast_Icon_Code","0","element")

It’s been running like this for probably a year now, no issues. I just hadn’t got a widget to work nicely. I was using individual blocks in HABpanel…worked, but wasn’t pretty…seeing how you had put your together was an awesome help…

Something I did also was at 6pm, copy the minimum temp from tomorrow’s forecast into today’s forecast, as the BOM data is no longer available, and a NULL value is set. Doing this stopped the NULL value…

That’s brilliant I will revisit this again and add in the icon codes (unless the SA XML is missing this and that’s why I never did it…)

I’m running python as well still

Thanks
Andrew

Happy to return some help. When I transfer the XML parsing over to OpenHAB, i’ll flick you a copy as well…

I was almost done with the configuration using yahoo api. I had just a little problem regarding the condition id being null …
Then i restarted OH, now yahoo is not working anymore. Tried OpenWeather (log says API key invalid, despite working in browser just fine), ForecastIO (throws exception). Best: my OH log keeps logging info about locations i used to test which are long gone from all cfg and item files. Restarted OH numerous times, cant get anything to work now, everything regarding weather fails.
I deleted everything from weather.cfg instead of commenting out, but even the old api keys i used still show up in the log! I have no idea what is going on. I can even have the binding uninstalled and get values for condition (i dont get them when the binding is installed).

Any idea where this binding/OH stores or caches (and uses …) historical configuration? What must i clean to get this working again? If i delete all that’s in cache then my Z-Wave devices are mostly gone :frowning:

Im kinda desperate now … even after complete reinstall of the binding and setting up Hamweather for the first time i still get alot errors about long gone locations (and it’s not working).

is there a way to get the max & min forecast temperatures in HABpanel without each of them having the ‘°C’ suffix?

Yes, just search the HTML for °C and delete or replace with your chosen suffix.

For example, the line:

{{'%.0f' | sprintf:itemValue('Temp_Max0')}} °C

For Fahrenheit:

{{'%.0f' | sprintf:itemValue('Temp_Max0')}} °F

Or for no suffix:

{{'%.0f' | sprintf:itemValue('Temp_Max0')}}

There are multiple instances, so be sure to get them all and take care not to inadvertently replace / delete something else. If the html ends up being invalid the whole thing will stop working (learn from my mistakes) :wink:

Andy

thanks, but it’s not in the HTML, it’s being returned by the wunderground channel.

FYI: i’m running v.2.4-M3, and have updated my wunderground thing to the new bridge & location format. I’ve also cleared the cache and restarted with no change.

Ok, if you are using the widget (link below), then you will get a better response if you ask your question in that thread:

If you are using the HTML code described in this thread, then you could use try using the .replace function to strip out the symbols. For example:

{{'%.0f' | sprintf:itemValue('Temp_Max0').replace('°C',''}}

Hope this helps. If not can you post a screen shot of what you are seeing with your code (html and items) and I will take a look.

Regards, Andrew

Thanks. I’m not using the code from this starting example, I’m using a very heavily customised version of weather-underground widget from the gallery, but as far as I’m aware that’s not of much relevance to my problem (I posted in this topic because it’s what my google search suggested).

I’ve tried your suggested replace code but it doesn’t give the item value and just displays as-is. Is there something I need to do to make it process?

Here’s a pic of how it displays (without your suggestion in place). The Max/Min temperatures are towards the bottom of the columns, and both display the ‘°C’ (I want it removed from the first).

here’s my items:-

|Number:Temperature|W_F_0_Temp_Min|||"Today's Temp min [%.2f]"   |<temperature>|(gForecasts0)|||{channel="weatherunderground:weather:local:forecastToday#minTemperature"}|
|---|---|---|---|---|---|---|---|---|---|
|Number:Temperature|W_F_0_Temp_Max|||"Today's Temp max [%.2f]"   |<temperature>|(gForecasts0)|||{channel="weatherunderground:weather:local:forecastToday#maxTemperature"}|

here’s my panel code:-

<h5 style="margin-bottom:-10px;"><b>{{itemValue('W_F_0_Temp_Max')}}</b> / {{itemValue('W_F_0_Temp_Min')}}</h5>

Thanks in advance for any help you can give.

Neil, you should post this in the correct thread (I believe this is the one in my previous post).

Personally I sill use a version of this code (so I can support it and it does all I want).

I’ve never actually looked at the alternative code, so I’m not the man to help.

Andy

ok, thanks.

Are you sure it’s °C (2 characters) and not ℃ (1 character)?
Anyways you can also do this:

{{'%.0f' | sprintf:itemState('Temp_Max0').split(' ')[0]}}

Not sure if it’s 1 or 2 characters, but your code worked - thank you. :slight_smile:

Hi Greg, can you share this with us? I want to also use the BoM in Habpanel.

Im retrieving the xml file from the ftp site…

Cheers!

See that one, thanks. Doesnt have the habpanel widgets though :frowning:

Hello, I am joining in here cause I want to extent my Weather-Template with values from the astro-binding. To do so, I simply added one row to the example:

<table id="weather-table">
                <tr>
                        <td rowspan="2"><img id="weather-icon" src="static/weather-data/images/${param:iconset}/${weather:condition.commonId}.png"/></td>
                        <td id="weather-temp">${weather:temperature.current(%.1f)}</td>
                        <td id="weather-temp-sign">°C</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(%.1f)} mb</td>
                                        </tr>
                                        <tr>
                                                <td>Sonnenaufgang</td>
                                                <td>${astro:sun:home:rise_start(%1$tH:%1$tM)}</td>
                                        </tr>
                                </table>
                        </td>
                </tr>
        </table>

I also tried to display “Sonnenaufgang” with itemValue, but whatever I try, the log says:

2018-11-18 17:44:26.153 [WARN ] [er.internal.gfx.WeatherTokenResolver] - Invalid weather token: astro:sun:rise.set
2018-11-18 17:50:29.649 [WARN ] [er.internal.gfx.WeatherTokenResolver] - Invalid weather token: Sunrise_Time
2018-11-18 17:53:42.849 [WARN ] [er.internal.gfx.WeatherTokenResolver] - Invalid weather token: item:Sunrise_Time
2018-11-18 17:53:42.999 [WARN ] [er.internal.gfx.WeatherTokenResolver] - Invalid weather token: item:Sunrise_Time
2018-11-18 18:53:50.701 [WARN ] [er.internal.gfx.WeatherTokenResolver] - Invalid weather token: astro:sun:home:rise#start
2018-11-18 18:55:49.069 [WARN ] [er.internal.gfx.WeatherTokenResolver] - Invalid weather token: astro:sun:home:rise_start
2018-11-18 19:02:06.980 [WARN ] [er.internal.gfx.WeatherTokenResolver] - Invalid weather token: astro:sun:home:rise_start(%1$tH:%1$tM)

Am I assuming right that I only can view Weather items in this template?

Hello Fab4guy,

I saw you are using the ForecastIo API with german language. How do you managed to get the icons to your widget?
Did you translate the icon names?

In the second I wrote this message I figured out how to solve my problem.

I´m using now:

<td rowspan="2"><img id="weather-icon" src="{{ServerPath}}/images/{{IconSet}}/{{itemValue('CommonId').replace(' ','-') | lowercase }}.png"/></td>

Nevertheless many thanks

Hi,
I´m new and i can’t html or jave but with the help in this thread i config a working habpanel view.

1

But now i have 3 questions cause i didn`t understand it.

First is the language problem. At which point i must copy the translate text in the example.hmtl ?
i have try at the beginnig but the Days like Monday didn’t translate.

Second is the third line under min and max temp in the forecast.
i try like this:

<!DOCTYPE html>
<html>

<head>
	<meta http-equiv="Content-type" CONTENT="text/html; charset=utf-8">
	<link rel="stylesheet" type="text/css" href="static/weather-data/layouts/example.css" />
	<script type="text/javascript" src="static/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)}</div>

	<table id="weather-table">
		<tr>
			<td rowspan="2"><img id="weather-icon" src="static/weather-data/images/${param:iconset}/${weather:condition.commonId}.png"/></td>
			<td id="weather-temp">${weather:temperature.current(%.1f)}</td>
			<td id="weather-temp-sign">°C</td>
		</tr>
		<tr>
			<td colspan="2">
				<table id="weather-table-details">
					<tr>
						<td>Luftfeuchtigkeit:</td>
						<td>${weather:atmosphere.humidity} %</td>
					</tr>
					<tr>
						<td>Niederschlag:</td>
						<td>${weather:precipitation.probability} %</td>
					</tr>
					<tr>
						<td>Wind:</td>
                    <td>${weather:wind.speed(%.1f)} km/h aus ${weather:wind.direction}</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>
			<td>${forecast(3):condition.observationTime(%1$tA)}</td>
	    	<td>${forecast(4):condition.observationTime(%1$tA)}</td>
		</tr>
		<tr>
			<td><img src="static/weather-data/images/${param:iconset}/${forecast(0):condition.commonId}.png"/></td>
			<td><img src="static/weather-data/images/${param:iconset}/${forecast(1):condition.commonId}.png"/></td>
			<td><img src="static/weather-data/images/${param:iconset}/${forecast(2):condition.commonId}.png"/></td>
			<td><img src="static/weather-data/images/${param:iconset}/${forecast(3):condition.commonId}.png"/></td>
			<td><img src="static/weather-data/images/${param:iconset}/${forecast(4):condition.commonId}.png"/></td>
		</tr>
		<tr>
			<td class="temp-max">${forecast(0):temperature.max(%.0f)}</td>
			<td class="temp-max">${forecast(1):temperature.max(%.0f)}</td>
			<td class="temp-max">${forecast(2):temperature.max(%.0f)}</td>
			<td class="temp-max">${forecast(3):temperature.max(%.0f)}</td>
			<td class="temp-max">${forecast(4):temperature.max(%.0f)}</td>
		</tr>
			<td class="temp-min">${forecast(0):temperature.min(%.0f)}</td>
			<td class="temp-min">${forecast(1):temperature.min(%.0f)}</td>
			<td class="temp-min">${forecast(2):temperature.min(%.0f)}</td>
			<td class="temp-min">${forecast(3):temperature.min(%.0f)}</td>
			<td class="temp-min">${forecast(4):temperature.min(%.0f)}</td>
		</tr>
		</tr>
			<td class="Precip_Probability">${precipitation(0):probability.min} %</td>
			<td class="Precip_Probability">${precipitation(0):probability.min} %</td>
			<td class="Precip_Probability">${precipitation(0):probability.min} %</td>
			<td class="Precip_Probability">${precipitation(0):probability.min} %</td>
		</tr>
		<tr>
			<td class="Precip_Probability">${forecast(1):precipitation.probability} %</td>
		</tr>
	</table>

</body>

</html>

what is wrong ? 

Last but not least is the formatting from the widget. when i change the example.css nothing saved. 
how i can formatting the icons ?? 

thx for help