Open Weather Map

*** All changes through 04/24/24 are included in the plugins attached to this post ***

*** Only the versions ending in “3_0” will work after June 2024 ***

*** OpenWeatherMap is retiring version 2.5 in June 2024. I have made the changes to the plugin but you will need to get a new API key. They require you to put a credit card on file and will give you the first 1,000 api calls per day for free, then charge you for subsequent api calls. You can put an api call limit in your settings, so if you limit them to 1,000, then you should never get charged. Get your new API key and update it in this new plugin. After you sign up, it can take up to 24 hours for it to take effect. Here’s the link describing the transition from 2.5 to 3.0: How to transfer from One Call API 2.5 to the One Call API 3.0 - OpenWeatherMap ***




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

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 “WeatherId” 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: Weather Conditions - OpenWeatherMap

OLD 2.5 Fahrenheit: openweathermap_weatheridfix.plugin (8.9 KB)

OLD 2.5 Celsius: openweathermap_weatheridfix_metric.plugin (8.9 KB)

*** Update 04/24/24: OpenWeatherMap is retiring API version 2.5 which the two above plugins run on. Here’s the link describing the transition from 2.5 to 3.0: How to transfer from One Call API 2.5 to the One Call API 3.0 - OpenWeatherMap

Fahrenheit 3.0: openweathermap_weatheridfix_3_0.plugin (8.9 KB)

Celsius 3.0: openweathermap_weatheridfix_metric_3_0.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!

Hi, I am now also trying to integrate a weather information in my home page.
I did own an older darksky API key and I thus used the darksky plugin.
So far so good, I can get all the information related to my location.
But since I am living in France, I changed the units indication to si, meaning metric units.
The point is that wind speed shows as MPH whereas I would like to get it in kmh.
How would I proceed to change the displayed unit?
Thanks,
Daniel

It currently is not possible to override the units for certain attributes in a Plugin. I know this is something that is needed & is definitely coming.

For the time being you have a few options:

  • In your XAML pages, use the unitless value & then manually add your kmh units to it. Appending “.Value” to any device binding will give you the unitless value. For example, bind your Label’s Text property to @Device.Wind.Value

  • In the plugin, create a new attribute. Call it WindSpeedKMH or something like that. Replace all of the Wind references in the plugin with your new attribute WindSpeedKMH.

Thanks, this made it. I used the unitless value and appended a label with the unit.
Thanks,

Daniel

Tile Problem - Bug or Function?

For my Android tablet, I have created an OpenWeather app, and there is an area (1280X400 dpi) that is intended for a Tile with a weekly forecast.

I therefore created my Tile 394x179 dpi for 7 pcs would fit in that area. But as the picture shows, it only fits 5 weather tiles.
I need to reduce the size by ~ 0.75 to 296x132 dpi for them to display correctly.
Is it a bug, or have I done something wrong?

Screenshot from my Tablet with truncated Tiles

Screenshot from Designer with Tile 394x179 dpi

Screenshot from my Tablet with reduced dimensions

The Home Remote’s sizes are not necessarily DPI. If it’s an Android tablet, it’s DP pixels we want. There’s an app called “Screen Size” you can install to find those values.

Many thanks for the information, for this I did not know.
The manufacturer states the resolution 800x1280, which I used, but in Designer it should in my case be 600x962.
So now the layout is absolutely perfect!
I like Home Remote more and more, and it’s time to shut down ImperiHome!

1 Like

I would like to change the units to European values. Is it easy to do?
I assume that I need to change something in the script, but not sure.
Thank you.

Which attributes in particular are you wanting to change? I think the plugin uses a generic degree symbol (°) for temperatures.

If there are some that you would like to override you can make the change on your XAML page rather than change the plugin. The raw unitless value for most attributes can be accessed by appending a “.Unit” to your bindings {Binding @Device.Temperature.Value}.