SMHI Weather Binding

Oh, shouldn’t have copied from this thread. Tack! :slight_smile:
Great binding and thanks for your work! Just thought about doing something similar today and then came arcoss this - perfect timing.

Great! With that information, it also works for me! :slight_smile:

I get “coordinates outside of valid area”, regardless what coordinates I use. Even the demo-thing gets the same error.

My thing:
Thing smhi:forecast:SMHI_Weather “SMHI Väder” [ latitude=57.997072, longitude=15.990068, hourlyForecasts=0,1,2, dailyForecasts=0,1 ]

09:16:53.041 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - 'smhi:forecast:SMHI_Weather' changed from INITIALIZING to OFFLINE (CONFIGURATION_ERROR): Coordinates outside valid area

Any suggestions?

Thank you for this binding! I have just started using it and it seems to work fine!

One question/request though. I’m struggling a bit to create a nice HABPanel forecast view since it’s not straight forward to me how to create labels for hour or day of week by adding n hours or days to a DateTime item. Maybe there’s an easy fix, but if not, would it be possible to add a DateTime value for the hourly and daily forecasts?

Will look into it when rebuilding for 3.0

2 Likes

Ok, thanks!

May I ask if you have any ideas/knowledge on how to generate the column headers/weeekdays dynamically? Ideally, I would like to do it “on the fly” in the widget-code, but I have searched and tried without any luck… :slightly_smiling_face:

This is my widget

Do you want the code?

1 Like

Yes, please. I might find something that helps me move forward!

