Skip to content

Keep weather units accurate when wttr.in is unavailable - #21397

Merged
emirb merged 4 commits into
quattrofrom
fix/weather-unit-resilience
Dec 2, 2026
Merged

emirb merged 4 commits into
quattrofrom
fix/weather-unit-resilience

Conversation

@emirb

@emirb emirb commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

What changes

The weather panel chose Celsius or Fahrenheit from wttr.in's nearest_area country alone, falling back to Qt.locale().name (LANG=en_US.UTF-8). Whenever wttr.in returns HTTP 500 (for example during the current outage in chubin/wttr.in#1316) or lags behind Open-Meteo, non-US locations flip to Fahrenheit and mph.

This keeps the two-letter ISO 3166-1 country code from geo.omarchy.org, Open-Meteo geocoding (country_code), and omarchy-weather-location --set <name> [lat,lon] [--country <code>]. The panel resolves units from the location's country first, then wttr.in's country for the active query, then LC_ALL, LC_MEASUREMENT, LANG, and Qt.locale().name.

It also recognizes LR, MM, and non-English US territory locales such as es_US.UTF-8. Cached wttr.in areaInfo is scoped to the query that fetched it, so a previous city's country cannot leak across location switches during an outage. If a cancelled wttr.in process exits after a location switch, the replacement fetch is queued rather than dropped.

Fixes #17415

Builds on #17443 (Reese Royster) and #20224 (Mikhail Turov), and supersedes #21164 (Andreas Kraxner).

Verification

  • bash test/shell.d/weather-unit-test.sh: fails on quattro before the fix and passes 29/29 after, covering degraded provider combinations and CLI validation.
  • bash test/shell.d/bar-widget-contract-test.sh and bash test/shell.d/i18n-test.sh: pass.
  • Verified in an Omarchy 4.5.0 KVM VM synced to quattro with wttr.in returning HTTP 500, geo.omarchy.org returning Heemserveen (NL), and LANG=en_US.UTF-8:
    • Base quattro: 52°F, feels 49°F, 9 mph.
    • Patched auto-detect (NL): 11°C, feels 9°C, 15 km/h.
    • Patched pinned --country au (Sydney): 11°C, feels 9°C, 15 km/h.
    • Cached New York wttr.in report switched to legacy country-less Amsterdam with wttr.in down and LC_MEASUREMENT=nl_NL.UTF-8: 11°C, 15 km/h.
  • systemctl --failed and coredumpctl clean in the VM.
  • Not checked: bin/omarchy-weather-status and bin/omarchy-weather-icon (separate wttr.in dependency, unchanged here).

Screenshots

Before (stock quattro, Heemserveen NL, wttr.in HTTP 500, LANG=en_US.UTF-8):

Before: Heemserveen showing 52°F and 9 mph while wttr.in returns 500

After (patched, Heemserveen NL, wttr.in HTTP 500, LANG=en_US.UTF-8):

After: Heemserveen showing 11°C and 15 km/h while wttr.in returns 500

Reese Royster and others added 4 commits December 2, 2026 22:08
The panel picked metric or imperial from wttr.in's nearest_area country,
and with coordinates configured only Open-Meteo answers the current
conditions, which carries no country. A wttr.in failure therefore left
reportCountry empty and the unit fell through to the session locale, so
an Australian location read as °F on an en_US session until wttr.in came
back.

weather.json now carries the place's ISO 3166-1 country code: the panel
stores the geocoder's country_code with the coordinates it pins, and
geo.omarchy.org already answers with one, so an auto-detected place has
it too. Units follow that code before wttr.in's report and the locale.

Closes #17415
countryUsesImperial knew Liberia and Myanmar by name only, so the codes
weather.json now stores (LR, MM) fell through to metric. Both are listed
alongside their names, with tests.

Also spell out --country in the manual, which promised the units without
showing how a CLI-pinned place gets one.
When wttr.in fails after a location change, the previous location's
cached wttr.in report could still supply areaInfo.country for the new
location, flipping units if the new location carried no saved country.

Track the query that produced the current wttr.in report so stale
areaInfo never bleeds across location changes, reject unknown flags in
omarchy-weather-location --set, and add a focused unit and CLI test
matrix covering degraded provider combinations (geo.omarchy.org,
Open-Meteo, wttr.in outages, saved country codes, and LC_MEASUREMENT).
@greptile-apps

greptile-apps Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5RetriggerView in Greptile

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

