Closed MarkHofmann11 closed 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.
Great, thanks for letting me know. I'll test this out over the weekend! Thanks!!!
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
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!
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
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!
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. :)
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.
Here are the changes.
set_property('Current.Pressure' , str(data['observations'][0]['metric']['pressure']) + ' inHg')
set_property('Current.Pressure' , str(MBtoINHG(data['observations'][0]['metric']['pressure'])) + ' inHg')
set_property('Current.WindChill' , str(data['observations'][0]['metric']['windChill']) + TEMPUNIT)
set_property('Current.WindChill' , str(CELSIUStoFAHR(data['observations'][0]['metric']['windChill'])) + TEMPUNIT)
def MBtoINHG(pressure): if pressure is None: return 'na' pressure = pressure * 0.02953 return str(round(pressure, 2))
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
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!!!
commit 6342893 closes #1
corrected pressure, precipRate, heatIndex and windChill conversions (skin dependent properties)
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!