Repository navigation
Place search for met_no and moon_phase (M5 part 3c, 2 of 2) - #271
Merged
Merged
Conversation
paperpi.places finds places by name with Open-Meteo (browser language, then English) and offers a ready-made location helper. met_no gets an optional altitude setting, sent to met.no. met_no and moon_phase fill lat and lon from the search on their settings page. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
txoof
approved these changes
Oct 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #238 (M5 part 3c, 2 of 2). Does the work of #176 (altitude for the weather), which was closed today.
What changed
The first real user of the setting helpers from #268: a place search on the settings page of
met_noandmoon_phase. Type a town's name abovelat, press Search, and Use fills in the fields (Save keeps them).src/paperpi/places.py:find_places(text, language)asks Open-Meteo's place search (no key needed). It searches in the browser's language first and then in English, and lists each place once ("Den Haag" is found only in Dutch). Each request may take at most 12 s with its retry, so two fit in the 30 s limit of a search (limits.PLACE_REQUEST,PLACE_CONNECT).location_helper(lat, lon, altitude=None, name=None): a ready-made helper. The plugin names its settings. Each choice shows place, region, country, altitude and lat/lon, with a "See on map" link (OpenStreetMap). The page credits "Search by Open-Meteo, place data from GeoNames" (CC BY 4.0).met_no: new optionalaltitudesetting (whole metres, -500 to 9000), sent to met.no as&altitude=. A change of altitude counts as a new place, so the saved forecast is not used. The search fillslat,lon,altitudeandplace(the name is always replaced, as agreed after the demo).moon_phase: the search fills onlylatandlon(the moon doesn't need the altitude, and the plugin shows no place name).docs/writing-plugins.md(how to uselocation_helper),docs/decisions/setting-helpers.md(the two languages and the time limit). The example config is made again (it now listsaltitude).About #176: its example had a sign mistake.
lon = 84.31is on the Tibetan plateau, where met.no's 4949 m is right; Atlanta is atlon = -84.31. With the search, lat, lon and altitude come from one place, so this mistake can't happen there.Area
core (
src/paperpi/places.py,limits.py), plugins/met_no, plugins/moon_phase, docs, tests.Tests
New
tests/test_places.py(fake Open-Meteo: reading answers, missing fields, two languages merged, list cut at 10, time limits, the helper's fill/show/link, Open-Meteo unreachable, one language failing, odd answers).test_met_no.py: altitude in the URL and in the saved place; the search fills altitude and place.test_moon_phase.py: the search fills only lat and lon.Tried with the real Open-Meteo: "Addis Ababa" and "Berlin" in the moon_phase settings page; the search box is shown just before
lat.uv run pytestpasses (1556 tests)uv run ruff check .passesReview
altitudefield (before, an earlier choice's altitude stayed and would be sent for the new place); one odd place in Open-Meteo's answer is left out instead of failing the whole search; when one of the two language searches fails, the other's places are still listed; clearer docs. Left as is: a place name over 60 characters or an altitude outside -500 to 9000 shows a field error after Use (nothing is saved; no real place found that does this).Only txoof approves and merges this PR.
🤖 Generated with Claude Code