Bug: _get_base_url always uses HTTPS even on port 80, causing SSL handshake failure
Environment
- freebox-api: 1.3.1
- Python: 3.14.2
- Home Assistant: 2026.4.2 (HAOS 17.2)
- Freebox: v9 (fbxgw9-r1), firmware API v15
- Network: Freebox in bridge mode behind a UniFi router
Problem
When configuring the Freebox integration in Home Assistant with host=mafreebox.freebox.fr and port=80, the connection always fails with an SSL error:
ClientConnectorSSLError: Cannot connect to host mafreebox.freebox.fr:80 ssl:default
[SSL: RECORD_LAYER_FAILURE] record layer failure
The root cause is in aiofreepybox.py line 343:
def _get_base_url(self, host: str, port: str, api_version: str) -> str:
return f"https://{host}:{port}/api/{api_version}/"
This always builds an https:// URL regardless of the port, so connecting to port 80 (plain HTTP) triggers an SSL handshake failure.
In bridge mode, the Freebox is not directly reachable via a local IP. The only working endpoint for the initial pairing (token request) is http://mafreebox.freebox.fr:80 via Free's reverse proxy — HTTPS on port 24637 is refused externally.
Fix
The URL scheme should depend on the port:
def _get_base_url(self, host: str, port: str, api_version: str) -> str:
scheme = "http" if str(port) == "80" else "https"
return f"{scheme}://{host}:{port}/api/{api_version}/"
This fix allows successful pairing via HTTP on port 80, after which the library correctly switches to HTTPS on port 24637 for all subsequent API calls.
Bug:
_get_base_urlalways uses HTTPS even on port 80, causing SSL handshake failureEnvironment
Problem
When configuring the Freebox integration in Home Assistant with
host=mafreebox.freebox.frandport=80, the connection always fails with an SSL error:The root cause is in
aiofreepybox.pyline 343:This always builds an
https://URL regardless of the port, so connecting to port 80 (plain HTTP) triggers an SSL handshake failure.In bridge mode, the Freebox is not directly reachable via a local IP. The only working endpoint for the initial pairing (token request) is
http://mafreebox.freebox.fr:80via Free's reverse proxy — HTTPS on port 24637 is refused externally.Fix
The URL scheme should depend on the port:
This fix allows successful pairing via HTTP on port 80, after which the library correctly switches to HTTPS on port 24637 for all subsequent API calls.