Skip to content

[weather.openmeteo] 1.0.14 #2749

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
20 changes: 20 additions & 0 deletions weather.openmeteo/CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
v1.0.14 (22/07/2025)
--------------------
* Added pressure units: hPa, kPa, mmHg, inHg, psi
* Adjust map download timers
* Fix geolocation loop on broken KODI devices
* Added translation: Chinese (thanks @wabisabi926)

v1.0.10 (22/05/2025)
--------------------
* Custom location names
* Use highest weather code for condition alert
* Re-download maps & layers when changing mapzoom level
* Removing locations should now work properly
* Fix 12h/24h time for weather alerts
* Added translation: Slovak (thanks @frederik877)
* Added translation: Tamil (thanks @தமிழ்நேரம்)
* Added translation: Czech (thanks @Tomas)
* Added translation: Indonesian (thanks @Nao3Line)
* Added translation: Hungarian (thanks @frodo19)

v1.0.0 (15/12/2024)
-------------------
* Official KODI repository
Expand Down
20 changes: 18 additions & 2 deletions weather.openmeteo/addon.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="weather.openmeteo" name="Open-Meteo" version="1.0.0" provider-name="OpenHT">
<addon id="weather.openmeteo" name="Open-Meteo" version="1.0.14" provider-name="OpenHT">
<requires>
<import addon="xbmc.python" version="3.0.0"/>
<import addon="script.module.requests" version="2.27.1+matrix.1"/>
Expand All @@ -10,8 +10,24 @@
<extension point="xbmc.python.weather" library="default.py"/>
<extension point="xbmc.service" library="service.py" />
<extension point="xbmc.addon.metadata">
<summary lang="cs_CZ">Predpoveď počasia z Open-Meteo</summary>
<description lang="cs_CZ">Počasie, mapy, kvalita vzduchu a pyľové údaje z open-meteo.com, rainviewer.com, weather.gc.ca a met.no</description>
<summary lang="de_DE">Wettervorhersage von Open-Meteo</summary>
<description lang="de_DE">Wetter, Karten, Luftqualität und Pollen Vorhersage von open-meteo.com, rainviewer.com, weather.gc.ca und met.no</description>
<summary lang="en_GB">Weather forecast from Open-Meteo</summary>
<description lang="en_GB">Weather, maps, airquality and pollen data from open-meteo.com, rainviewer.com, weather.gc.ca and met.no</description>
<description lang="en_GB">Weather, maps, airquality and pollen forecast from open-meteo.com, rainviewer.com, weather.gc.ca and met.no</description>
<summary lang="hu_HU">Időjárás-előrejelzés az Open-Meteo-ból</summary>
<description lang="hu_HU">Időjárás, térképek, levegőminőség és pollenelőrejelzés az open-meteo.com, a rainviewer.com, a weather.gc.ca és a met.no oldalakról</description>
<summary lang="id_ID">Prakiraan cuaca oleh Open-Meteo</summary>
<description lang="id_ID">Ramalan cuaca, peta, kualitas udara, dan serbuk sari dari open-meteo.com, rainviewer.com, weather.gc.ca dan met.no</description>
<summary lang="sk_SK">Predpoveď počasia z Open-Meteo</summary>
<description lang="sk_SK">Počasie, mapy, kvalita vzduchu a peľové údaje z open-meteo.com, rainviewer.com, weather.gc.ca a met.no</description>
<summary lang="ta_IN">திறந்த-மெட்டியோவிலிருந்து வானிலை முன்னறிவிப்பு</summary>
<description lang="ta_IN">திறந்த-மெட்டியோ.காம், ரெயின்வியூவர்.காம், வானிலை. GC.CA மற்றும் MET.NO இலிருந்து வானிலை, வரைபடங்கள், காற்றோட்டம் மற்றும் மகரந்த முன்னறிவிப்பு</description>
<summary lang="uk_UA">Прогноз погоди від Open-Meteo</summary>
<description lang="uk_UA">Прогноз погоди, мап , якість повітря та пилку від open-meteo.com, rainviewer.com, weather.gc.ca та met.no</description>
<summary lang="zh_CN">Open-Meteo 提供的天气预报</summary>
<description lang="zh_CN">天气、地图、空气质量和花粉预报来自 open-meteo.com、rainviewer.com、weather.gc.ca 和 met.no</description>
<platform>all</platform>
<license>GPL-2.0-or-later</license>
<forum>https://forum.kodi.tv/forumdisplay.php?fid=155</forum>
Expand Down
131 changes: 80 additions & 51 deletions weather.openmeteo/lib/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,22 @@ def getloc(locid):
utils.setsetting(f'loc{locid}lon', str(location["longitude"]))
utils.setsetting(f'loc{locid}tz', str(location["timezone"]))

