Description
I recently changed my Homeassistant hardware. Afterwards I was not able to use the FRITZ!SmartHome integration. I got the following error:
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: http://fritz.box/webservices/homeautoswitch.lua?switchcmd=gettemplatelistinfos&sid=88a3e4bb76d62fe0
The Fritz!Box reports an failed log in. Tests with the CLI results in the same error, but not on my normal PC. It seems to be similar to the problem of the following report.
Further investigation using wireshard revealed the problem:
The used IPv6 address changed between the different request and the address needs to be the same, otherwise the request failes.
My first idea was to get the source IP address of the first request and set it for further connections. But getting the source address is tricky and did not work with the Fritz!Box (further information).
I came up with the following quick and dirty solution in fritzhome.py
:
import requests
requests.packages.urllib3.util.connection.HAS_IPV6 = False
Do you have an idea for a better solution? Especially for integration into pyfritzhome.
Some background on the environment: Raspberry Pi OS Lite 64 based on Debian 12 with the IP addresses assigned via DHCP.