Repository navigation
fix(config_flow): inject the HA websession into OWNd discovery and correct the OWNd licence - #757
Merged
GreenGrassBlueOcean merged 2 commits intoOct 21, 2026
Conversation
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
GreenGrassBlueOcean
force-pushed
the
fix/ownd-packaging-and-websession-alignment
branch
from
October 19, 2026 12:38
0b2dde0 to
df28f81
Compare
This was referenced Oct 21, 2026
…rrect the OWNd licence OWNd.discovery.find_gateways() and get_gateway() fetch the gateway's UPnP/SOAP description over HTTP and accept an optional aiohttp session. The config flow called them without one, so OWNd opened its own ClientSession per call. Pass async_get_clientsession(self.hass) and mark inject-websession done in quality_scale.yaml. quality_scale.yaml also described OWNd as MIT/GPL licensed; it is Apache-2.0 (OWNd LICENSE and pyproject.toml). Rebuilt on v2-phase1-architecture: the typing changes this branch carried before are in #765, and the OWNd pin stays at 2.0.0b11. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
GreenGrassBlueOcean
force-pushed
the
fix/ownd-packaging-and-websession-alignment
branch
from
October 21, 2026 11:33
cb640b1 to
00fcf09
Compare
…he typing docs Review follow-ups on #757: - async_step_custom still falls back to manual MAC entry on any UPnP lookup failure, but logs it at debug level; the redundant (asyncio.TimeoutError, Exception) tuple becomes Exception. - The websession test patches find_gateways/get_gateway with an explicit new_callable=AsyncMock, and the timeout test asserts the new debug line. - docs/quality_scale_plan.md: replace the stale "504 errors remain in 13 modules" with the actual state (71 modules clean, baseline 0). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
GreenGrassBlueOcean
deleted the
fix/ownd-packaging-and-websession-alignment
branch
October 21, 2026 15:03
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.
Rebuilt on
v2-phase1-architectureafter #765. The strict-typing half of the earlier version of this PR (installing OWNd instrict-typing.yml, dropping theOWNd.*mypy override, the 11 boundary fixes) landed in #765 against the PyPIOWNd==2.0.0b11pin, and thetests/test_connection.pypatch targets landed in #758. The OWNd pin stays atOWNd==2.0.0b11. What remains is the websession injection and the licence fix.1. What is the problem?
custom_components/myhome/config_flow.py,quality_scale.yaml):OWNd.discovery.find_gateways()andget_gateway()fetch the gateway's UPnP/SOAP description XML over HTTP (SSDPLOCATION, port49153on most gateways). Both acceptsession: aiohttp.ClientSession | None = None.MyhomeFlowHandler.async_step_userandasync_step_customcalled them without a session, so OWNd created and closed a privateClientSessionon every discovery, outside Home Assistant's managed connection pool.quality_scale.yamlmarkedinject-websessionasexempt("No HTTP is used"), which is not true for discovery.quality_scale.yaml):dependency-transparencydescribed OWNd as "MIT/GPL licensed". OWNd isApache-2.0(itsLICENSEand thelicense = "Apache-2.0"metadata on the 2.0.0b11 PyPI release).2. How is it solved?
config_flow.py):find_gateways(session=async_get_clientsession(self.hass))inasync_step_user.get_gateway(user_input["address"], session=async_get_clientsession(self.hass))inasync_step_custom.async_step_customstill falls back to manual MAC entry on any failure, but no longer silently. The redundantexcept (asyncio.TimeoutError, Exception)becomesexcept Exception as err, which logsUPnP lookup of <address> failed, asking for the MAC: <err>at debug level. The clause itself dates from 2020 (ce7a342d); it stays broad on purpose, because a timeout, an HTTP error or malformed XML must all lead to the manual step rather than a broken config flow.quality_scale.yaml,docs/quality_scale_plan.md):inject-websession:exempt→done, with a comment that names the two calls and says the bus itself stays on raw TCP.dependency-transparency: "MIT/GPL" → "Apache-2.0".docs/quality_scale_plan.mdnow matches. The stale "504 errors remain in 13 modules" line is replaced with the actual state: all 71 modules clean, andmypy_baseline.jsonat"total": 0.tests/test_config_flow.py):test_config_flow_injects_ha_websession_into_discoveryruns the user step and then the custom step, and asserts that bothfind_gatewaysandget_gatewayare awaited withsession=async_get_clientsession(hass). Both are patched with an explicitnew_callable=AsyncMock.test_custom_step_validation_and_timeoutalso asserts the new debug line for aget_gatewaytimeout.3. State Diagram
sequenceDiagram participant User as Home Assistant User participant CF as MyhomeFlowHandler (config_flow.py) participant HAHttp as async_get_clientsession(hass) participant OWNd as OWNd.discovery (find_gateways / get_gateway) participant GW as MyHOME Gateway (UPnP / SOAP XML) User->>CF: Start config flow (step_user / step_custom) CF->>HAHttp: async_get_clientsession(self.hass) HAHttp-->>CF: Shared aiohttp.ClientSession CF->>OWNd: find_gateways(session=…) / get_gateway(addr, session=…) OWNd->>GW: HTTP GET UPnP description XML (shared HA session) GW-->>OWNd: Device / service XML (model, serial, port) OWNd-->>CF: Discovered gateway metadata4. Where are the traces (real ones)?
tests/fixtures/traces/oracle_h4684_gateway/myhome_trace_oracle_h4684_gateway_identification.json: gateway discovery and identification metadata.5. What does the Firmware Oracle / Encyclopedia say?
F454,F455,MH202,MH201,F452,F453AVon port49153;MyHomeServer1,MH200N,MH200,H4890,HL4684via SSDP) serve their description XML over HTTP duringfind_gateways()/get_gateway(). This is the traffic that now uses Home Assistant's session.F461020011, Legrand3578) skip HTTP discovery and identify in-band viaWHO 13(*#13**15##) andWHO 1013(*#1013*0*1##) over the OpenWebNet session, which this PR does not touch.Verification
Full suite on
v2-phase1-architectureat3692dd11(fix(typing): check mypy --strict against the pinned OWNd 2.0.0b11 types #765 merged) against the releasedOWNd==2.0.0b11wheel with--cov=custom_components/myhome:4359 passed, 5 snapshots passed,TOTAL 14461 statements, 0 missed, 100.0%.scripts/typing_ratchet.pywith OWNd b11 installed:0 error(s) in 0 module(s); baseline 0.ruff check custom_components tests scripts,scripts/verify_ha_standards.py,scripts/sync_documentation.py --check: all pass.scripts/quality_scale_report.pylistsinject-websessionas ✅ done.V2 Architecture: New entities implement
handle_event()and do not manually subscribe viaasync_dispatcher_connect. (No entities are added or changed.)🤖 Generated with Claude Code