[PATCH] feat: add Force IPv4 option to config and options flow#131
Open
baylanger wants to merge 1 commit into
Open
[PATCH] feat: add Force IPv4 option to config and options flow#131baylanger wants to merge 1 commit into
baylanger wants to merge 1 commit into
Conversation
Author
|
I believe the PR is good but later today when I have time I'll test again both PRs and post an update. |
baylanger
commented
May 14, 2026
| preheat_duration: Pre-heat duration in minutes (default 120) | ||
| force_ipv4: When True, restricts the aiohttp session to IPv4 | ||
| only (family=socket.AF_INET). Useful on dual-stack hosts | ||
| where Hydro-Québec servers are not reachable over IPv6. |
Author
There was a problem hiding this comment.
Oops ... comment needs to mention traffic not from Quebec/Canada.
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.
Context: Hydro-Québec servers geo-block traffic originating from outside
Quebec/Canada, returning a timeout. On dual-stack hosts, IPv6 traffic may
route through a non-Canadian path (e.g. via a tunnel broker). Forcing IPv4
ensures all connections use the Canadian IPv4 address.
Adds a 'Force IPv4' toggle to the first setup step (Choose Connection
Mode), visible in both the initial setup wizard and the options flow.
When enabled, all aiohttp sessions are created with a TCPConnector
restricted to socket.AF_INET (IPv4 only):
The correct CookieJar settings (quote_cookie=False, unsafe=True,
requote_redirect_url=False) are applied to match what HydroClient uses
internally, which is required for Azure B2C authentication to succeed.
Improves exception logging during login (HTTP status code logged on
HydroQcHTTPError, warning logged on RuntimeError portal unavailable).
FIX a pre-existing naming mismatch: Home Assistant resolves UI labels for
a config flow step by matching the step's step_id against the keys in
strings.json and the translation files. The function
async_step_opendata_rate was registered with step_id="opendata_rate" in
config_flow/base.py, but all translation files defined the labels under
the key "opendata_offer". This mismatch meant translated labels for
contract name, rate selection, and the new Force IPv4 option were never
shown to the user. Fixed by renaming the function and step_id in
config_flow/base.py to "opendata_offer" to match the existing translation
keys. No changes were needed in strings.json or the translation files.
Depends on: PR to hydroqc (Hydro-Quebec-API-Wrapper) adding the session
parameter passthrough in WebUser.init().
Changes:
IPv4 session with correct CookieJar for temp WebUser during login;
write CONF_FORCE_IPV4 into all entry_data paths; improve exception
logging; rename async_step_opendata_rate -> async_step_opendata_offer
to match existing translation keys
reads from both options and data for backward compatibility with
existing entries
correct CookieJar into WebUser; pass force_ipv4 to PublicDataClient
in _get_session()
explanation note in user step and options step