Open Weather Map

OpenWeatherMap plugin built as a replacement for the DarkSky plugin. It will work out of the box with a few notes:

Get your free API Key here: https://openweathermap.org/appid

Alerts do not work

Items not available:
current precipitation rate
current precipitation probability
current precipitation type
current wind gust
daily precipitation rate
daily precipitation type
daily wind gust

The WeatherIcon attribute should now be used as a web image

There is an additional attribute “Id” that will return a 3 digit code for various weather conditions. You can use this if you want to use your own icons. You can see the codes here: https://openweathermap.org/weather-conditions

openweathermap.plugin (8.9 KB)

4 Likes

I can’t figure out how to create a template for forecast. Can you share some example?

DarkSky_Weather.hrp (2.8 MB)

tnx. Do you know why no icon are associated to forecast ( cloud, rain etc)?

The WeatherIcon attribute should now be used as a web image.

Sorry, it’s not clear to me how to use it, or what i have to put in source properties

Sure, this is sort of an odd project as it was meant to replace a previous plugin. If you click on the ForecastDayTile.xaml, you’ll see the IconElement that shows the daily weather icon. Note that the binding is @Device.WeatherIcon. You’ll just reference this same binding in a WebImage. First, write down the layout info for the IconElement (column, row, height, margin, etc). Delete the IconElement. Now create the WebImage and enter in the same layout details. Now put the @Device.WeatherIcon binding in the Source field and you should be done.

Tnx, done and working. But i have another issue. Do you have any idea why eveything is working for the current day but i have to reload the application next day? To be clear:
i have a page with 7 days forecast. I have 7 tile for example today from wed to tue. Tomorrow i’ll find on tablet or the same tiles or 7 empty tiles.
Sorry if question is not clear but my english is really poor

Sorry, it looks like it was polling too often so OpenWeatherMap was likely denying your API calls. Change line 8 in the plugin to 300000, or you can download the plugin again, I have updated it. After you do this, you might need to wait up to 24 hours for your API calls to refresh.

I think I am having the same issue as gggizmo, I have a tablet that sits with the screen on all day every day, when I look at it the next day the day tiles are empty. If I reload the app the tiles show up correctly. If I refresh the device via “App.RefreshDevice(“OpenWeatherMap”);” it also causes the tiles to go blank.

Adding some debug into the script via consol.write I can see that the dayData seems to be correct, but it is not assigned correctly to dayDevice.
Code:
console.log("day of week: " + convertUnixTimeToDayOfWeek(dayData.dt));
dayDevice.DayOfWeek = convertUnixTimeToDayOfWeek(dayData.dt);
console.log("day Device day of week: " + dayDevice.DayOfWeek);
Output:
day of week: Tuesday
day Device day of week: null

Before and after pictures:

Try the revised script.
openweathermap_weatheridfix.plugin (8.9 KB)

It was lines 61, 101, & 125 that was breaking it. Those were overwriting the device object Id. That is reserved & should not be written to in a plugin. I changed the Id attribute that was being used to WeatherId. Everything should work again once you load the new script.

Old

currentlyDevice.Id = currently.weather[0].id;
dayDevice.Id= dayData.weather[0].id;
dayDevice.Id= null;

New

currentlyDevice.WeatherId = currently.weather[0].id;
dayDevice.WeatherId= dayData.weather[0].id;
dayDevice.WeatherId = null;
1 Like

That fixed it in the simulator, if I run into issues on the device I will let you know!

Thanks for the quick fix!