diff --git a/homeassistant/components/fritzbox/__init__.py b/homeassistant/components/fritzbox/__init__.py index fc65ed96459..38f0e375e87 100644 --- a/homeassistant/components/fritzbox/__init__.py +++ b/homeassistant/components/fritzbox/__init__.py @@ -2,7 +2,6 @@ from __future__ import annotations from abc import ABC, abstractmethod -from xml.etree.ElementTree import ParseError from pyfritzhome import Fritzhome, FritzhomeDevice, LoginError from pyfritzhome.devicetypes.fritzhomeentitybase import FritzhomeEntityBase @@ -44,14 +43,8 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: CONF_CONNECTIONS: fritz, } - try: - await hass.async_add_executor_job(fritz.update_templates) - except ParseError: - LOGGER.debug("Disable smarthome templates") - has_templates = False - else: - LOGGER.debug("Enable smarthome templates") - has_templates = True + has_templates = await hass.async_add_executor_job(fritz.has_templates) + LOGGER.debug("enable smarthome templates: %s", has_templates) coordinator = FritzboxDataUpdateCoordinator(hass, entry, has_templates) diff --git a/tests/components/fritzbox/test_init.py b/tests/components/fritzbox/test_init.py index 3aa155863d5..28476d88273 100644 --- a/tests/components/fritzbox/test_init.py +++ b/tests/components/fritzbox/test_init.py @@ -2,7 +2,6 @@ from __future__ import annotations from unittest.mock import Mock, call, patch -from xml.etree.ElementTree import ParseError from pyfritzhome import LoginError import pytest @@ -170,7 +169,7 @@ async def test_coordinator_update_after_reboot( assert await hass.config_entries.async_setup(entry.entry_id) assert fritz().update_devices.call_count == 2 - assert fritz().update_templates.call_count == 2 + assert fritz().update_templates.call_count == 1 assert fritz().get_devices.call_count == 1 assert fritz().get_templates.call_count == 1 assert fritz().login.call_count == 2 @@ -270,17 +269,3 @@ async def test_raise_config_entry_not_ready_when_offline(hass: HomeAssistant) -> entries = hass.config_entries.async_entries() config_entry = entries[0] assert config_entry.state is ConfigEntryState.SETUP_ERROR - - -async def test_disable_smarthome_templates(hass: HomeAssistant, fritz: Mock) -> None: - """Test smarthome templates are disabled.""" - entry = MockConfigEntry( - domain=FB_DOMAIN, - data=MOCK_CONFIG[FB_DOMAIN][CONF_DEVICES][0], - unique_id="any", - ) - entry.add_to_hass(hass) - fritz().update_templates.side_effect = [ParseError(), ""] - - assert await hass.config_entries.async_setup(entry.entry_id) - assert fritz().update_templates.call_count == 1