Skip to content

Backport #21397 to v4-6-0: Keep weather units accurate without wttr.in - #21482

Merged
emirb merged 1 commit into
v4-6-0from
backport/21397-v4-6-0
Dec 3, 2026
Merged

emirb merged 1 commit into
v4-6-0from
backport/21397-v4-6-0

Conversation

@emirb

@emirb emirb commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Problem

When wttr.in returns HTTP 500, the weather panel drops its country signal and falls back to en_US Fahrenheit for users outside the United States. Users in Europe and Australia see 52°F instead of 11°C even though Open-Meteo still serves current conditions.

Fix

This is a clean cherry-pick of #21397 (322523c112), already merged into quattro. It saves the ISO 3166-1 country code from geo.omarchy.org and Open-Meteo geocoding, respects LC_ALL and LC_MEASUREMENT, and drops stale wttr.in area data across location switches.

Scope and risk

Only the weather panel, omarchy-weather-location, manual/10-notices.md, and the weather unit test file change. Existing weather.json files without a country field keep working. Undo by reverting this single commit on v4-6-0.

Evidence

The cherry-pick applied onto v4-6-0 (68a637db9) with no conflicts and an identical diff to 322523c112. All 29 cases in test/shell.d/weather-unit-test.sh pass on the backport branch. The same diff was verified end to end in a KVM desktop VM on #21397 (Amsterdam under wttr.in HTTP 500 moved from 52°F / 9 mph to 11°C / 15 km/h).

Not checked: a separate v4-6-0 VM image build, as the diff matches #21397 on quattro.

Refs #21397, #17415

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

@emirb emirb added this to the 4.6.0 milestone Dec 3, 2026
@greptile-apps

greptile-apps Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5RetriggerView in Greptile

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

Summary

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

  • Weather units stay tied to the location when wttr.in cannot answer.
  • Old wttr.in area data stops carrying over when the location changes.

No actionable issues found. Runtime tests and desktop checks were not run during this review.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Choose weather units] --> B{Explicit unit setting?}
  B -->|Yes| C[Use the setting]
  B -->|No| D{Place has a country?}
  D -->|Yes| E[Use the place's country]
  D -->|No| F{Matching wttr.in report has a country?}
  F -->|Yes| G[Use the reported country]
  F -->|No| H[Use LC_ALL, then LC_MEASUREMENT, then LANG]
Loading

Reviews (2) · Last reviewed commit: "Keep weather units accurate when wttr.in..." · Reviewed by Greptile

* 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
emirb force-pushed the backport/21397-v4-6-0 branch from 19a0479 to a8845cc Compare December 3, 2026 13:16
@omarchybot

Copy link
Copy Markdown
Collaborator

Recommend: Hold — waiting for the maintainer to settle the classification.

Codex High checked the release-branch diff and classified the Fahrenheit fallback in #17415 as a bug. DeepSeek V4.1 Flash at Pi’s default effort classified the backport as an enhancement. The patch matches #21397, including the --country option for CLI-pinned locations. Worker verification is pending classification.

@emirb
emirb merged commit 0b106c5 into v4-6-0 Dec 3, 2026
6 checks passed
@emirb
emirb deleted the backport/21397-v4-6-0 branch December 3, 2026 13:19
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.

2 participants