# Clear location
def clearloc(locid, last=False):
if last:
utils.setsetting(f'loc{locid}data', '321318000')
utils.setsetting(f'loc{locid}map', '321318000')
utils.setsetting(f'loc{locid}rv', '321318000')
utils.setsetting(f'loc{locid}gc', '321318000')
else:
utils.setsetting(f'loc{locid}', '')
utils.setsetting(f'loc{locid}user', '')
utils.setsetting(f'loc{locid}alert', 'true')
utils.setsetting(f'loc{locid}utz', 'false')
utils.setsetting(f'loc{locid}tz', '')
utils.setsetting(f'loc{locid}lat', '0')
utils.setsetting(f'loc{locid}lon', '0')

# Set location
def setloc (locid):
utils.log(f'Search dialog ...')
Expand All @@ -201,57 +217,70 @@ def setloc (locid):
keyboard = xbmc.Keyboard(input, utils.loc(14024), False)
keyboard.doModal()

if (keyboard.isConfirmed() and keyboard.getText()):
if keyboard.isConfirmed():
search = keyboard.getText()

try:
locs = []
search = keyboard.getText()
url = config.map_api.get('search').format(search)
data = json.loads(geturl(url))['results']
except:
utils.log('No results found', 2)
dialog.ok('Open-meteo', utils.loc(284))
# No changes
if search == input:
utils.log(f'[LOC{locid}] No changes')

# Remove location
elif search == '':
check = utils.setting(f'loc{int(locid)+1}')

if not check:
utils.log(f'[LOC{locid}] Removed')
clearloc(locid)
clearloc(locid, True)

# Search location
else:
for item in data:
li = xbmcgui.ListItem(f'{item.get("name")}, {item.get("admin1")}, {item.get("country_code")} (Lat: {item.get("latitude")}, Lon: {item.get("longitude")})')
locs.append(li)

select = dialog.select(utils.loc(396), locs, useDetails=True)

if select != -1:

# Cleanup cache dir
dir = f'{config.addon_cache}/{locid}'
files = sorted(list(Path(dir).glob('*')))

for file in files:
os.remove(file)

# Set location
utils.log(f'Location {locid}: {data[select].get("name")}, {data[select].get("admin1")}, {data[select].get("country_code")} {data[select].get("latitude")} {data[select].get("longitude")}')
utils.setsetting(f'loc{locid}', f'{data[select].get("name")}, {data[select].get("admin1")}, {data[select].get("country_code")}')
utils.setsetting(f'loc{locid}lat', data[select]["latitude"])
utils.setsetting(f'loc{locid}lon', data[select]["longitude"])
utils.setsetting(f'loc{locid}tz', data[select]["timezone"])

# Wait for settings dialog
while xbmcgui.getCurrentWindowDialogId() == 10140:
utils.log(f'Waiting for settings dialog ...')
utils.monitor.waitForAbort(1)

if utils.monitor.abortRequested():
return

# Cleanup lastupdate
utils.setsetting(f'loc{locid}data', '321318000')
utils.setsetting(f'loc{locid}map', '321318000')
utils.setsetting(f'loc{locid}layer', '321318000')

