It is currently June 15th, 2024, 8:08 am

Custom weather plugin

Share and get help with Plugins and Addons
cperryoh
Posts: 10
Joined: May 22nd, 2022, 10:38 pm

Custom weather plugin

Post by cperryoh »

Hello, I originally posted this on the Rainmeter subreddit but a commenter told me to come here as it could reach more people that might use it. Anyways, I got Rainmeter a few years back and I have always kind of noticed that every premade skin with weather is using an old and broken API. I decided to spend a few hours writing up a plugin that uses the free API https://openweathermap.org/ it allows for 60 calls a min and provides substantial information to replace the API in most older skins. There are two ways I have programmed it to be used.

First, you can make a measure for a particular piece of data you want to grab. The ones I have set up so far are temp(or current temp), temp_min, temp_max, humidity, condition, and description. So if I wanted to create a measure that kept track of current temperature and let's say longitude 50 and latitude 50, the measure would look like this.

Code: Select all

[currentTempature]
Measure=Plugin
Plugin=WeatherApiPlugin.dll
key=*your openweather API key here*
longitude=50
latitude=50
type=temp
#Other options: temp_min, temp_max, humidity, condition, description
It can also be used with a custom function I wrote into the plugin, it includes all the options for data listed above with two others that I will explain later. I made it this way as well for 2 reasons. (1) I figured out that when making a measure for every piece of data you want to access(temp, temp_min, temp_max, etc) it will run a separate instance of the plugin, therefore, making more API calls and possibly temporarily locking you out of the API. I could've solved this by slowing the update of my skin, but that felt a bit hacky. Using the getValue function and dynamic variables makes only one instance but still allows you to access all the data the plugin has access to. (2) I am lazy and one plugin is easier to keep track of. Now as for the other two parameters that this method has access to. They are icon and iconUrl. 'icon' is the icon id for the weather status outside and iconUrl is a URL to that icon hosted by OpenWeatherMap. The icons for OpenWeatherMap icons follow a format of <iconId>2x.png. I added access to both of these so you could have an image sourcing from the web or store the icons locally and access them from the Resources folder. Personally, I could not get dynamic variables working with the web parser plugin, so I could not grab an icon based on the icon URL variable. I opted for downloading all the icons using a google extension from open weather API and accessing them locally using the icon parameter.

Code: Select all

[weatherApi]
Measure=Plugin
Plugin=WeatherApiPlugin.dll
key=*your openweather API key here*
longitude=50
latitude=50

[Meter Current tempature]
Meter=String
DynamicVaribles=1
X=0
Y=0
FontColor=255,255,255,255
FontFace=Segoe UI
FontSize=17
StringEffect=Shadow
FontEffectColor=0,0,0,255
AntiAlias=1
Text=The temperature out side is: [weatherApi:getValue(temp)]
#Other options: temp_min, temp_max, humidity, condition, description, icon, iconUrl
I am aware that there are other ways of going about fixing these old skins(like this tutorial), but frankly parsing Jsons and web scraping in Rainmeter does not make sense to me and this, in my opinion, is a much more elegant way of doing the same thing. Although I do not know if anyone has done anything similar to this in the past. I will link the GitHub to the plugin below, it also has a copy of the popular skin Simplic with that was modified to use the plugin. Also, in the resources folder of the skin, all the icons for open weather API are in there. I originally was making this as a side project but I figured to make this post to offer people an alternative to other methods of fixing weather skins. This is in no way polished or documented yet, I made this in the past 2 days so it is still a bit rough around the edges, but it works. I would love to hear what you guys think and maybe features that I could add πŸ™‚ .



Github: https://github.com/cperryoh/Rainmeter-weather-api-plugin

Icons: https://github.com/cperryoh/Rainmeter-weather-api-plugin/tree/main/C%23/WeatherPlugin/MySimplic/%40Resources/WeatherIcons

Skin: https://github.com/cperryoh/Rainmeter-weather-api-plugin/tree/main/MySimplic

Final Product: https://imgur.com/a/ih1hKRm

Example skin credit: https://www.deviantart.com/lostskinscollection/art/Simplic-by-Hiphopium-905984362

Wallpaper engine wallpaper: https://steamcommunity.com/sharedfiles/filedetails/?id=1887571248
User avatar
balala
Rainmeter Sage
Posts: 16305
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Custom weather plugin

Post by balala »

Would be an interesting plugin, but where can it be downloaded? The GitHub link (In the Skin line) is broken, clicking it leads to a "This is not the web page you are looking for" message. The skin downloaded from DeviantArt (the Example skin credit line), doesn't contain the plugin. So please post a complete package with and example skin and the plugin.
User avatar
ikarus1969
Posts: 575
Joined: February 28th, 2011, 3:20 pm
Location: Vienna, Austria

Re: Custom weather plugin

Post by ikarus1969 »

User avatar
balala
Rainmeter Sage
Posts: 16305
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Custom weather plugin

Post by balala »

Yep, good catch (???), could say, but sucks. Completely useless. Both versions of a plugin are required in order to can use it. Not telling that I couldn't download even the 64-bit version. :(
User avatar
ikarus1969
Posts: 575
Joined: February 28th, 2011, 3:20 pm
Location: Vienna, Austria

Re: Custom weather plugin

Post by ikarus1969 »

balala wrote: ↑March 4th, 2023, 7:29 pm Yep, good catch (???), could say, but sucks. Completely useless. Both versions of a plugin are required in order to can use it. Not telling that I couldn't download even the 64-bit version. :(
You might be right, but at least the dll can be downloaded: click on the 2nd link, click on the dll (left mouse button) and then on the "Download" button.
I won't try it out (i'm completely satisfied with weather.com) but in case you or someone else will play with it.
Screenshot DLL.jpg
You do not have the required permissions to view the files attached to this post.
User avatar
balala
Rainmeter Sage
Posts: 16305
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Custom weather plugin

