cytech / weather.wundergroundpws

A Kodi weather addon for Weather Underground personal weather station users
GNU General Public License v2.0
4 stars 0 forks source link

Imperial Units? #1

Closed MarkHofmann11 closed 5 years ago

MarkHofmann11 commented 5 years ago

Very happy to see you wrote a Weather Underground script for Kodi for us that have a PWS/API. Was wondering if this has support for imperial units? I saw the code and it appeared to me metric units only, but I'm not an expert to say for sure.

Any chance in adding imperial support if it isn't already included?

Thanks!

cytech commented 5 years ago

With Kodi, the weather units are displayed based on the Kodi region setting. So the addon code has to return metric, then Kodi handles the display units. i.e. region is US, units are imperial. at least thats what the docs claimed.. I cannibalized this code from the old wunderground addon to work with the new API.

MarkHofmann11 commented 5 years ago

Great, thanks for letting me know. I'll test this out over the weekend! Thanks!!!

cytech commented 5 years ago

great. hope it works for you, I have run it here for a month or so without problems. Just remember the new weaher company api for PWS users is extremely limited compared to the old weatherunderground api. So all the addon shows is your PWS current data and 5 day forecast for lat/lon. thanx

MarkHofmann11 commented 5 years ago

Just tested - only issue I'm having with imperial units are for the "Pressure" and "WindChill". They are listing "inHg" and "F", but displaying metric data. Hopefully the attached image I inserted below will display what I mean.

Everything else looks great! I tried to figure out how to change the code to get those values correct but so far, so luck. The API can be called using "e" for units - and tried that approach, but then the temp was "F" converted to "F" (way too high of a number). Just have not figured out how the best way to handle this yet.

Any ideas welcome. Thanks!

Capture

cytech commented 5 years ago

hmm, I only tried it on the Kodi default skin, which doesn't show pressure and windchill. what skin are you using? i"ll try to look at it later this week

MarkHofmann11 commented 5 years ago

The skin is "Transparency!". I thought changing the API to use "e" for units would solve things, but Kodi expects the original data to be metric from what I can tell. Not sure where the "temp" value gets converted to F, but that works. Just not WindChill and the Pressure isn't showing inHg numeric values. I'm wondering if "Precipitation" is also effected, but don't have any here at the moment to investigate.

Thanks for checking!

MarkHofmann11 commented 5 years ago

Just pushed the fix - Imperial units for Wind Chill and Pressure. Added a function in utilities to handle the conversion and used an existing function to handle wind chill. Works great over here! Will check if something is needed on precip once I have precip to check. :)

MarkHofmann11 commented 5 years ago

Seems I don't have access to push the changes. I'm not a GitHub expert, but I can send the changes once there is a way to do it.

MarkHofmann11 commented 5 years ago

Here are the changes.

default.py

utilities.py (under resources\lib)

def MBtoINHG(pressure): if pressure is None: return 'na' pressure = pressure * 0.02953 return str(round(pressure, 2))

MarkHofmann11 commented 5 years ago

Capture

cytech commented 5 years ago

you can't push to my repo unless I allow it. normally you fork the repo, make changes to the fork, and issue a pull request. Your changes will work for imperial users but will cause issues for metric. I need to look again at what Kodi converts compared to "extras" contained in different skins. Keep your changes so that your station works and I will try and look at it later this week. thanx

MarkHofmann11 commented 5 years ago

Ok, will wait to hear back. The changes I made shouldn't break the metric support, as I only changed the sections where the "tempunit" was "F". I left the metric section in tact for the routines (doesn't show that above due to how I posted the changes). After looking later this week if you want me to fork the repo and send changes to the fork, just let me know. Thank you!!!

cytech commented 5 years ago

commit 6342893 closes #1

cytech commented 5 years ago

corrected pressure, precipRate, heatIndex and windChill conversions (skin dependent properties)