Skip to content

fix(energy): align active power queries and dimension 1200 stream lifecycle (#466, #629) - #661

Merged
GreenGrassBlueOcean merged 4 commits into
OpenWebNet-HA:v2-phase1-architecturefrom
GreenGrassBlueOcean:fix/energy-stream-dimension1200-lifecycle
Oct 9, 2026
Merged

GreenGrassBlueOcean merged 4 commits into
OpenWebNet-HA:v2-phase1-architecturefrom
GreenGrassBlueOcean:fix/energy-stream-dimension1200-lifecycle

Conversation

@GreenGrassBlueOcean

@GreenGrassBlueOcean GreenGrassBlueOcean commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Note

Trace Gate Satisfied: Grounded in authentic on-wire customer bus capture contributed by @xtimmy86x in #664 (tests/fixtures/traces/issue_466/myhome_trace_F454_who18_2026-10-08T19-30-16.json). Companion OWNd PR OpenWebNet-HA/OWNd#92 is approved.

fix(energy): align active power queries and dimension 1200 stream lifecycle (#466, #629)

Summary

Fixes a recurring NACK defect in MyHOMEPowerSensor.async_update and completes the stream lifecycle handling for WHO 18 Dimension 1200 auto-updating instant power.

Companion to:

Grounding & Defect Resolution:

  1. Eliminate Invalid Dimension 1200 Polling Query (*#18*WHERE*1200##):
    • MyHOMEPowerSensor.async_update previously sent *#18*{where}*1200##.
    • On physical Legrand/BTicino gateway firmwares (bt_supervisione), Dimension 1200 is an auto-update parameter; query requests without parameters are syntactically invalid and always return *#*0## (NACK), causing recurring retry storms in production customer installations (#629).
    • Querying instantaneous active power on demand requires Dimension 113: *#18*{where}*113##.
  2. Stream Interval Lifecycle Handling in handle_event:
    • Handles MESSAGE_TYPE_AUTO_UPDATE_INTERVAL (and fallback to raw Dimension 1200) emitted by physical energy meters (e.g. *#18*51*1200#1*125##).
    • Updates self._streaming_until to track stream duration and deactivates streaming when update_interval == 0 (e.g. *#18*51*1200#1*0## stream stop frame).
  3. Stop Streaming Support:
    • Adds async_stop_sending_instant_power (and alias stop_sending_instant_power) to gracefully cancel active streams via *#18*{where}*#1200#1*0## or typed OWNd builder.
  4. Dual Compatibility & 100% Coverage:
    • Fully compatible with released OWNd==2.0.0b10 and upcoming OWNd 2.0.0b11.
    • Comprehensive unit tests added to tests/test_component_sensors.py covering all new paths and fallbacks with 100.0% coverage on MyHOMEPowerSensor.

Changes

  • custom_components/myhome/sensor.py:
    • Fixed MyHOMEPowerSensor.async_update to query active power (*#18*{where}*113##).
    • Added auto-update interval handling in MyHOMEPowerSensor.handle_event.
    • Added async_stop_sending_instant_power and stop_sending_instant_power methods.
  • tests/test_component_sensors.py:
    • Updated test_power_sensor to assert Dimension 113 active power status requests.
    • Added unit tests for stream lifecycle, stop methods, fallback branches, and auto-update interval handling.

Verification

  • Unit tests in tests/test_component_sensors.py: 100.0% coverage on MyHOMEPowerSensor.
  • Full test suite: 16/16 CI checks passing.

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@GreenGrassBlueOcean GreenGrassBlueOcean changed the title fix(energy): align active power queries and dimension 1200 stream lifecycle (#466, #629) [BLOCKED: PENDING TRACES] fix(energy): align active power queries and dimension 1200 stream lifecycle (#466, #629) Oct 8, 2026
@GreenGrassBlueOcean

Copy link
Copy Markdown
Contributor Author

PR Merging Blocked: Pending Authentic On-Wire Bus Traces

In accordance with our strict protocol conformance rules:

  1. Companion OWNd PR OpenWebNet-HA/OWNd#92 is formally blocked with CHANGES_REQUESTED because we do not have an authentic customer on-wire bus capture of an energy meter emitting the *#18*WHERE*1200#Type*Time## incoming reply frame on a live plant.
  2. The synthetic trace fixture PR test(trace): add WHO 18 Dimension 1200 energy stream lifecycle trace and replay test (#466) #660 was withdrawn and closed.
  3. While the Dimension 113 polling fix (*#18*{where}*113##) is verified and eliminates the NACK retry storms from issue Central unit (WHERE #0) is marked "unresponsive" after two restarts, although it answers a plain status request #629, the Dimension 1200 streaming lifecycle portion of this PR directly depends on the unverified Dimension 1200 reply semantics.

Therefore, this PR is strictly blocked from merging until an authentic, untouched customer on-wire bus capture of a physical energy meter (e.g. F520) streaming Dimension 1200 replies is contributed from a physical installation.

@GreenGrassBlueOcean
GreenGrassBlueOcean marked this pull request as draft October 8, 2026 15:08
@xtimmy86x

Copy link
Copy Markdown
Contributor

Hi @GreenGrassBlueOcean
I captured the missing Dimension 1200 replies on my physical installation with F520 meters, through an F454 gateway.

Environment:

  • Gateway: BTicino F454, firmware 2.0
  • Home Assistant: 2026.10.0.dev0
  • MyHOME: 2.0.0b14
  • OWNd: 2.0.0b9
  • Tested OpenWebNet address: 56

The attached original Bus Monitor export contains 66 WHO 18 frames (65 RX, 1 TX), with truncated: false. No frames have been edited or synthesized.

Relevant sequence on 2026-10-08, timestamps in UTC:

19:27:55.541903 TX *#18*56*#1200#1*2##
19:27:55.776619 RX *#18*56*1200#1*2##
19:27:55.847621 RX *#18*56*113*9##

19:30:01.726662 RX *#18*56*1200#1*0##
19:30:01.870024 RX *#18*56*1200#1*255##
19:30:02.089484 RX *#18*56*113*9##

The incoming reply carrying 2 arrived approximately 235 ms after the start command. The zero-duration notification arrived approximately 126.2 seconds after that command, consistent with a two-minute streaming duration. Regular power reports during the capture were approximately 30 seconds apart.

A reply carrying 255 followed the zero-duration notification approximately 143 ms later. No corresponding renewal TX appears in this capture, so its initiator cannot be determined from this trace.

This documents the incoming nonzero and zero Dimension 1200 replies from a real installation over the gateway’s OpenWebNet connection. I tested expiry after requesting two minutes; I did not send an explicit stop command.

Please use the unchanged JSON as a trace fixture for MyHOME #661 and OWNd #92, and reassess the missing-trace blocker.
myhome_trace_F454_who18_2026-10-08T19-30-16.json

@GreenGrassBlueOcean

Copy link
Copy Markdown
Contributor Author

B15 is out btw see discussion

@xtimmy86x

Copy link
Copy Markdown
Contributor

Thanks for the heads-up! The captures were taken on b14 with OWNd b9. I’ll update to b15 for further testing.

The original traces still document the incoming Dimension 1200 replies from my physical F520 installation through the F454, including the nonzero-duration reply and the zero-duration notification after expiry.

@GreenGrassBlueOcean

Copy link
Copy Markdown
Contributor Author

The authentic, untouched customer on-wire bus trace contributed by @xtimmy86x in #661 (comment) has been integrated into our test corpus and submitted as trace PR #664:

  • Fixture: tests/fixtures/traces/issue_466/myhome_trace_F454_who18_2026-10-08T19-30-16.json (66 frames verbatim from physical F454 + F520 plant)
  • Replay Test: tests/test_energy_dimension1200_trace.py (verifies start command *#18*56*#1200#1*2##, ~235 ms interval confirmation delay *#18*56*1200#1*2##, periodic active power telemetry, and the ~126.18 s lease expiry zero-duration notification *#18*56*1200#1*0##)
  • Golden Corpus: who18_energy.yaml and corpus.json updated with roundtrip and builder parity for OWNEnergyCommand.start_sending_instant_power.

Trace PR #664 provides the authentic physical evidence required to unblock this PR (#661) and companion OWNd PR OpenWebNet-HA/OWNd#92.

GreenGrassBlueOcean added a commit that referenced this pull request Oct 8, 2026
…and replay test (#466)

Adds an authentic customer on-wire bus trace and deterministic replay
test suite for the complete WHO 18 Dimension 1200 automatic instant power
stream lifecycle (*#18*WHERE*#1200#Type*Time## start command, meter interval
confirmation, periodic active power telemetry, and zero-duration interval
notification emitted upon 2-minute stream lease expiry).

Captured and contributed by @xtimmy86x on PR #661 (#issuecomment-6067730589)
from a physical BTicino F454 gateway (firmware 2.0) and BTicino F520 energy
meters on a live plant.

Companion to:
- OWNd PR OpenWebNet-HA/OWNd#92
- Downstream companion PR #661

Co-authored-by: xtimmy86x <76836856+xtimmy86x@users.noreply.github.com>
@GreenGrassBlueOcean GreenGrassBlueOcean changed the title [BLOCKED: PENDING TRACES] fix(energy): align active power queries and dimension 1200 stream lifecycle (#466, #629) fix(energy): align active power queries and dimension 1200 stream lifecycle (#466, #629) Oct 9, 2026
@GreenGrassBlueOcean
GreenGrassBlueOcean marked this pull request as ready for review October 9, 2026 06:27
fedem95
fedem95 previously approved these changes Oct 9, 2026

@fedem95 fedem95 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.

Approving. Replacing the *#18*W*1200## poll is right: in the #629 log (F454 gateway; FW 1.0.34 per that issue's sweep) all 18 meters fail with Could not send message *#18*…*1200## and none succeeds, and *#18*<Where>*113## is the PDF's "Request active power" (WHO_18.pdf 5.2.18). The 1200 handling treats the value as minutes, which matches xtimmy86x's trace (Time = 2, the 0 reply 126.2 s later). Locally, full suite against OWNd b10: 3468 passed, 1 skipped; sensor tests also pass against OWNd#92. CI green.

Notes:

  • async_update looks up OWNEnergyCommand.get_instant_power / request_active_power, which exist in neither OWNd b10 nor #92, so it always falls back to OWNCommand.parse("*#18*…*113##").
  • async_stop_sending_instant_power / stop_sending_instant_power aren't registered as an HA service (only start_sending_instant_power is), so users can't call the stop.
  • I found no capture of a client sending *#18*W*113##. The evidence is the PDF plus the oracle (ack on F453AV, F454 2.0.51, F459, F460, F461, MH202, MyHomeServer1; nack on MH200N and F450).
  • In xtimmy86x's trace (filtered to WHO 18) *#18*56*1200#1*255## arrives 143 ms after the *1200#1*0##, with no WHO 18 request from his HA in the capture (he notes the initiator is unknown). With this PR that frame marks the stream active for 255 minutes, so the sensor skips polling for that long. Throughout that capture *113* reports arrive about every 30 s, including before the start request.

@GreenGrassBlueOcean
GreenGrassBlueOcean merged commit 84649c8 into OpenWebNet-HA:v2-phase1-architecture Oct 9, 2026
16 checks passed
@GreenGrassBlueOcean
GreenGrassBlueOcean deleted the fix/energy-stream-dimension1200-lifecycle branch October 21, 2026 19:35
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.

4 participants