-
Notifications
You must be signed in to change notification settings - Fork 13
122 QST Weather current and forecast
Version 0.3.9 the QST weather is now based on openweathermap.org APIs for current and forecasts. Starting with 0.3.9 alpha, D-Rats includes an initial substitution of the QST weather API. The alpha has removed the outdated API of Weather Underground while introducing the API for OpenWeatherMap.
In order to use this new feature you have to get your own API key from OpenWeatherMap by signing up for a free account and verifying the account with the email that openweathermap sends to you.
https://openweathermap.org/api is where you get the free api key after you sign up.
Then, insert the api key
in Preferences->Chat->OpenWeather appid and Save
The OpenWeather uri is left as the default of https://api.openweathermap.org/data/2.5/
Next, go into the Chat window, click the "+" next to "QSTs", then click "Add".
A small dialog box will pop up. Use the down arrow next to the word "Text" to navigate to OpenWeather.
Once OpenWeather is selected, you can set up the weather QST with 2 options:
- “Current” will query openweathermap and provide the current weather in a location (Sparta, in the example below)
- “Forecast” will query openweathermap and provide the weather forecasts for the next 5 days. This creates a lot of text. So, please use the forecast feature sparingly.
If you have weather QSTs using Weather Underground in the config file then please remove them. Use the QST remove feature and then check the config file to make sure Weather Underground QSTs DO NOT
exist in the config file. See next paragraph for instructions on how to manually delete the Weather Underground QSTs.
The config file is located in a folder named C:\Users\"Your_Name"\AppData\Roaming\D-RATS-EV
where "Your_Name"
is the user name Windows uses for your PC. Use Windows File Explorer to find and open the folder. The config file, in the folder, is named d-rats.config
. Edit the file with an editor such as Notepad (right-click--Open With--More Apps--Notepad). Find the QSTs (usually near the bottom of the config file) and select the text containing reference to Weather Underground QSTs and then delete the text. Save the file. Restart D-Rats and check for correct operation.
When you have created the location request, pay attention to the location reported. Make sure it is the one that you expect by checking its coordinates in the resulting weather text!
In the US there are many cities with the same exact name in different states.
In the US, the state can be added to provide more accurate location using City,State_code,US. Other countries can use the format City,Country_code.
For Example:
Using "Sparta,GR" output will be:
[10:27:03] [My RAT flector (on localhost)] IZ2LXI-L: [QST] Current weather at Sparta - GR lat: 37.08 Lon: 22.43
Conditions: scattered clouds
Current Temperature: 23.03 C (73.18 F)
Minimum Temperature: 22.93 C (73.00 F)
Maximum Temperature: 23.15 C (73.40 F)
Humidity: 56 %
Pressure: 1015 hpa
Wind Speed: 3.60 km/hr
Using "Sparta,MI,US" output will be:
[10:26:29] [My RAT flector (on localhost)] IZ2LXI-L: [QST] Current weather at Sparta - US lat: 43.16 Lon: -85.71
Conditions: overcast clouds
Current Temperature: 14.14 C (57.18 F)
Minimum Temperature: 13.48 C (55.99 F)
Maximum Temperature: 15.15 C (59.00 F)
Humidity: 89 %
Pressure: 1017 hpa
Wind Speed: 2.51 km/hr
Notes from Glen Streker: The openweathermap function kept returning an SSL Certificate Validation Failed error in the debug.log and would not display the weather information.
Solution:
- In the Cordana search bar type "Internet Options".
- When it comes up, go to the Security section and make sure "Use SSL 3.0" is checked.
- Then go into D-Rats Preferences, Chat, and remove the "https://" on the openweathermap.org URL and replace with "http://"; with the "s" removed.
- Reboot the system and reload.
- Under QSTs create an OpenWeather QST. You must use the format "city name,state,country in order for it to work properly.
- Be aware if calling for forecasts instead of the current weather condition the returned amount of text will be extensive.
To get data in API for both current weather and forecast in Fahrenheit just add units=imperial parameter into your API call like in this example:
Sparta,MI,US&units=Imperial
So, a full weather query will look like this (add your own api key):
https://api.openweathermap.org/data/2.5/weather?q=Sparta,MI,US&units=Imperial&appid=xxxx_api_key_goes_here_xxxx
This call works on the web.
However, this feature does not appear to work with the D-Rats program. To get the QST to add the units request, simply add "&units=Imperial" after the City,State,Country in the QST text. This seems like it would work, however, the URI that gets sent to Openweathermap includes percent encoded non-ascii characters.
For example:
https://api.openweathermap.org/data/2.5/weather?q=Sparta%2CMI%2CUS%26units%3Dimperial&appid=xxxx_api_key_goes_here_xxxx
is sent by D-Rats results in default metric data when using a browser,
While:
https://api.openweathermap.org/data/2.5/weather?q=Sparta,MI,US&units=imperial&appid=xxxx_apikey_goes_here_xxxx
typed by hand in a browser results in the correct imperial data.
D-Rats converts temperature in the Weather QST. The units of pressure (hpa - HectoPacals - milliBars) and wind velocity (km/hr - Kilometers per Hour) are provided in metric units. Hand conversion is possible by multiplying the metric unit by the conversion factor for each unit.
The conversion factors are:
1 hpa equals 0.02953 inches of mercury (inHg)
1 km/hr equals 0.539957 knots (kn - nautical miles per hour)
Here is a table of barometric pressure conversions (hpa-mb):
Here is a conversion ruler of km/h to knots:
If after invoking openweather you see in on your debug.log file the following error:
IOError: [Errno socket error] [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)
you can force the use of http instead of from https: got to file->preferences->CHAT Edit the openweather uri changing http:// into http://
In my case, on Windows 10, it works in both cased (with and without the s)
Edited 20211001