Skip to content

Commit 25d8a48

Browse files
committed
Load of FRITZ!OS version via direct request.
Loads the FRITZ!OS version via direct HTTP request & response JSON parsing instead of using Fritzconnection. This removes an external dependency and also reduces the number of logins/interactions to the device which could cause stress on older, less performant models and also reduces the number of parallel sessions.
1 parent 008c4e4 commit 25d8a48

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

fritz_advanced_thermostat/fritz_advanced_thermostat.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import re
33
import requests
44
from .errors import FritzAdvancedThermostatConnectionError, FritzAdvancedThermostatCompatibilityError, FritzAdvancedThermostatExecutionError, FritzAdvancedThermostatKeyError
5-
from fritzconnection import FritzConnection
65
from pyfritzhome import Fritzhome
76
from selenium import webdriver
87
from selenium.webdriver.chrome.options import Options
@@ -55,9 +54,7 @@ def __init__(self,
5554
self._sid = fh._sid
5655
self._devices = fh._devices
5756
self._prefixed_host = fh.get_prefixed_host()
58-
# Check Fritz!OS via FritzConnection
59-
fc = FritzConnection(address=host, user=user, password=password)
60-
self._fritzos = fc.system_version
57+
self._fritzos = self._load_fritzos(fh.get_prefixed_host())
6158
self._supported_firmware = ['7.29', '7.30', '7.31', '7.56', '7.57']
6259
# Set basic properties
6360
self._experimental = experimental
@@ -100,6 +97,18 @@ def __init__(self,
10097
self._selenium_options.add_argument('ignore-certificate-errors')
10198
self._check_fritzos()
10299

100+
def _load_fritzos(self, url):
101+
data = {
102+
"xhr": 1,
103+
"sid": self._sid,
104+
"page": "overview",
105+
}
106+
107+
response = requests.post(url + "/data.lua", data=data, allow_redirects=True, timeout=300)
108+
response.raise_for_status()
109+
110+
return json.loads(response.text)["data"]["fritzos"]["nspver"]
111+
103112
def _check_fritzos(self):
104113
if self._fritzos not in self._supported_firmware:
105114
if self._experimental:

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
fritzconnection>=1.12.2
21
pyfritzhome>=0.6.8
32
requests>=2.31.0
43
selenium==4.10.0

0 commit comments

Comments
 (0)