Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions homeassistant/components/fritzbox/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Comment thread
mib1185 marked this conversation as resolved.

coordinator = FritzboxDataUpdateCoordinator(hass, entry, has_templates)

Expand Down
17 changes: 1 addition & 16 deletions tests/components/fritzbox/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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