mirror of
https://github.com/home-assistant/core.git
synced 2026-12-02 11:33:11 -04:00
Also detect Tado X homes from the zones response (#195826)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
dd23b11719
commit
173f504b28
@@ -115,7 +115,11 @@ class TadoDataUpdateCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
||||
raise UpdateFailed(f"Error during Tado setup: {err}") from err
|
||||
|
||||
tado_home = tado_home_call["homes"][0]
|
||||
if tado_home.get("generation", "").lower() == "line_x":
|
||||
# /me usually has no generation, but Tado X homes return rooms
|
||||
# (roomId) instead of zones.
|
||||
if tado_home.get("generation", "").lower() == "line_x" or any(
|
||||
"roomId" in zone for zone in self.zones
|
||||
):
|
||||
raise ConfigEntryError(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="tado_x_unsupported",
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
[
|
||||
{
|
||||
"roomId": 1,
|
||||
"roomName": "Living room",
|
||||
"devices": [
|
||||
{
|
||||
"serialNumber": "VA1234567890",
|
||||
"type": "VA04",
|
||||
"firmwareVersion": "245.1",
|
||||
"connection": {
|
||||
"state": "CONNECTED"
|
||||
},
|
||||
"batteryState": "NORMAL"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"roomId": 2,
|
||||
"roomName": "Bedroom",
|
||||
"devices": []
|
||||
}
|
||||
]
|
||||
@@ -7,7 +7,7 @@ from unittest.mock import MagicMock, patch
|
||||
|
||||
from PyTado.http import Http
|
||||
import pytest
|
||||
from pytest_homeassistant.common import MockConfigEntry
|
||||
from pytest_homeassistant.common import MockConfigEntry, async_load_json_array_fixture
|
||||
|
||||
from homeassistant.components.tado import DOMAIN
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
@@ -101,3 +101,21 @@ async def test_tado_x_home_is_rejected_error(
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert mock_config_entry.state is ConfigEntryState.SETUP_ERROR
|
||||
|
||||
|
||||
async def test_tado_x_rooms_are_rejected_error(
|
||||
hass: HomeAssistant,
|
||||
mock_tado_api: MagicMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test a Tado X home is detected from its rooms when /me has no generation."""
|
||||
mock_tado_api.get_zones.return_value = await async_load_json_array_fixture(
|
||||
hass, "tadox_rooms.json", DOMAIN
|
||||
)
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert mock_config_entry.state is ConfigEntryState.SETUP_ERROR
|
||||
mock_tado_api.get_heating_circuits.assert_not_called()
|
||||
assert not hass.config_entries.flow.async_progress_by_handler(DOMAIN)
|
||||
|
||||
Reference in New Issue
Block a user