Skip to content

feat(remne_p1ib): read-only site meter for the Remne P1IB bridge - #150

Merged
frahlg merged 1 commit into
srcfl:mainfrom
Vortitron:add-remne-p1ib
Oct 1, 2026
Merged

frahlg merged 1 commit into
srcfl:mainfrom
Vortitron:add-remne-p1ib

Conversation

@Vortitron

Copy link
Copy Markdown
Contributor

Problem

The Remne Technologies P1IB is a common Wi-Fi P1/HAN reader in Sweden (sold by m.nu, among others). FTW has no driver for it. Its MQTT output is not usable as a site meter: the bridge publishes a value only when it moves past a per-sensor hysteresis ("reduced mode"), so a site whose load holds steady goes quiet for hours and Core marks the meter stale and stops dispatch.

Scope

One new read-only community driver, remne_p1ib 0.1.0, with its manifest, a behaviour test and a changelog entry. No change to any other driver or contract.

  • Reads the bridge's own GET /meterData JSON: one request per poll.
  • Emits net and per-phase active power, voltage, current, and lifetime import/export energy. Reactive power and Wi-Fi RSSI go out as diagnostic metrics.
  • Freshness comes from the bridge's good-telegram counter (info.okCnt). The driver emits once per new telegram, never re-emits the rolling 10-value window, and logs once when no telegram has arrived for three telegram intervals (at least 30 s). A bridge reboot resets the counter and counts as new data.
  • Values the meter does not send are omitted rather than emitted as 0.
  • Identity: make Remne Technologies, serial p1ib-<mac>, model from the meter string the bridge reports (e.g. LGF5E360).
  • connection_defaults declares an empty host, so the setup wizard passes the entered IP as config.host.

The endpoint shape was read off live units. The firmware is closed; the paths match the strings in the published firmware image and the webservice mentioned in the vendor README, both listed in upstream_docs.

Test steps and results

  • make check: pass (4793 passed, 923 skipped).
  • drivers/tests/test_remne_p1ib.py runs a Lua harness over a synthetic /meterData payload: site sign convention per phase, no re-emit on an unchanged counter, one stale warning, bridge reboot, missing per-phase values omitted, empty arrays after boot. I checked that it fails when the counter check is removed and when the sign is flipped.
  • Hardware: FTW v0.138.2-beta.1, native install on Debian 13 (x86_64 VM), with two P1IB units (hardware rev F, firmware 757b45d) on Landis+Gyr E360 meters (Mode D, telegram every ~10 s), one as site meter, the other as a second meter. Both were added through the setup wizard. Result: health ok for both drivers, 0 consecutive errors over 40 polls each, readings not stale, "site dispatch freshness recovered" logged for the site meter. Site power in FTW (708 W) matched the same meter's reading in Home Assistant (725 W) one telegram apart.

Not tested: export (no solar at this site, so export has only been seen as 0), single-phase meters, and the P1IB Ethernet variant.

A related finding in esphome_dsmr

While adding the P1IB through the setup wizard, both drivers first failed at init with config.host is required. web/setup.js seeds config.host only when the catalog entry's connection_defaults has a host key, and my first version had copied esphome_dsmr's block, which contains only a comment. esphome_dsmr (1.0.6) has the same empty block and requires config.host, so I expect it fails the same way when added through the wizard. I have not changed it here, to keep this PR to one driver. Declaring host = "" there, as this driver now does, should be enough.

🤖 Generated with Claude Code

Add a read-only meter driver for the Remne Technologies P1IB, a Wi-Fi
P1/HAN reader common in Sweden. It reads the bridge's /meterData JSON
rather than its MQTT output: P1IB publishes MQTT only when a value moves
past its hysteresis, so a steady site would look stale to Core and stop
dispatch. Freshness comes from the bridge's good-telegram counter, so the
driver emits once per telegram and never re-emits the rolling window.

connection_defaults declares an empty host so the setup wizard passes the
entered IP as config.host; without the key a wizard-added driver never
learns its address.

Run in FTW v0.138.2-beta.1 against two P1IB units (rev F, fw 757b45d) on
Landis+Gyr E360 meters, one as site meter.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Andy Lyeklint Hancock <[email protected]>

@miravoss26 miravoss26 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New read-only community driver remne_p1ib 0.1.0 (Remne P1IB bridge, HTTP /meterData polling instead of the bridge's own hysteresis-gated MQTT — the stated reason, avoiding false-stale site meters, is sound and matches how FTW treats a quiet site meter).

Correctness: read_only = true / control: false throughout, matches the driver's scope. Sign convention (w = (import - export) * 1000, site-positive) is consistent with the rest of the fleet. Freshness is driven off the bridge's info.okCnt telegram counter rather than value-change — correctly avoids re-emitting the rolling window as fresh, and correctly treats a lower counter (bridge reboot) as new data. Missing per-phase values are omitted rather than defaulted to 0, which matters here (a synthetic 0 A would disable the per-phase fuse guard per the driver's own comment) — good instinct. Exponential backoff on HTTP/JSON failures, capped at 60s. driver_cleanup resets all module state cleanly. Lua harness covers six real scenarios (first telegram + sign check, no-re-emit, stale-after-3-intervals warning, reboot-lower-counter, partial-phase-omission, empty-arrays-at-boot) and the PR body reports the full make check suite green plus real hardware validation against two live units.

Security: no secrets, no new external network destination — this talks to a bridge at a site-local, installer-entered IP (config.host), same shape as every other local HTTP driver here. No injection surface (base_url built from a validated non-empty string, JSON parsed through a pcall-wrapped decoder). No auth/control-path changes.

One thing worth a decision, not a blocker: the PR body flags that esphome_dsmr's connection_defaults has the same empty-host-block bug this driver had to work around (setup wizard fails with "config.host is required" unless the key is declared), and deliberately left it unfixed to keep this PR to one driver. Reasonable scoping call — might be worth a quick follow-up issue so it doesn't get lost, but not this PR's job to fix.

CI hasn't run yet (empty status-check list as of this review) — worth a second look once it reports. Safe to merge from my read once CI is green; device-drivers isn't on the auto-merge allowlist so this needs a human regardless.

@frahlg

frahlg commented Oct 1, 2026

Copy link
Copy Markdown
Member

Great first driver, and thanks for testing it on two live units. Choosing HTTP over MQTT because of the hysteresis is the right call. A steady site would otherwise look stale and stop dispatch. Your #151 fix is up as #152. I'll merge this once CI is green.

@frahlg
frahlg merged commit 20792c2 into srcfl:main Oct 1, 2026
5 checks passed
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.

3 participants