Closed cdce8p closed 1 year ago
Thank you very much for this pull-request, I was not aware of this url. It could also make the cache verification faster. Indeed the url seems to be designed for this kind of usage.
I would like to add this feature. However, based on already existing and tested functions, the code could be implemented in a more compact way, by just adding a couple of lines to the core.fritzconnection.py
file.
At first the URI should get defined as a constant on line 41, so it is grouped with the other URIs for the router interface descriptions:
...
FRITZ_BOXINFO_FILE = "jason_boxinfo.xml"
FRITZ_IGD_DESC_FILE = "igddesc.xml"
...
Line 281 would be the proper location to insert a new property updatecheck
. I think this is a better name, because the content indicates this usecase and get_device_info
is already used in fritzstatus, and get_box_info
sounds like a synonyme of the latter. I suggest an implementation like:
@property
def updatecheck(self):
"""
Dictionary with information about the hard- and software version of
the device (http://fritz.box/jason_boxinfo.xml).
"""
xml_data = get_xml_root(
f"{self.address}/{FRITZ_BOXINFO_URL}",
timeout=self.timeout,
session=self.session
)
return {localname(elem): elem.text for elem in xml_data}
Last but not least the utility functions must get imported. So line 27 should get changed to:
from .utils import (
get_bool_env,
get_xml_root,
localname
)
Thanks for the detailed suggestions. I've implemented them in the last commit. For now I removed the test case, let me know if I should add it back (and where it should be located).
I'm not sure whether this needs a test. But if there is one, it should be in tests/test_fritzconnection.py
.
Add method to get and parse
box_info
. In general it returns similar information toDeviceInfo
. However, the endpoint doesn't require any authorization.For contrast
DeviceInfo
does require theFritz!Box Configuration
permission which is basically admin access. In Home Assistant we currently useDeviceInfo
to get the Serial number. Understandably, some users aren't comfortable with giving admin access to a third party application.References