# Refresh
if int(utils.settingrpc("weather.currentlocation")) == int(locid):
weather.Main(str(locid), mode='download')
weather.Main(str(locid), mode='update')
else:
weather.Main(str(locid), mode='download')
weather.Main(str(locid), mode='updatelocs')
try:
locs = []
url = config.map_api.get('search').format(search)
data = json.loads(geturl(url))['results']
except:
utils.log('[LOC{locid}] No results')
dialog.ok('Open-meteo', utils.loc(284))
else:
for item in data:
li = xbmcgui.ListItem(f'{item.get("name")}, {item.get("admin1")}, {item.get("country_code")} (Lat: {item.get("latitude")}, Lon: {item.get("longitude")})')
locs.append(li)

select = dialog.select(utils.loc(396), locs, useDetails=True)

if select != -1:

# Cleanup cache dir
dir = f'{config.addon_cache}/{locid}'
files = sorted(list(Path(dir).glob('*')))

for file in files:
os.remove(file)

# Set location
utils.log(f'Location {locid}: {data[select].get("name")}, {data[select].get("admin1")}, {data[select].get("country_code")} {data[select].get("latitude")} {data[select].get("longitude")}')
utils.setsetting(f'loc{locid}', f'{data[select].get("name")}, {data[select].get("admin1")}, {data[select].get("country_code")}')
utils.setsetting(f'loc{locid}lat', data[select]["latitude"])
utils.setsetting(f'loc{locid}lon', data[select]["longitude"])
utils.setsetting(f'loc{locid}tz', data[select]["timezone"])

# Wait for settings dialog
while xbmcgui.getCurrentWindowDialogId() == 10140:
utils.log(f'Waiting for settings dialog ...')
utils.monitor.waitForAbort(1)

if utils.monitor.abortRequested():
return

# Cleanup lastupdate
clearloc(locid, True)

# Refresh
if int(utils.settingrpc("weather.currentlocation")) == int(locid):
weather.Main(str(locid), mode='download')
weather.Main(str(locid), mode='update')
else:
weather.Main(str(locid), mode='download')
weather.Main(str(locid), mode='updatelocs')

9 changes: 6 additions & 3 deletions weather.openmeteo/lib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,9 @@
# Mapping (Rainviewer)
map_rvradar = [ 'radar', 'past' ]
map_rvsatellite = [ 'satellite', 'infrared' ]
map_layers = { 'rvradar': map_rvradar, 'rvsatellite': map_rvsatellite, 'gctemp': '', 'gcwind': '' }
map_maps = { 'osm': '', **map_layers }
map_rv = { 'rvradar': map_rvradar, 'rvsatellite': map_rvsatellite }
map_gc = { 'gctemp': '', 'gcwind': '' }
map_layers = { **map_rv, **map_gc }

