Use otbr domain as dataset source (#89653)
parent
a99f6f7124
commit
2f4e9c8ef3
|
@ -60,7 +60,6 @@ class OTBRData:
|
|||
|
||||
url: str
|
||||
api: python_otbr_api.OTBR
|
||||
dataset_source: str
|
||||
|
||||
@_handle_otbr_error
|
||||
async def set_enabled(self, enabled: bool) -> None:
|
||||
|
@ -138,7 +137,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
"""Set up an Open Thread Border Router config entry."""
|
||||
api = python_otbr_api.OTBR(entry.data["url"], async_get_clientsession(hass), 10)
|
||||
|
||||
otbrdata = OTBRData(entry.data["url"], api, entry.title)
|
||||
otbrdata = OTBRData(entry.data["url"], api)
|
||||
try:
|
||||
dataset_tlvs = await otbrdata.get_active_dataset_tlvs()
|
||||
except (
|
||||
|
@ -149,7 +148,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
raise ConfigEntryNotReady("Unable to connect") from err
|
||||
if dataset_tlvs:
|
||||
_warn_on_default_network_settings(hass, entry, dataset_tlvs)
|
||||
await async_add_dataset(hass, otbrdata.dataset_source, dataset_tlvs.hex())
|
||||
await async_add_dataset(hass, DOMAIN, dataset_tlvs.hex())
|
||||
|
||||
hass.data[DOMAIN] = otbrdata
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ async def websocket_create_network(
|
|||
connection.send_error(msg["id"], "get_active_dataset_tlvs_empty", "")
|
||||
return
|
||||
|
||||
await async_add_dataset(hass, data.dataset_source, dataset_tlvs.hex())
|
||||
await async_add_dataset(hass, DOMAIN, dataset_tlvs.hex())
|
||||
|
||||
connection.send_result(msg["id"])
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ async def test_import_dataset(hass: HomeAssistant) -> None:
|
|||
) as mock_add:
|
||||
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
|
||||
mock_add.assert_called_once_with(config_entry.title, DATASET_CH16.hex())
|
||||
mock_add.assert_called_once_with(otbr.DOMAIN, DATASET_CH16.hex())
|
||||
assert not issue_registry.async_get_issue(
|
||||
domain=otbr.DOMAIN, issue_id=f"insecure_thread_network_{config_entry.entry_id}"
|
||||
)
|
||||
|
@ -72,7 +72,7 @@ async def test_import_insecure_dataset(hass: HomeAssistant, dataset: bytes) -> N
|
|||
) as mock_add:
|
||||
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
|
||||
mock_add.assert_called_once_with(config_entry.title, dataset.hex())
|
||||
mock_add.assert_called_once_with(otbr.DOMAIN, dataset.hex())
|
||||
assert issue_registry.async_get_issue(
|
||||
domain=otbr.DOMAIN, issue_id=f"insecure_thread_network_{config_entry.entry_id}"
|
||||
)
|
||||
|
|
|
@ -4,6 +4,7 @@ from unittest.mock import patch
|
|||
import pytest
|
||||
import python_otbr_api
|
||||
|
||||
from homeassistant.components import otbr
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
|
@ -130,7 +131,7 @@ async def test_create_network(
|
|||
assert set_enabled_mock.mock_calls[0][1][0] is False
|
||||
assert set_enabled_mock.mock_calls[1][1][0] is True
|
||||
get_active_dataset_tlvs_mock.assert_called_once()
|
||||
mock_add.assert_called_once_with("Open Thread Border Router", DATASET_CH16.hex())
|
||||
mock_add.assert_called_once_with(otbr.DOMAIN, DATASET_CH16.hex())
|
||||
|
||||
|
||||
async def test_create_network_no_entry(
|
||||
|
|
Loading…
Reference in New Issue