Add Chimnie provider for UK property valuations
Problem
The automatic property valuations added in #2727 only work for US properties (RentCast and Realie). UK users can't value a property automatically.
Solution
Adds Chimnie as a third :property_valuations provider. Chimnie values UK residential properties for free when looked up by UPRN (Unique Property Reference Number).
I checked the API contract against Chimnie's OpenAPI spec (https://api.chimnie.com/docs-json) and with sandbox calls:
- Endpoint:
GET /residential/uprn/{uprn}, authenticated withAuthorization: Bearer <key>. - Only the free fields are requested:
property_value,property_value_rangeandproperty_value_confidence. Requesting anything else makes the call billable. - The free tier allows 1 request/second, so the provider throttles at 1.1s between requests.
Turning an address into a UPRN costs money (address search charges 5p or more), so users enter their UPRN themselves. The form explains where to find it.
Resulting behaviour
- Settings → Self-Hosting has a Chimnie API key field, stored encrypted like the RentCast key. It can also be set with
CHIMNIE_API_KEY. - Add property → Add via Chimnie asks for the address, postcode and UPRN, with UK labels and an optional county.
- The preview shows the estimate, its range, Chimnie's confidence, the UPRN and the required OS / Royal Mail / HM Land Registry attribution.
- The account is created in GBP, with no currency conversion.
- Refreshes: UK properties are refreshed at most monthly by the existing
SyncPropertyValuationsJob. RentCast and Realie keep their one-day minimum.- If a provider rate-limits, the job stops calling it for the rest of the run.
- A new Refresh valuation button on the property overview queues a forced refresh. It is scoped to the family and requires edit permission.
- No duplicate valuations: a refresh on the same date updates that day's valuation (existing
CurrentBalanceManagerbehaviour, now covered by a test). - Clear errors for invalid or missing UPRNs, unknown properties, commercial properties (409), missing estimates, rejected keys (401), low balance (402) and rate limits (429). A malformed UPRN is rejected before any request is spent.
- Valuations written by a provider are now named after it, e.g. "Chimnie valuation" or "RentCast valuation", instead of "Manual value update". Manual edits keep the old name.
Backwards compatibility
- Provider capabilities moved to class methods on
Provider::PropertyValuationConcept:supported_country,required_address_fields,requires_external_id?,refresh_intervalandlookup_ready?. Their defaults reproduce the previous US-only behaviour. - RentCast and Realie are untouched.
external_id:is only passed to providers that require it. PropertyValuationgains optionalexternal_id,valuation_low,valuation_highandconfidencemembers, all defaulting tonil.
Migration notes
20261011090000_add_chimnie_support_to_properties:
- Adds
properties.avm_external_id(string, nullable), which stores the UPRN. - Replaces
properties_avm_provider_checkso it also allows'chimnie'. - Reversible. Tested with
db:migrate:redo.
Validation
bin/rails test: 11,382 runs, 0 failures, 0 errors (34 skips, all from before this change)bin/rails test test/system/settings_test.rb: passingbin/rubocop,erb_linton the changed views,bin/brakeman: no offences or warnings- No JavaScript changed, so Biome wasn't run.
- New and updated tests:
test/models/provider/chimnie_test.rbtest/models/property_test.rbtest/jobs/sync_property_valuations_job_test.rb: GBP refresh, monthly interval, forced refresh, missing UPRN, rate-limit cut-off, same-day dedupetest/controllers/properties_controller_test.rb: UPRN form, preview, GBP confirm, refresh action, family scoping- Settings controller and system test stubs
To try it manually: get a free key at https://dashboard.chimnie.com (sign-up requires a business or custom-domain email address, not Gmail, Outlook or similar), then use sandbox UPRN 999000000001 (postcode CH1 1MN). It should value at £425,000, with a range of £340,000–£530,000 and High confidence.
Docs: docs/hosting/property-valuations.md and .env.example.
Screenshots
1. Settings → Self-Hosting. The new Chimnie section under RentCast and Realie: an encrypted API key field (masked once saved), a note that sign-up needs a business or custom-domain email, and monthly usage against Sure's 1,000-request cap.
2. Choosing how to add a property. Once a Chimnie key is configured, Add via Chimnie appears next to the manual option, with Chimnie's provider logo. Without a Brandfetch client ID, the logo falls back to its initials.
3. Lookup form. It reuses the existing provider dialog, with UK labels (Town or city, optional County, Postcode) and a required UPRN field. The help text explains where to find a UPRN. Lookups go by UPRN only, which keeps them free.
4. Preview before anything is created. Sandbox UPRN 999000000001: £425,000 estimate, £340,000 – £530,000 range, High confidence, plus the OS / Royal Mail / HM Land Registry attribution Chimnie requires. Property type, year built and area show as Unknown because those fields are paid, so they aren't requested.
5. The created account. Stored in GBP with no conversion, with the address country set to GB. The valuation entry is named Chimnie valuation rather than "Manual value update". Family-wide totals still convert to the family currency as usual: the property shows £425,000 (≈ $562,445), and the Properties group total is $912,445.
6. Overview tab. Shows the provider and last refresh date, plus a Refresh valuation button that queues an immediate refresh, skipping the monthly interval. Purchase Price equals the first estimate because no purchase price is collected yet; see Follow-ups.
Exchange rates in these screenshots come from the free Frankfurter (ECB) provider, which converts GBP to the demo family's USD in totals.
Follow-ups (not in this PR)
- Optional purchase price and date on property creation, saved as the opening valuation. For UK properties it could be pre-filled from Chimnie's free
last_transaction_price/last_transaction_date. - Translations of the new strings for languages other than English.
🤖 Generated with Claude Code
Summary by CodeRabbit
-
New Features
- Added UK property valuations using a UPRN, with estimates in GBP and optional value ranges and confidence details.
- Added Chimnie API key configuration and monthly usage information in self-hosting settings.
- Added on-demand valuation refresh for provider-linked properties, with the latest sync date displayed.
- Valuations are labeled with their provider.
-
Documentation
- Added guidance for configuring valuation providers and understanding refresh schedules and limits.