Custom widget: Current Weather

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)

…and the widget cut off, so here it is with a .json extensioon.

weatherbar.json (1.2 KB)

Thanks so much!
Worked great:

Again, you have done such a great job with this. It was the perfect thing to replace the old geek dashboard, which I always loved the way it had the weather at the bottom. It’s incredible how flexible this thing has become!

1 Like

Hey

I tried your widget and I didn’t get anywhere especially the conditions


I’m using Openhab2 on Ubuntu 16.04

Please Help

your weather.cfg file shows all lines commented out.

1 Like

Hey all,

this widget is nice! I need help to make this Widget linking to my Weather Dashboard. Can you help me and give me the code i have to add?

Thank you!

Hello again,

Um…
I’m almost done with the widget but I’m having trouble with “Preview Widget”,I’m not sure if someone has/had a similar problem, But would appreciate your Help

Nice work! Your widget works flawlessly :slight_smile: I had to figure out to install the map transformation service and then voila

Off topic but may I ask what software you use to record the screen gif?

Cheers,

Craig

Hey Craig, I use a great LICECap to record the screen gifs.
Best regards,
Kuba

1 Like

That’s a very useful utility Many thanks :slight_smile:

Hey Again, Um

Today I upgraded to Openhab 2.1 on Ubuntu and after I did the upgrade,the climacons stopped rendering

And When I check the openhab.log file there is no hint of the cimacons having an issue…Help please