Custom widget: Current Weather

Hi guys, firstly thanks a great great post!!!
But I’m getting in some problems, I’m using OH 1.8.3 and the icon set provided is used for OH 2 snapshot version, anyone can share the icon set for OH1.8.3?
I failed to set this widget up. Can anybody show me how to do it step by step?
How can I import json file from those links you provided into my habpanel?
Please help me to install this, I love this

The iconset is not made for OH2 snapshot explicitly. It’s generic map for weather binding. I recommend you reading through the docs, there’s everything you need to get you started.

thanks for your quick reply, then how can I add a new widget from json file to habpanel OH1.8.3?

I made an English map below. Has anyone noticed that sometimes when the weather refreshes the MAP stops being applied?

when I open my HABPanel, I see:

Sunny

but after the weather is updated by the weather binding it changes to:

sunny

The item value hasn’t changed and if I open the HABPanel on another machine the mapping is present.

thunder=Thunder
storm=Storm
rain-and-snow=Rain & Snow
rain-and-sleet=Rain & Sleet
snow-and-sleet=Snow & Sleet
freezing-drizzle=Freezing Drizzle
few-showers=Few Showers
freezing-rain=Freezing Rain
rain=Rain
snow-flurries=Snow Flurries
light-snow=Light Snow
blowing-snow=Blowing Snow
snow=Snow
sleet=Sleet
dust=Dust
fog=Fog
wind=Wind
cold=Cold
cloudy=Cloudy
mostly-cloudy-night=Mostly Cloudy
mostly-cloudy-day=Mostly Cloudy
partly-cloudy-night=Partly Cloudy
partly-cloudy-day=Partly Cloudy
clear-night=Clear
sunny=Sunny
hot=Hot
scattered-thunder=Scattered Thunder
scattered-showers=Scattered Showers
thundershowers=Thunder Showers
snow-showers=Snow Showers
scattered-thundershower=Scattered Thunder Storms
unknown=???

Yes. The cause is the same as described here: https://community.openhab.org/t/mapping-of-item-values-not-correctly-shown-in-habpanel/19518

That’s because the Rest API call returns for the state call for one item or the change on the event bus only the “unmapped” status - but when getting it through the item “overview” call it returns the “mapped” status. That’s why HABpanel “jumps” between the two views.

I’m not sure if it can solved by HAPpanel only.

Widget works great with underground binding. My only improvement request would be how to use icons that have been used previously in Template Example: Weather Binding

In my opinion colour adds to the eye catching appeal that HABpanel has to offer

Ok, Im clearly doing something wrong. Im still very new to this. My Temp displays Null. Im running openhab2 with yahoo weather 2.0 binding.

String Weather_Condition “Weather [%s]” (Weather) {weather=“locationId=Home, type=condition, property=commonId”}
String Weather_Formatted_Condition “Weather [MAP(weather_pl.map):%s]” (Weather) {weather=“locationId=Home, type=condition, property=commonId”}
Number Weather_Temp “Today [%.2f °F]” (Weather) {weather=“locationId=Home, type=temperature, property=feel”}F

Hi Josh,

If you use Yahoo Weather binding, you’ll need to adjust the items to be linked with channels.
E.g. instead of:

Number Weather_Temp "Today [%.2f °F]" (Weather) {weather="locationId=Home, type=temperature, property=feel"}

You need to use:

Number Weather_Temp "Today [%.2f °F]" (Weather) {channel="yahooweather:weather:8fd96b13:temperature"}
1 Like

Most excellent!! Thanks that clarifies alot.

Two more quick questions I hope.

To get the condtition replace temperature with condition? also to change to farenheight?

Did you find a way to change the icon ? because I’m using fully kiosk browser on old android tab an the icon is not displaying well so maybe with png icon it gonna be better

Hi Dominic,

Kuba helped me with this over at:

Hope this helps

Hi Dominic,