Keeps weather units tied to the selected place when wttr.in is unavailable.

  • Weather readings use the active place’s country to choose units.
  • A late weather reply no longer sets units for another city.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A{Explicit unit setting?} -->|Yes| B[Use selected units]
  A -->|No| C{Location country known?}
  C -->|Yes| D[Use location country]
  C -->|No| E{Country from active wttr.in query?}
  E -->|Yes| F[Use reported country]
  E -->|No| G[Use LC_ALL, LC_MEASUREMENT, LANG, then Qt locale]
Loading

Reviews (1) · Last reviewed commit: "Drop stale wttr.in country on location c..." · Reviewed by Greptile

@emirb
emirb merged commit 322523c into quattro Dec 2, 2026
6 checks passed
@emirb
emirb deleted the fix/weather-unit-resilience branch December 2, 2026 22:49
@emirb emirb added this to the 4.6.0 milestone Dec 2, 2026
emirb added a commit that referenced this pull request Dec 3, 2026
* Keep weather units on the pinned location's country

The panel picked metric or imperial from wttr.in's nearest_area country,
and with coordinates configured only Open-Meteo answers the current
conditions, which carries no country. A wttr.in failure therefore left
reportCountry empty and the unit fell through to the session locale, so
an Australian location read as °F on an en_US session until wttr.in came
back.

weather.json now carries the place's ISO 3166-1 country code: the panel
stores the geocoder's country_code with the coordinates it pins, and
geo.omarchy.org already answers with one, so an auto-detected place has
it too. Units follow that code before wttr.in's report and the locale.

Closes #17415

* Read the imperial countries by their country codes too

countryUsesImperial knew Liberia and Myanmar by name only, so the codes
weather.json now stores (LR, MM) fell through to metric. Both are listed
alongside their names, with tests.

Also spell out --country in the manual, which promised the units without
showing how a CLI-pinned place gets one.

* Respect LC_MEASUREMENT and LC_ALL for weather unit selection

* Drop stale wttr.in country on location change and add weather unit tests

When wttr.in fails after a location change, the previous location's
cached wttr.in report could still supply areaInfo.country for the new
location, flipping units if the new location carried no saved country.

Track the query that produced the current wttr.in report so stale
areaInfo never bleeds across location changes, reject unknown flags in
omarchy-weather-location --set, and add a focused unit and CLI test
matrix covering degraded provider combinations (geo.omarchy.org,
Open-Meteo, wttr.in outages, saved country codes, and LC_MEASUREMENT).

---------

Co-authored-by: Reese Royster <reeseroyster@pm.me>
Co-authored-by: Mikhail Turov <groldster@gmail.com>
(cherry picked from commit 322523c)
emirb added a commit that referenced this pull request Dec 3, 2026
)

* Keep weather units on the pinned location's country

The panel picked metric or imperial from wttr.in's nearest_area country,
and with coordinates configured only Open-Meteo answers the current
conditions, which carries no country. A wttr.in failure therefore left
reportCountry empty and the unit fell through to the session locale, so
an Australian location read as °F on an en_US session until wttr.in came
back.

weather.json now carries the place's ISO 3166-1 country code: the panel
stores the geocoder's country_code with the coordinates it pins, and
geo.omarchy.org already answers with one, so an auto-detected place has
it too. Units follow that code before wttr.in's report and the locale.

Closes #17415

* Read the imperial countries by their country codes too

countryUsesImperial knew Liberia and Myanmar by name only, so the codes
weather.json now stores (LR, MM) fell through to metric. Both are listed
alongside their names, with tests.

Also spell out --country in the manual, which promised the units without
showing how a CLI-pinned place gets one.

* Respect LC_MEASUREMENT and LC_ALL for weather unit selection

* Drop stale wttr.in country on location change and add weather unit tests

When wttr.in fails after a location change, the previous location's
cached wttr.in report could still supply areaInfo.country for the new
location, flipping units if the new location carried no saved country.

Track the query that produced the current wttr.in report so stale
areaInfo never bleeds across location changes, reject unknown flags in
omarchy-weather-location --set, and add a focused unit and CLI test
matrix covering degraded provider combinations (geo.omarchy.org,
Open-Meteo, wttr.in outages, saved country codes, and LC_MEASUREMENT).

---------



(cherry picked from commit 322523c)

Co-authored-by: Reese Royster <reeseroyster@pm.me>
Co-authored-by: Mikhail Turov <groldster@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Weather panel switches to °F when wttr.in is unreachable, even for a non-US location

2 participants