Custom widget: Current Weather

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 …

Thanks Dominic, I’ll take a look at it. Shouldn’t be difficult.

Regards.

Hi Dominic,

thanks a lot. That was actually what I was looking for. It looks much better now on my forcast:

my items are:

String Weather_Formatted_Condition0  "Wetter: [MAP(weather_de.map):%s]" {weather="locationId=home, type=condition, property=commonId"}
String Weather_Formatted_Condition1  "Wetter: [MAP(weather_de.map):%s]" {weather="locationId=home, forecast=1, type=condition, property=commonId"}
String Weather_Formatted_Condition2  "Wetter: [MAP(weather_de.map):%s]" {weather="locationId=home, forecast=2, type=condition, property=commonId"}
String Weather_Formatted_Condition3  "Wetter: [MAP(weather_de.map):%s]" {weather="locationId=home, forecast=3, type=condition, property=commonId"}
String Weather_Formatted_Condition4  "Wetter: [MAP(weather_de.map):%s]" {weather="locationId=home, forecast=4, type=condition, property=commonId"}
String Weather_Formatted_Condition5  "Wetter: [MAP(weather_de.map):%s]" {weather="locationId=home, forecast=5, type=condition, property=commonId"}
String Weather_Formatted_Condition6  "Wetter: [MAP(weather_de.map):%s]" {weather="locationId=home, forecast=6, type=condition, property=commonId"}

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 "Wetter: Pogoda [%s]" {weather="locationId=home, type=condition, property=commonId"}
String Weather_Condition6 "Wetter: [%s]" {weather="locationId=home, forecast=6, type=condition, property=commonId"}
String Weather_Condition2 "Wetter: [%s]" {weather="locationId=home, forecast=2, type=condition, property=commonId"}
String Weather_Condition1 "Wetter: [%s]" {weather="locationId=home, forecast=1, type=condition, property=commonId"}
String Weather_Condition3 "Wetter: [%s]" {weather="locationId=home, forecast=3, type=condition, property=commonId"}
String Weather_Condition4 "Wetter: [%s]" {weather="locationId=home, forecast=4, type=condition, property=commonId"}
String Weather_Condition5 "Wetter: [%s]" {weather="locationId=home, forecast=5, type=condition, property=commonId"}

DateTime Day0
String Today 			"Heute: [MAP(day.map):%s]"
String Tomorrow 		"Morgen: [MAP(day.map):%s]"
String DayAfterTomorrow "Übermorgen: [MAP(day.map):%s]"
String Day3  			"4.Tag: [MAP(day.map):%s]"
String Day4  			"5.Tag: [MAP(day.map):%s]"
String Day5   			"6.Tag: [MAP(day.map):%s]"
String Day6     		"7.Tag: [MAP(day.map):%s]"

my day.map contains…

Sunday=Sonntag
Monday=Montag
Tuesday=Dienstag
Wednesday=Mittwoch
Thursday=Donnerstag
Friday=Freitag
Saturday=Samstag

…and my weather_de.map contains:

thunder=Gewitter
storm=Sturm
rain-and-snow=Regen und Schnee
rain-and-sleet=Regen und Schneeregen
snow-and-sleet=Schnee und Schneeregen
freezing-drizzle=gefrierender Niessel
few-showers=wenige Schauer
freezing-rain=gefrierender Regen
rain=Regen
snow-flurries=Sneeuwvlagen
light-snow=leichter Schnee
blowing-snow=Schneetreiben
snow=Schnee
sleet=Schneeregen
dust=Staubig
fog=Nebel
wind=Wind
cold=Kalt
cloudy=Bewölkt
mostly-cloudy-night=Bewölkte Nacht
mostly-cloudy-day=Bewölkter Tag
partly-cloudy-night=Leicht bewölkte Nacht
partly-cloudy-day=Leicht bewölkter Tag
clear-night=Klare Nacht
sunny=Sonnig
hot=Warm
scattered-thunder=vereinzelte Gewitter
scattered-showers=vereinzelte Schauer
thundershowers=Gewitterschauer
snow-showers=Schneeschauer
scattered-thundershower=vereinzelte Gewitterschauer
unknown=Unbekannt

Do you have any idea, why my mappings in day.map and weather_de.map do not work?
Or why the wind speed is always UNDEF (I’m using yahoo weather)
or how to change text color?

Thanks a lot.

BR
Matthias

1 Like

Hi @Matt_Hiass. I am having the same issue.

Please let me know if you solve it.

Wouldn’t be nice if Current Weather widget was clickable and by touching it, get forwarded to Forecast Dashboard where Forecast widget is displayed?

Something like Button widget functionality:

Does anyone knows how to get this done?
Thanks, regards.

Yes I did it, you just need to add a alink at the beginning

Hi…

For the day, it’s simply:

<td>{{itemValue('WB_1ObservationTime') | date:'EEEE'}}</td>

No Map needed for me. If you want my whole widget:

<td>{{itemValue('WB_1ObservationTime') | date:'EEEE'}}</td>
<td><img

src="{{ServerPath}}/images/{{IconSet}}/{{itemValue(‘WB_1ConditionIcon’)}}.png"/>


<td>{{itemValue('WB_2ObservationTime') | date:'EEEE'}}</td>
<td><img

src="{{ServerPath}}/images/{{IconSet}}/{{itemValue(‘WB_2ConditionIcon’)}}.png"/>


Today {{itemValue('WB_Condition')}}

{{'%.0f' | sprintf:itemValue('WB_Temp_Max_F')}}/{{'%.0f' | sprintf:itemValue('WB_Temp_Min_F')}}°F

{{itemValue(‘WB_1Condition’)}}

{{’%.0f’ |
sprintf:itemValue(‘WB_1Temp_Max_F’)}}/{{’%.0f’ |
sprintf:itemValue(‘WB_1Temp_Min_F’)}}°F

{{itemValue(‘WB_2Condition’)}}

{{’%.0f’ |
sprintf:itemValue(‘WB_2Temp_Max_F’)}}/{{’%.0f’ |
sprintf:itemValue(‘WB_2Temp_Min_F’)}}°F

Here is my map(updated since my last post…there was alot missing, and may
still need more, but you get the idea how to fix that. Take the .json off
the end.

Thank you everyone for the help!

weathercond.map.json (1.03 KB)