Your weather widget looks impressing. I’m pretty new to habpanel, but I tried to setup your widget on my habpanel. unfortunately only limitted success;-(( Maybe you can give me 1-2 hints. It looks like the following. As you can see, not that good as yours:

I created plenty of items in weather.items file:

String  W0_Weather_Condition  		   "Condition [%s]" 								<fog> 		(Weather) {weather="locationId=home, forecast=0, type=condition, property=commonId"}
String  W0_Weather_Formatted_Condition "Condition [MAP(weather_de.map):%s]" 			<fog>		(Weather) {weather="locationId=home, forecast=0, type=condition, property=commonId"}
Number  W0_Weather_Temp        		   "Temp. [%.1f °C]"     					<temperature>   	(Weather) {weather="locationId=home, forecast=0, type=temperature, property=feel"}
Number  W0_Weather_Temp_min            "Temp. [%.2f °C]"     					<temperature>   	(Weather) {weather="locationId=home, forecast=0, type=temperature, property=min"}
Number  W0_Weather_Temp_max            "Temp. [%.2f °C]"     					<temperature>   	(Weather) {weather="locationId=home, forecast=0, type=temperature, property=max"}
Number  W0_Weather_Wind                "Windspeed [%.2f m/h]"    				<wind>				(Weather) {weather="locationId=home, forecast=0, type=wind, property=speed"}
String  W0_Weather_Forecast	 	   	   "[%1$tA]" 													(Weather) {weather="locationId=home, forecast=0, type=condition, property=observationTime" }

I think my major problem is the fornat of the day.

Thanks a lot.

Regards.
Matthias

2 Likes

Hum … start to look at this and if you can’t figure it out I’m gonna help you

String  Weather_Formatted_Condition0   "Pogoda [MAP(weather_pl.map):%s]" <fog> (Weather) {weather="locationId=home, type=condition, property=commonId"}

String Weather_Formatted_Condition1 “Pogoda [MAP(weather_pl.map):%s]” (Weather) {weather=“locationId=home, forecast=1, type=condition, property=commonId”}
String Weather_Formatted_Condition2 “Pogoda [MAP(weather_pl.map):%s]” (Weather) {weather=“locationId=home, forecast=2, type=condition, property=commonId”}
String Weather_Formatted_Condition3 “Pogoda [MAP(weather_pl.map):%s]” (Weather) {weather=“locationId=home, forecast=3, type=condition, property=commonId”}
String Weather_Formatted_Condition4 “Pogoda [MAP(weather_pl.map):%s]” (Weather) {weather=“locationId=home, forecast=4, type=condition, property=commonId”}
String Weather_Formatted_Condition5 “Pogoda [MAP(weather_pl.map):%s]” (Weather) {weather=“locationId=home, forecast=5, type=condition, property=commonId”}
String Weather_Formatted_Condition6 “Pogoda [MAP(weather_pl.map):%s]” (Weather) {weather=“locationId=home, forecast=6, type=condition, property=commonId”}

Number  Weather_Temp        "Dzisiaj [%.2f °C]"     <temperature>   (Weather) {weather="locationId=home, type=temperature, property=feel"}    

Number Weather_Temp1 “Temperature min [%.2f °C]” {weather=“locationId=home, forecast=1, type=temperature, property=feel”}

Number Temperature “Temperature [%.2f °C]” {weather=“locationId=home, type=temperature, property=current”}
Number Humidity “Humidity [%d %%]” {weather=“locationId=home, type=atmosphere, property=humidity”}
Number Pressure “Pressure [%.2f mb]” {weather=“locationId=home, type=atmosphere, property=pressure”}

Number Temp_Min0 “Temperature min [%.2f °C]” {weather=“locationId=home, forecast=0, type=temperature, property=min”}
Number Temp_Max0 “Temperature max [%.2f °C]” {weather=“locationId=home, forecast=0, type=temperature, property=max”}
Number Temp_Min1 “Temperature min [%.2f °C]” {weather=“locationId=home, forecast=1, type=temperature, property=min”}
Number Temp_Max1 “Temperature max [%.2f °C]” {weather=“locationId=home, forecast=1, type=temperature, property=max”}
Number Temp_Min2 “Temperature min [%.2f °C]” {weather=“locationId=home, forecast=2, type=temperature, property=min”}
Number Temp_Max2 “Temperature max [%.2f °C]” {weather=“locationId=home, forecast=2, type=temperature, property=max”}
Number Temp_Min3 “Temperature min [%.2f °C]” {weather=“locationId=home, forecast=3, type=temperature, property=min”}
Number Temp_Max3 “Temperature max [%.2f °C]” {weather=“locationId=home, forecast=3, type=temperature, property=max”}
Number Temp_Min4 “Temperature min [%.2f °C]” {weather=“locationId=home, forecast=4, type=temperature, property=min”}
Number Temp_Max4 “Temperature max [%.2f °C]” {weather=“locationId=home, forecast=4, type=temperature, property=max”}
Number Temp_Min5 “Temperature min [%.2f °C]” {weather=“locationId=home, forecast=5, type=temperature, property=min”}
Number Temp_Max5 “Temperature max [%.2f °C]” {weather=“locationId=home, forecast=5, type=temperature, property=max”}
Number Temp_Min6 “Temperature min [%.2f °C]” {weather=“locationId=home, forecast=6, type=temperature, property=min”}
Number Temp_Max6 “Temperature max [%.2f °C]” {weather=“locationId=home, forecast=6, type=temperature, property=max”}

Number Wind_Speed0 “Windspeed [%.2f km/h]” {weather=“locationId=home, forecast=0, type=wind, property=speed”}
Number Wind_Speed1 “Windspeed [%.2f km/h]” {weather=“locationId=home, forecast=1, type=wind, property=speed”}
Number Wind_Speed2 “Windspeed [%.2f km/h]” {weather=“locationId=home, forecast=2, type=wind, property=speed”}
Number Wind_Speed3 “Windspeed [%.2f km/h]” {weather=“locationId=home, forecast=3, type=wind, property=speed”}
Number Wind_Speed4 “Windspeed [%.2f km/h]” {weather=“locationId=home, forecast=4, type=wind, property=speed”}
Number Wind_Speed5 “Windspeed [%.2f km/h]” {weather=“locationId=home, forecast=5, type=wind, property=speed”}
Number Wind_Speed6 “Windspeed [%.2f km/h]” {weather=“locationId=home, forecast=6, type=wind, property=speed”}

String Weather_Condition0 “Pogoda [%s]” (Weather) {weather=“locationId=home, type=condition, property=commonId”}
String Weather_Condition6 “Pogoda [%s]” (Weather) {weather=“locationId=home, forecast=6, type=condition, property=commonId”}
String Weather_Condition2 “Pogoda [%s]” (Weather) {weather=“locationId=home, forecast=2, type=condition, property=commonId”}
String Weather_Condition1 “Pogoda [%s]” (Weather) {weather=“locationId=home, forecast=1, type=condition, property=commonId”}
String Weather_Condition3 “Pogoda [%s]” (Weather) {weather=“locationId=home, forecast=3, type=condition, property=commonId”}
String Weather_Condition4 “Pogoda [%s]” (Weather) {weather=“locationId=home, forecast=4, type=condition, property=commonId”}
String Weather_Condition5 “Pogoda [%s]” (Weather) {weather=“locationId=home, forecast=5, type=condition, property=commonId”}

DateTime Day0

String Day3 “Pogoda [MAP(day.map):%s]”
String Day4 “Pogoda [MAP(day.map):%s]”
String Day5 “Pogoda [MAP(day.map):%s]”
String Day6 “Pogoda [MAP(day.map):%s]”

String Today “aujourd’hui [MAP(day.map):%s]”
String Tomorrow “demain [MAP(day.map):%s]”
String DayAfterTomorrow “après-demain [MAP(day.map):%s]”

p.s sorry it’s in French

Hi Guys…

I dont know about anyone else, but I had an extremely rough time with all the different weather condition possibilities that WeatherUnderground came back with. So I did some pseudo items for the icon, and a map file. I attached my map, and I did this for each icon:

String WB_ConditionIcon “Condition Icon [%s]” (Weather, WeatherDisplay)
String WB_1ConditionIcon “Condition Icon 1d [%s]” (Weather, WeatherDisplay)
String WB_2ConditionIcon “Condition Icon 2d [%s]”

and simplified my html to this:

Now I just maintain the map file. I have a hidden screen off the main screen that displays all group items weather, then I just look to see what the icon says and modify the map files.

weathercond.map.json (863 Bytes)
(I renamed it .json because .map not authorized…take the .json off)

and of course, the quick rule:
rule “Weather String Substitutions”
when
Item WB_Condition received update
then
logInfo(“rules”, “rules - mapping conditions: “+(String::format(”%s”,WB_Condition.state)).toLowerCase );
postUpdate(WB_ConditionIcon,transform(“MAP”,“weathercond.map”,(String::format("%s",WB_Condition.state)).toLowerCase ))
postUpdate(WB_1ConditionIcon,transform(“MAP”,“weathercond.map”,(String::format("%s",WB_1Condition.state)).toLowerCase ))
postUpdate(WB_2ConditionIcon,transform(“MAP”,“weathercond.map”,(String::format("%s",WB_2Condition.state)).toLowerCase ))

end

Hope it helps someone…

BTW, I saw someone that did a lower bar like I did:


how do you get it closer to the bottom, and is there any way to get more resolution for the widgets/items? They are like 1" tall, 2" tall are the choices, is there any way to go in between so I can better use the space?

Thanks for everyones great work on this!

@Dominic_Bonneau Great work! I am struggling a litle bit to make it work thou.

How do you get the day of the week? Do you have some rules with jodatime now.getDayOfWeek() ??

Can you share the day.map file please?
Thanks

There is a semi-hidden option for this - currently labeled as “advanced / experimental” because it hasn’t been fully tested. In the home screen switch to edit mode then click on the “gears” icons in your dashboard’s tile. Go to the “Advanced” tab then try increasing the “Nb. of columns” option (above 12, the default).

Like I said it’s in french but here is my day.map

lundi=Lundi
mardi=Mardi
mercredi=Mercredi
jeudi=Jeudi
vendredi=Vendredi
samedi=Samedi
dimanche=Dimanche

Monday=Lundi
Tuesday=Mardi
Wednesday=Mercredi
Thursday=Jeudi
Friday=Vendredi
Saturday=Samedi
Sunday=Dimanche

And how do you get it? Do you get the actual day with a rule?
Thanks.

YES ! sorry it’s an old setup and it’s working so I never touch it again and I didn’t remember how it was setup

import java.text.DateFormat
import java.text.SimpleDateFormat
import java.util.Calendar

rule SetDay
when
System started or
Time is midnight

then
Day0.postUpdate(new DateTimeType())

var Calendar cal = Calendar::instance
var DateFormat fmt = new SimpleDateFormat(“EEEE”)
var String todayString = fmt.format(cal.time)
Today.postUpdate(todayString)
logInfo(“SetDay”,"Today is " + todayString)

cal.add(Calendar::DAY_OF_YEAR, 1)
var String tomorrowString = fmt.format(cal.time)
Tomorrow.postUpdate(tomorrowString)
logInfo(“SetDay”,"Tomorrow is " + tomorrowString)

cal.add(Calendar::DAY_OF_YEAR, 1)
var String dayAfterString = fmt.format(cal.time)
DayAfterTomorrow.postUpdate(dayAfterString)
logInfo(“SetDay”,"Day After is " + dayAfterString)

cal.add(Calendar::DAY_OF_YEAR, 1)

var String Day3String = fmt.format(cal.time)
Day3.postUpdate(Day3String)
logInfo(“SetDay”,"Day3 is " + dayAfterString)

  cal.add(Calendar::DAY_OF_YEAR, 1)

var String Day4String = fmt.format(cal.time)
Day4.postUpdate(Day4String)
logInfo(“SetDay”,"Day3 is " + dayAfterString)

  cal.add(Calendar::DAY_OF_YEAR, 1)

var String Day5String = fmt.format(cal.time)
Day5.postUpdate(Day5String)
logInfo(“SetDay”,"Day5 is " + dayAfterString)

  cal.add(Calendar::DAY_OF_YEAR, 1)

var String Day6String = fmt.format(cal.time)
Day6.postUpdate(Day6String)
logInfo(“SetDay”,"Day6 is " + dayAfterString)

end

P.s I don’t understand this code … I just know that it work …