mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 00:37:13 +00:00
Set default Matter fabric label (#127252)
This commit is contained in:
parent
df8269e772
commit
abf3da2fa1
@ -9,6 +9,7 @@ from matter_server.client import MatterClient
|
|||||||
from matter_server.client.exceptions import (
|
from matter_server.client.exceptions import (
|
||||||
CannotConnect,
|
CannotConnect,
|
||||||
InvalidServerVersion,
|
InvalidServerVersion,
|
||||||
|
NotConnected,
|
||||||
ServerVersionTooNew,
|
ServerVersionTooNew,
|
||||||
ServerVersionTooOld,
|
ServerVersionTooOld,
|
||||||
)
|
)
|
||||||
@ -132,6 +133,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
listen_task.cancel()
|
listen_task.cancel()
|
||||||
raise ConfigEntryNotReady("Matter client not ready") from err
|
raise ConfigEntryNotReady("Matter client not ready") from err
|
||||||
|
|
||||||
|
# Set default fabric
|
||||||
|
try:
|
||||||
|
await matter_client.set_default_fabric_label(
|
||||||
|
hass.config.location_name or "Home"
|
||||||
|
)
|
||||||
|
except (NotConnected, MatterError) as err:
|
||||||
|
raise ConfigEntryNotReady("Failed to set default fabric label") from err
|
||||||
|
|
||||||
if DOMAIN not in hass.data:
|
if DOMAIN not in hass.data:
|
||||||
hass.data[DOMAIN] = {}
|
hass.data[DOMAIN] = {}
|
||||||
|
|
||||||
|
@ -6,6 +6,6 @@
|
|||||||
"dependencies": ["websocket_api"],
|
"dependencies": ["websocket_api"],
|
||||||
"documentation": "https://www.home-assistant.io/integrations/matter",
|
"documentation": "https://www.home-assistant.io/integrations/matter",
|
||||||
"iot_class": "local_push",
|
"iot_class": "local_push",
|
||||||
"requirements": ["python-matter-server==6.5.2"],
|
"requirements": ["python-matter-server==6.6.0"],
|
||||||
"zeroconf": ["_matter._tcp.local.", "_matterc._udp.local."]
|
"zeroconf": ["_matter._tcp.local.", "_matterc._udp.local."]
|
||||||
}
|
}
|
||||||
|
@ -2352,7 +2352,7 @@ python-linkplay==0.0.12
|
|||||||
# python-lirc==1.2.3
|
# python-lirc==1.2.3
|
||||||
|
|
||||||
# homeassistant.components.matter
|
# homeassistant.components.matter
|
||||||
python-matter-server==6.5.2
|
python-matter-server==6.6.0
|
||||||
|
|
||||||
# homeassistant.components.xiaomi_miio
|
# homeassistant.components.xiaomi_miio
|
||||||
python-miio==0.5.12
|
python-miio==0.5.12
|
||||||
|
@ -1870,7 +1870,7 @@ python-kasa[speedups]==0.7.4
|
|||||||
python-linkplay==0.0.12
|
python-linkplay==0.0.12
|
||||||
|
|
||||||
# homeassistant.components.matter
|
# homeassistant.components.matter
|
||||||
python-matter-server==6.5.2
|
python-matter-server==6.6.0
|
||||||
|
|
||||||
# homeassistant.components.xiaomi_miio
|
# homeassistant.components.xiaomi_miio
|
||||||
python-miio==0.5.12
|
python-miio==0.5.12
|
||||||
|
@ -9,6 +9,7 @@ from unittest.mock import AsyncMock, MagicMock, call, patch
|
|||||||
from aiohasupervisor import SupervisorError
|
from aiohasupervisor import SupervisorError
|
||||||
from matter_server.client.exceptions import (
|
from matter_server.client.exceptions import (
|
||||||
CannotConnect,
|
CannotConnect,
|
||||||
|
NotConnected,
|
||||||
ServerVersionTooNew,
|
ServerVersionTooNew,
|
||||||
ServerVersionTooOld,
|
ServerVersionTooOld,
|
||||||
)
|
)
|
||||||
@ -64,6 +65,7 @@ async def test_entry_setup_unload(
|
|||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert matter_client.connect.call_count == 1
|
assert matter_client.connect.call_count == 1
|
||||||
|
assert matter_client.set_default_fabric_label.call_count == 1
|
||||||
assert entry.state is ConfigEntryState.LOADED
|
assert entry.state is ConfigEntryState.LOADED
|
||||||
entity_state = hass.states.get("light.mock_onoff_light_light")
|
entity_state = hass.states.get("light.mock_onoff_light_light")
|
||||||
assert entity_state
|
assert entity_state
|
||||||
@ -108,6 +110,26 @@ async def test_connect_failed(
|
|||||||
assert entry.state is ConfigEntryState.SETUP_RETRY
|
assert entry.state is ConfigEntryState.SETUP_RETRY
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("expected_lingering_tasks", [True])
|
||||||
|
async def test_set_default_fabric_label_failed(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
matter_client: MagicMock,
|
||||||
|
) -> None:
|
||||||
|
"""Test failure during client connection."""
|
||||||
|
entry = MockConfigEntry(domain=DOMAIN, data={"url": "ws://localhost:5580/ws"})
|
||||||
|
entry.add_to_hass(hass)
|
||||||
|
|
||||||
|
matter_client.set_default_fabric_label.side_effect = NotConnected()
|
||||||
|
|
||||||
|
await hass.config_entries.async_setup(entry.entry_id)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
assert matter_client.connect.call_count == 1
|
||||||
|
assert matter_client.set_default_fabric_label.call_count == 1
|
||||||
|
|
||||||
|
assert entry.state is ConfigEntryState.SETUP_RETRY
|
||||||
|
|
||||||
|
|
||||||
async def test_connect_timeout(
|
async def test_connect_timeout(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
matter_client: MagicMock,
|
matter_client: MagicMock,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user