Also curious of the high/low temperatures you have in your widget. In the binding, I only see one Temperature (smhi:forecast:xxx:day_0#t). Am I missing something?

Have this in template

<a style="position:absolute; top:20; left:20; width:100%; height:100%"
   href="https://www.smhi.se/#geonameid=2712414" target="_blank"
<div ng-init="ServerPath='http://192.168.192.61:8080/static/weather-data'; IconSet='smhi'; daysnames={'Sunday': 'Söndag', 'Monday': 'Måndag', 'Tuesday': 'Tisdag', 'Wednesday': 'Onsdag', 'Thursday': 'Torsdag', 'Friday': 'Fredag', 'Saturday': 'Lördag'}">
<link rel="stylesheet" type="text/css" href="../static/weather-data/layouts/smhihabpanel.css" />
</div>

<div id="weather-location-name" >
	SMHI {{itemValue('SMHI_ObsTime') | date:'yyyy-MM-dd HH:mm'}} 
</div>
<table id="weather-table">
	<tr>
		<td rowspan="2"><img id="weather-icon" src="../static/weather-data/images/{{IconSet}}/{{itemValue('SMHI_Condition_No').replace(' ','-') | lowercase }}.png"/></td>
		<td rowspan="2" id="weather-temp">{{'%.1f' | sprintf:itemValue('SMHI_Temperature')}}</td>
		<td rowspan="2"id="weather-temp-sign">°C</td>
    		<td class="temp-max">{{'%.0f' | sprintf:itemValue('SMHI_Temperature_Max')}} °C</td>
  </tr>
  <tr>
		<td class="temp-min">{{'%.0f' | sprintf:itemValue('SMHI_Temperature_Min')}} °C</td>
  </tr>
</table>
			<table id="weather-table-details">
			   <tr>
					<td>Humidity:</td>
					<td>{{itemValue('SMHI_Humidity')}} %</td>
				</tr>
				<tr>
					<td>Pressure:</td>
					<td>{{'%.0f' | sprintf:itemValue('SMHI_Pressure')}} MPa</td>
				</tr>

			</table>

<p/>

<table id="weather-forecast-table">
	<tr>
 		<td>{{itemValue('SMHI_ObsTime_1') | date:'EEEE'}}</td>
    <td>{{itemValue('SMHI_ObsTime_2') | date:'EEEE'}}</td>
		<td>{{itemValue('SMHI_ObsTime_3') | date:'EEEE'}}</td>
	</tr>
	<tr>
 		<td>
			<img src="../static/weather-data/images/{{IconSet}}/{{itemValue('SMHI_Condition_No_1').replace(' ','-') | lowercase }}.png"/>
			<p>{{itemValue('SMHI_Condition_1')}}</p>
		</td>
		<td>
			<img src="../static/weather-data/images/{{IconSet}}/{{itemValue('SMHI_Condition_No_2').replace(' ','-') | lowercase }}.png"/>
			<p>{{itemValue('SMHI_Condition_2')}}</p>
		</td>
		<td>
			<img src="../static/weather-data/images/{{IconSet}}/{{itemValue('SMHI_Condition_No_3').replace(' ','-') | lowercase }}.png"/>
			<p>{{itemValue('SMHI_Condition_3')}}</p>
	</tr>
	<tr>
		<td class="temp-max">{{'%.0f' | sprintf:itemValue('SMHI_Temperature_Max_1')}} °C</td>
		<td class="temp-max">{{'%.0f' | sprintf:itemValue('SMHI_Temperature_Max_2')}} °C</td>
		<td class="temp-max">{{'%.0f' | sprintf:itemValue('SMHI_Temperature_Max_3')}} °C</td>
	</tr>
	<tr>
		<td class="temp-min">{{'%.0f' | sprintf:itemValue('SMHI_Temperature_Min_1')}} °C</td>
		<td class="temp-min">{{'%.0f' | sprintf:itemValue('SMHI_Temperature_Min_2')}} °C</td>
		<td class="temp-min">{{'%.0f' | sprintf:itemValue('SMHI_Temperature_Min_3')}} °C</td>
	</tr>
</table>
</a>

Thanks! Are you using a rule to populate the max and min daily temperature items by looking at all 24 hourly weather forecasts?

SMHI can just give Today Min/max in future so i adjust it with history.

rule "SMHI Min/Max Current "
when
Item SMHI_Temperature_Min changed or
Item SMHI_Temperature_Max changed
then
if (SMHI_Temperature_Min.state > Weather_Temp_Min.state ){
SMHI_Temperature_Min.postUpdate( Weather_Temp_Min.state)
}
if (SMHI_Temperature_Max.state < Weather_Temp_Max.state ){
SMHI_Temperature_Max.postUpdate( Weather_Temp_Max.state)
}
end

Binding compiled for OpenHAB3
org.openhab.binding.smhi-3.1.0-SNAPSHOT.jar

There is a lot of confusion about this binding.
The forum mentions observation time and min and max temperature. None of those are in the SMHI binding that you can download from within OpenHAB.
Is the binding discussed in this thread completely different from the one in the OpenHAB repository?

Yes it is. Min and max temperature, as well as min/max wind-speed and total daily precipitation has recently been merged in the OH3-binding, but won’t be available until 3.1 is released (or the next milestone if using the testing-branch, which should be available in a few days if the monthly release schedule still holds true)

Hi!
I am running this binding in OH3.10 and after 8-12 hours it stops refreshing.
Can I make it automatically refresh say every hour?

Do you use the binding from the link above, or the one included in the distribution?

I used the included one.

Den ons 9 juni 2021 17:19Anders Alfredsson via openHAB Community <bot@community.openhab.org> skrev:

I had a problem a week or so ago where the binding crashed after it recieved some bad values from the API and I had to restart the binding. But that was just one time, and have been running correctly after that. A fix is submitted and will be included in OH 3.1.

Du you get any errors in the log when it stops updating? Is the thing still marked as online?

Edit: And by default it does update every hour, that’s how often Smhi publishes new forecasts, so it tries to get the latest as soon as it is available

I have no errors and its online.

Try setting the binding to debug logging (log:set DEBUG org.openhab.binding.smhi in the console) and then restart the binding (bundle:restart org.openhab.binding.smhi) and see what it logs the next time it stops updating. You should see log lines every hour when it updates the forecast until then at least.