core: Upgrade to 2022.12 breaks Fritzbox integration

The problem

Integration stopped working after upgrade.

What version of Home Assistant Core has the issue?

2022.12.0

What was the last working version of Home Assistant Core?

2022.11.5

What type of installation are you running?

Home Assistant OS

Integration causing the issue

fritz.box

Link to integration documentation on our website

https://www.home-assistant.io/integrations/fritzbox

Diagnostics information

Logger: homeassistant.components.fritzbox
Source: components/fritzbox/coordinator.py:48
Integration: AVM FRITZ!SmartHome (documentation, issues)
First occurred: 15:49:28 (11 occurrences)
Last logged: 15:55:30

Unexpected error fetching *** data: no element found: line 1, column 0
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 225, in _async_refresh
    self.data = await self._async_update_data()
  File "/usr/src/homeassistant/homeassistant/components/fritzbox/coordinator.py", line 87, in _async_update_data
    return await self.hass.async_add_executor_job(self._update_fritz_devices)
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/fritzbox/coordinator.py", line 48, in _update_fritz_devices
    self.fritz.update_templates()
  File "/usr/local/lib/python3.10/site-packages/pyfritzhome/fritzhome.py", line 357, in update_templates
    for element in self.get_template_elements():
  File "/usr/local/lib/python3.10/site-packages/pyfritzhome/fritzhome.py", line 371, in get_template_elements
    return self._get_listinfo_elements("template")
  File "/usr/local/lib/python3.10/site-packages/pyfritzhome/fritzhome.py", line 144, in _get_listinfo_elements
    dom = ElementTree.fromstring(plain)
  File "/usr/local/lib/python3.10/xml/etree/ElementTree.py", line 1343, in XML
    return parser.close()
xml.etree.ElementTree.ParseError: no element found: line 1, column 0

Example YAML snippet

No response

Anything in the logs that might be useful for us?

In front of the stack trace:

2022-12-08 16:07:32.048 DEBUG (MainThread) [homeassistant.components.fritzbox] Finished fetching *** data in 0.688 seconds (success: False)
2022-12-08 16:07:52.517 INFO (SyncWorker_4) [pyfritzhome.fritzhome] Updating Devices ...
2022-12-08 16:07:52.865 DEBUG (SyncWorker_4) [pyfritzhome.fritzhome] <Element 'devicelist' at 0x7f55360b30>
2022-12-08 16:07:52.866 INFO (SyncWorker_4) [pyfritzhome.fritzhome] Adding new Device 11657 0483368
2022-12-08 16:07:52.867 DEBUG (SyncWorker_4) [pyfritzhome.devicetypes.fritzhomeentitybase] b'<device identifier="11657 0483368" id="16" functionbitmask="2944" fwversion="03.87" manufacturer="AVM" productname="FRITZ!DECT 210"><present>1</present><name>Terasse</name><switch><state>1</state><mode>manuell</mode><lock>0</lock><devicelock>0</devicelock></switch><powermeter><power>960</power><energy>2125005</energy></powermeter><temperature><celsius>45</celsius><offset>20</offset></temperature></device>'
2022-12-08 16:07:52.868 INFO (SyncWorker_4) [pyfritzhome.fritzhome] Adding new Device 11630 0270389
2022-12-08 16:07:52.869 DEBUG (SyncWorker_4) [pyfritzhome.devicetypes.fritzhomeentitybase] b'<device identifier="11630 0270389" id="17" functionbitmask="2944" fwversion="03.87" manufacturer="AVM" productname="FRITZ!DECT 200"><present>1</present><name>K&#252;hlschrank</name><switch><state>0</state><mode>manuell</mode><lock>0</lock><devicelock>0</devicelock></switch><powermeter><power>0</power><energy>82490</energy></powermeter><temperature><celsius>190</celsius><offset>-30</offset></temperature></device>'
2022-12-08 16:07:52.870 INFO (SyncWorker_4) [pyfritzhome.fritzhome] Adding new Device 11630 0286673
2022-12-08 16:07:52.871 DEBUG (SyncWorker_4) [pyfritzhome.devicetypes.fritzhomeentitybase] b'<device identifier="11630 0286673" id="18" functionbitmask="2944" fwversion="03.87" manufacturer="AVM" productname="FRITZ!DECT 200"><present>1</present><name>Wohnzimmer</name><switch><state>0</state><mode>manuell</mode><lock>0</lock><devicelock>0</devicelock></switch><powermeter><power>0</power><energy>212166</energy></powermeter><temperature><celsius>185</celsius><offset>-10</offset></temperature></device>'
2022-12-08 16:07:52.873 INFO (SyncWorker_4) [pyfritzhome.fritzhome] Updating Templates ...
2022-12-08 16:07:53.208 ERROR (MainThread) [homeassistant.components.fritzbox] Unexpected error fetching 3c3b1b62b09edb953257c0b29c74b1a2 data: no element found: line 1, column 0