Post by balala »

ikarus1969 wrote: ↑March 5th, 2023, 7:46 am You might be right, but at least the dll can be downloaded: click on the 2nd link, click on the dll (left mouse button) and then on the "Download" button.
Right. Thanks.
ikarus1969 wrote: ↑March 5th, 2023, 7:46 am I won't try it out (i'm completely satisfied with weather.com) but in case you or someone else will play with it.
I also am satisfied for now, weather.com perfectly works. Now. But same way as wxdata has been deprecated form one day to another, who knows what will come? So, worth saving the plugin, just in case...
User avatar
Yincognito
Rainmeter Sage
Posts: 7428
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Custom weather plugin

Post by Yincognito »

balala wrote: ↑March 4th, 2023, 7:29 pmBoth versions of a plugin are required in order to can use it. Not telling that I couldn't download even the 64-bit version. :(
To use a plugin, you only need the version corresponding to your architecture, not both. You can easily see that by examining the C:\Users\[UserName]\AppData\Roaming\Rainmeter\Plugins folder or its equivalent on your system, where only those versions are actually used (or copied there) by Rainmeter, and listed as such in the About/Plugins tab. Sure, for the sake of completeness, both versions (32bit and 64bit) are nice to have, but it's by no means technically required, unless one still has a 32bit OS (which is more and more unlikely these days, and probably the reason why the developer didn't bother to make one in the first place).

Also, I could easily download the 64bit version, so the problem probably lies in Chrome automatically producing a confirmation message to be able to download DLL files cause of the standard "they could be dangerous" warning. Didn't test it though, since the weather.com route is still the most advantageous, as you mentioned as well.
Profiles: Rainmeter Profile β—‡ DeviantArt Profile β—† Suites: MYiniMeter β—† Skins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16305
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Custom weather plugin

Post by balala »

Yincognito wrote: ↑March 27th, 2023, 3:00 pm To use a plugin, you only need the version corresponding to your architecture, not both. You can easily see that by examining the C:\Users\[UserName]\AppData\Roaming\Rainmeter\Plugins folder or its equivalent on your system, where only those versions are actually used (or copied there) by Rainmeter, and listed as such in the About/Plugins tab. Sure, for the sake of completeness, both versions (32bit and 64bit) are nice to have, but it's by no means technically required, unless one still has a 32bit OS (which is more and more unlikely these days, and probably the reason why the developer didn't bother to make one in the first place).
I know, believe me. Have tried this a few times. However what I said is that both versions are needed in order to can use it on creating a skin installer, to distribute the skin which uses the plugin.
Yincognito wrote: ↑March 27th, 2023, 3:00 pm Also, I could easily download the 64bit version, so the problem probably lies in Chrome automatically producing a confirmation message to be able to download DLL files cause of the standard "they could be dangerous" warning. Didn't test it though, since the weather.com route is still the most advantageous, as you mentioned as well.
Yep, I meantime I also succeeded in downloading the existing version. At the time I wrote that reply (almost a month ago) I didn't realize how to download it, but in meantime I did download it.
User avatar
Yincognito
Rainmeter Sage
Posts: 7428
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Custom weather plugin

Post by Yincognito »

balala wrote: ↑March 27th, 2023, 3:39 pm I know, believe me. Have tried this a few times. However what I said is that both versions are needed in order to can use it on creating a skin installer, to distribute the skin which uses the plugin.
Ah, I see what you mean now, you're right: it doesn't let you add less than both the 32bit and 64bit versions of a plugin when building the .rmskin. Apparently it reads the version info within the DLL (the way ResourceHacker does, for example), so it can't be fooled with a 0 bytes fake .dll or a 64bit version of another plugin's .dll - that's smart. Of course, this is true only if one uses the skin installer to create the skin, because otherwise someone could just pack stuff in a .zip and let the user place files / folders within where needed, and it would be functional.
balala wrote: ↑March 27th, 2023, 3:39 pm Yep, I meantime I also succeeded in downloading the existing version. At the time I wrote that reply (almost a month ago) I didn't realize how to download it, but in meantime I did download it.
You're right again, I only saw that after I posted my own reply - my bad. :oops:
Profiles: Rainmeter Profile β—‡ DeviantArt Profile β—† Suites: MYiniMeter β—† Skins: Earth
cperryoh
Posts: 10
Joined: May 22nd, 2022, 10:38 pm

Re: Custom weather plugin

Post by cperryoh »

balala wrote: ↑March 27th, 2023, 3:39 pm I know, believe me. Have tried this a few times. However what I said is that both versions are needed in order to can use it on creating a skin installer, to distribute the skin which uses the plugin.

Yep, I meantime I also succeeded in downloading the existing version. At the time I wrote that reply (almost a month ago) I didn't realize how to download it, but in meantime I did download it.
Wow. I just logged back into this account after forever, I didn't know this post got some attention. Sorry for being a bit absent, if you'd like I can try and troubleshoot what might've been the problem here. I never compiled an x32 version as I could not figure out how to configure Visual Studio for it(C# is not my first choice in languages and visual studio can be a bit clunky).

Edit: I cleaned up the repo a bit and split two plugins I wrote apart. So the weather plugin is now located here https://github.com/cperryoh/WeatherPluginRainmeter
Edit 2: i figured out how to compile x32 DLLs, those are up now in the releases section.