Skip to content

fix: add ESPHome DSMR object ID aliases - #9

Merged
frahlg merged 1 commit into
mainfrom
agent/esphome-dsmr-aliases
Jul 22, 2026
Merged

frahlg merged 1 commit into
mainfrom
agent/esphome-dsmr-aliases

Conversation

@frahlg

@frahlg frahlg commented Jul 22, 2026

Copy link
Copy Markdown
Member

What changed

  • add esphome-dsmr as the public editable source for FTW
  • probe Sourceful, name-derived, and delivered/returned ESPHome object ID aliases
  • keep the driver read-only and add an FTW-only package recipe
  • test both live-reported alias families against the Lua host contract

Why

ESPHome DSMR firmware often derives object IDs from entity names. FTW only probed Sourceful Zap IDs, so sites such as SlimmeLezer+ lost per-phase current and power data. Tommy Lindgren validated the fix on live hardware in FTW #617, which fixes FTW #613.

This PR moves the editable implementation to this repository. FTW will keep only a traced offline recovery snapshot and host tests.

Checks

  • make test-driver ID=esphome-dsmr
  • uv run --frozen --extra package --extra dev pytest -q drivers/tests/test_esphome_dsmr_aliases.py
  • make package-driver ID=esphome-dsmr TARGET=ftw-core
  • make check — 2,585 passed, 490 skipped; all 62 drivers passed sandbox checks

Co-authored-by: Tommy Lindgren <tommy@lindgrens.nu>
Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
@frahlg
frahlg marked this pull request as ready for review July 22, 2026 05:13
@frahlg
frahlg merged commit c1d61ea into main Jul 22, 2026
5 checks passed
@frahlg
frahlg deleted the agent/esphome-dsmr-aliases branch July 22, 2026 05:14

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: be9c9eeaf9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

end

host.set_make(make_name)
host.set_poll_interval(poll_ms)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Remove the unsupported poll-interval host call

On the declared ftw-core host API v1, scheduling is driven by the number returned from driver_poll; host.set_poll_interval is not part of that runtime contract. Any ESPHome DSMR instance reaches this line during driver_init, so on the packaged target this attempts to call a nil host function and the driver never starts polling; the existing return poll_ms/return backoff_ms() paths should be used instead or the call must be feature-guarded.

AGENTS.md reference: AGENTS.md:L27-L27

Useful? React with 👍 / 👎.

Comment on lines +325 to +327
if phase_w[i] ~= nil then host.emit_metric("meter_l" .. i .. "_w", phase_w[i], "W") end
if v[i] ~= nil then host.emit_metric("meter_l" .. i .. "_v", v[i], "V") end
if a[i] ~= nil then host.emit_metric("meter_l" .. i .. "_a", a[i], "A") end

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid emitting diagnostics through an undeclared host API

When any documented phase alias is present, the poll path reaches these host.emit_metric calls after host.emit("meter", ...), but emit_metric is not in the declared host API v1 for this package target. On hosts that only expose the contract APIs, each successful phase poll will raise attempt to call field 'emit_metric' (a nil value) and mark the poll failed; diagnostic metrics should be omitted or guarded unless the target runtime declares them.

AGENTS.md reference: AGENTS.md:L27-L27

Useful? React with 👍 / 👎.

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.

[bug] esphome-dsmr: per-phase fuse data missing on ESPHome name-derived object_ids

1 participant