Additional information

Fritzbox 7390

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 22 (7 by maintainers)

Most upvoted comments

@tobixx @PCDoc0815 @Ventusfahrer @crazyduck @rugosch please test again as soon as 2022.12.2 is available (should be within next few days)

so ist es: gefixt mit 2022.12.4!

Viele Dank an @mib1185 !!!

sorry, should stay in English:

Confirm: fixed with 2022.12.4.

Thanks a lot @mib1185

Just upgraded to 2022.12.4 - and voila - nothing to see there (in the positive way: no tracebacks - everything functional). Thanks @mib1185 - that was fast! And thanks to all others who tried to help him! (while I couldn’t because still waiting for a free moment where no one would be at home - else I would earn some sh*** storm if anything would not work - like kids running into walls in the dark … 😉 )

@rugosch @Ventusfahrer fix will be available with 2022.12.4

Hi @mib1185, the result is empty.

>>> result = fritz._aha_request("gettemplateinfos")
>>> print(result)

>>> print(result,)

>>> type(result)
<class 'str'>
>>> len(result)
0

Did it in a live console in a python 3.9 docker container with your explained steps

Thanks a lot! 2022.12.4 working like a charm

I yesterday installed 2022.12 on two of my home-assistant systems. The first one (using an Fritz!Box 6660 with Fritz!OS 7.39 (a beta of the upcoming 7.50) with one connected Fritz!DECT200 switch did not show any problems. The switch continues to work without any problem after the upgrade.

On the second one (an (older) Fritz!Box 7390 with Fritz!OS 6.87 with one Fritz!DECT200 ) I hat the same problem documented above. Meanwhile 2022.12.1 was available and installed, but did not change anything.

The ha logger-configuration was adjusted like described above, here is the output in home-assistant.log

2022-12-09 13:19:46.364 INFO (SyncWorker_0) [pyfritzhome.fritzhome] Updating Devices ...
2022-12-09 13:19:47.357 DEBUG (SyncWorker_0) [pyfritzhome.fritzhome] <Element 'devicelist' at 0xffff96314310>
2022-12-09 13:19:47.357 INFO (SyncWorker_0) [pyfritzhome.fritzhome] Adding new Device 08761 0060334
2022-12-09 13:19:47.362 DEBUG (SyncWorker_0) [pyfritzhome.devicetypes.fritzhomeentitybase] b'<device identifier="08761 0060334" id="16" functionbitmask="2944" fwversion="03.87" manufacturer="AVM" productname="FRITZ!DECT 200"><present>1</present><name>FRITZ!DECT 200 #1</name><switch><state>1</state><mode>auto</mode><lock>0</lock><devicelock>0</devicelock></switch><powermeter><power>2070</power><energy>57354</energy></powermeter><temperature><celsius>115</celsius><offset>0</offset></temperature></device>'
2022-12-09 13:19:47.362 INFO (SyncWorker_0) [pyfritzhome.fritzhome] Updating Templates ...
2022-12-09 13:19:48.338 ERROR (MainThread) [homeassistant.components.fritzbox] Unexpected error fetching a894e8da8a81a177cddda0778fd04fa2 data: no element found: line 1, column 0
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 225, in _async_refresh
    self.data = await self._async_update_data()
  File "/usr/src/homeassistant/homeassistant/components/fritzbox/coordinator.py", line 87, in _async_update_data
    return await self.hass.async_add_executor_job(self._update_fritz_devices)
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/fritzbox/coordinator.py", line 48, in _update_fritz_devices
    self.fritz.update_templates()
  File "/usr/local/lib/python3.10/site-packages/pyfritzhome/fritzhome.py", line 357, in update_templates
    for element in self.get_template_elements():
  File "/usr/local/lib/python3.10/site-packages/pyfritzhome/fritzhome.py", line 371, in get_template_elements
    return self._get_listinfo_elements("template")
  File "/usr/local/lib/python3.10/site-packages/pyfritzhome/fritzhome.py", line 144, in _get_listinfo_elements
    dom = ElementTree.fromstring(plain)
  File "/usr/local/lib/python3.10/xml/etree/ElementTree.py", line 1343, in XML
    return parser.close()
xml.etree.ElementTree.ParseError: no element found: line 1, column 0
2022-12-09 13:19:48.353 DEBUG (MainThread) [homeassistant.components.fritzbox] Finished fetching a894e8da8a81a177cddda0778fd04fa2 data in 1.989 seconds (success: False)
2022-12-09 13:19:48.353 WARNING (MainThread) [homeassistant.config_entries] Config entry 'SFG-Bensheim' for fritzbox integration not ready yet: no element found: line 1, column 0; Retrying in background