# Mapping WMO to KODI
map_wmo = {
Expand Down Expand Up @@ -736,6 +737,7 @@ def addon(cache=False):
addon.particlesdp = utils.setting('unitparticlesdp', 'str', cache)
addon.pollendp = utils.setting('unitpollendp', 'str', cache)
addon.uvindexdp = utils.setting('unituvindexdp', 'str', cache)
addon.pressure = utils.setting('unitpressure', 'str', cache)
addon.pressuredp = utils.setting('unitpressuredp', 'str', cache)
addon.radiationdp = utils.setting('unitradiationdp', 'str', cache)
addon.cdefault = utils.setting('colordefault', 'str', cache)
Expand Down Expand Up @@ -773,12 +775,13 @@ def kodi():
kodi.meri = utils.region('meridiem')
kodi.speed = utils.region('speedunit')
kodi.temp = utils.region('tempunit')
kodi.height = map_height.get(utils.xbmcgui.getScreenHeight(), 1080)
kodi.height = 1080

def loc(locid, cache=False):
loc.id = locid
loc.cid = str(utils.settingrpc("weather.currentlocation"))
loc.name = utils.setting(f'loc{locid}', 'str')
loc.user = utils.setting(f'loc{locid}user', 'str')
loc.lat = utils.setting(f'loc{locid}lat', 'float')
loc.lon = utils.setting(f'loc{locid}lon', 'float')
loc.utz = utils.setting(f'loc{locid}utz', 'bool')
Expand Down
42 changes: 42 additions & 0 deletions weather.openmeteo/lib/conv.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,48 @@ def precipconv(value, unit):
def precip(value=False):
return precipconv(value, config.addon.precip)

# Pressure
def pressureconv(value, unit):
if value is not False:
value = float(value)

if unit == 'kPa':
v = value * 0.1
elif unit == 'mmHg':
v = value * 0.7500637554
elif unit == 'inHg':
v = value * 0.02953
elif unit == 'psi':
v = value * 0.0145037738
else:
v = value

if config.addon.pressuredp == '0':
return round(v)
else:
if config.addon.unitsep == ',':
return str(round(v,int(config.addon.pressuredp))).replace('.',',')
else:
return round(v,int(config.addon.pressuredp))

else:

if unit == 'kPa':
v = 'kPa'
elif unit == 'mmHg':
v = 'mmHg'
elif unit == 'inHg':
v = 'inHg'
elif unit == 'psi':
v = 'psi'
else:
v = 'hPa'

return v

def pressure(value=False):
return pressureconv(value, config.addon.pressure)

# Decimal places
def dp(value, setting):
value = float(value)
Expand Down
10 changes: 10 additions & 0 deletions weather.openmeteo/lib/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ def onSettingsChanged(self):
config.init()
weather.Main(str(utils.settingrpc("weather.currentlocation")), mode='update')

# Map zoom
if current.get('mapzoom') != self.old.get('mapzoom'):
utils.log('Map zoom changed, re-downloading ...')

for locid in range(1, config.addon.maxlocs):
if utils.setting(f'loc{locid}'):
utils.setsetting(f'loc{locid}map', '321318000')
utils.setsetting(f'loc{locid}rv', '321318000')
utils.setsetting(f'loc{locid}gc', '321318000')

self.old = current

def waitForService(self):
Expand Down
13 changes: 8 additions & 5 deletions weather.openmeteo/lib/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,18 @@ def Main():
utils.log(f'Starting service ...')
utils.log(config.addon_info, 3)

# Geolocation
if not utils.setting('geoip') and not utils.setting('loc1'):
utils.setsetting('geoip', 'true')
utils.setsetting('service', 'running')
weather.Main('1', mode='geoip')
weather.Main('1', mode='download')
utils.setsetting('service', 'idle')

# Service
while not utils.monitor.abortRequested():
utils.setsetting('service', 'running')

# Geolocation
if startup and not utils.setting('geoip'):
weather.Main('1', mode='geoip')
weather.Main('1', mode='download')

# Init
if utils.settingrpc('weather.addon') == 'weather.openmeteo':
utils.log(f'Running service ...', 3)
Expand Down
18 changes: 10 additions & 8 deletions weather.openmeteo/lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,9 @@ def getprop(data, map, idx, count):

# Pressure
elif unit == 'pressure':
content = conv.dp(content, config.addon.pressuredp)
content = conv.pressure(content)
elif unit == 'unitpressure':
content = 'hPa'
content = conv.pressure()

# Direction
elif unit == 'direction':
Expand Down Expand Up @@ -521,7 +521,7 @@ def setalert(data, map, idx, locid, curid, loc, mode):
if content >= limit:
code = int(alert[-1])
value = content
time = data[map[1][0]]['time'][index]
stamp = data[map[1][0]]['time'][index]

elif 'low' in alert:
if content <= limit:
Expand All @@ -530,20 +530,22 @@ def setalert(data, map, idx, locid, curid, loc, mode):
if content <= limit:
code = int(alert[-1])
value = content
time = data[map[1][0]]['time'][index]
stamp = data[map[1][0]]['time'][index]

elif 'wmo' in alert:
for wmo in limit:
if content == int(wmo):
hours[f'{alert[-1]}'] += 1
code = int(alert[-1])
value = content
time = data[map[1][0]]['time'][index]

if content > value:
code = int(alert[-1])
value = content
stamp = data[map[1][0]]['time'][index]

# Check alert code
if code != 0:
icon = f'{prop}{code}'
time = dt('stamploc', time).strftime('%H:%M')
time = conv.time('time', stamp)

if prop == 'temperature':
value = conv.temp(value)
Expand Down
Loading