diff --git a/homeassistant/components/otbr/config_flow.py b/homeassistant/components/otbr/config_flow.py index 32842ad6cc7..0a554806c32 100644 --- a/homeassistant/components/otbr/config_flow.py +++ b/homeassistant/components/otbr/config_flow.py @@ -50,7 +50,7 @@ class OTBRConfigFlow(ConfigFlow, domain=DOMAIN): "not importing TLV with channel %s", thread_dataset_channel ) await api.create_active_dataset( - python_otbr_api.OperationalDataSet( + python_otbr_api.ActiveDataSet( channel=allowed_channel if allowed_channel else DEFAULT_CHANNEL, network_name="home-assistant", ) diff --git a/homeassistant/components/otbr/manifest.json b/homeassistant/components/otbr/manifest.json index c10a2417dc6..f092bff48b9 100644 --- a/homeassistant/components/otbr/manifest.json +++ b/homeassistant/components/otbr/manifest.json @@ -8,5 +8,5 @@ "documentation": "https://www.home-assistant.io/integrations/otbr", "integration_type": "service", "iot_class": "local_polling", - "requirements": ["python-otbr-api==1.0.9"] + "requirements": ["python-otbr-api==2.0.0"] } diff --git a/homeassistant/components/otbr/util.py b/homeassistant/components/otbr/util.py index b2ce05f280c..a625ba09018 100644 --- a/homeassistant/components/otbr/util.py +++ b/homeassistant/components/otbr/util.py @@ -79,7 +79,7 @@ class OTBRData: @_handle_otbr_error async def create_active_dataset( - self, dataset: python_otbr_api.OperationalDataSet + self, dataset: python_otbr_api.ActiveDataSet ) -> None: """Create an active operational dataset.""" return await self.api.create_active_dataset(dataset) diff --git a/homeassistant/components/otbr/websocket_api.py b/homeassistant/components/otbr/websocket_api.py index 2189df363ba..7fd0f8187b2 100644 --- a/homeassistant/components/otbr/websocket_api.py +++ b/homeassistant/components/otbr/websocket_api.py @@ -80,7 +80,7 @@ async def websocket_create_network( try: await data.create_active_dataset( - python_otbr_api.OperationalDataSet( + python_otbr_api.ActiveDataSet( channel=channel, network_name="home-assistant" ) ) diff --git a/homeassistant/components/thread/manifest.json b/homeassistant/components/thread/manifest.json index 3d61315f3d1..da142be49aa 100644 --- a/homeassistant/components/thread/manifest.json +++ b/homeassistant/components/thread/manifest.json @@ -7,6 +7,6 @@ "documentation": "https://www.home-assistant.io/integrations/thread", "integration_type": "service", "iot_class": "local_polling", - "requirements": ["python-otbr-api==1.0.9", "pyroute2==0.7.5"], + "requirements": ["python-otbr-api==2.0.0", "pyroute2==0.7.5"], "zeroconf": ["_meshcop._udp.local."] } diff --git a/requirements_all.txt b/requirements_all.txt index fa680bf6df9..a0493a79d35 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -2109,7 +2109,7 @@ python-opensky==0.0.7 # homeassistant.components.otbr # homeassistant.components.thread -python-otbr-api==1.0.9 +python-otbr-api==2.0.0 # homeassistant.components.picnic python-picnic-api==1.1.0 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 4e3847687c6..f64d37ff45f 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -1532,7 +1532,7 @@ python-nest==4.2.0 # homeassistant.components.otbr # homeassistant.components.thread -python-otbr-api==1.0.9 +python-otbr-api==2.0.0 # homeassistant.components.picnic python-picnic-api==1.1.0 diff --git a/tests/components/otbr/test_config_flow.py b/tests/components/otbr/test_config_flow.py index 9fe30d709a7..faec90282df 100644 --- a/tests/components/otbr/test_config_flow.py +++ b/tests/components/otbr/test_config_flow.py @@ -72,8 +72,8 @@ async def test_user_flow_router_not_setup( """ url = "http://custom_url:1234" aioclient_mock.get(f"{url}/node/dataset/active", status=HTTPStatus.NO_CONTENT) - aioclient_mock.post(f"{url}/node/dataset/active", status=HTTPStatus.ACCEPTED) - aioclient_mock.post(f"{url}/node/state", status=HTTPStatus.OK) + aioclient_mock.put(f"{url}/node/dataset/active", status=HTTPStatus.CREATED) + aioclient_mock.put(f"{url}/node/state", status=HTTPStatus.OK) result = await hass.config_entries.flow.async_init( otbr.DOMAIN, context={"source": "user"} @@ -96,14 +96,14 @@ async def test_user_flow_router_not_setup( ) # Check we create a dataset and enable the router - assert aioclient_mock.mock_calls[-2][0] == "POST" + assert aioclient_mock.mock_calls[-2][0] == "PUT" assert aioclient_mock.mock_calls[-2][1].path == "/node/dataset/active" assert aioclient_mock.mock_calls[-2][2] == { "Channel": 15, "NetworkName": "home-assistant", } - assert aioclient_mock.mock_calls[-1][0] == "POST" + assert aioclient_mock.mock_calls[-1][0] == "PUT" assert aioclient_mock.mock_calls[-1][1].path == "/node/state" assert aioclient_mock.mock_calls[-1][2] == "enable" @@ -216,8 +216,8 @@ async def test_hassio_discovery_flow_router_not_setup( """ url = "http://core-silabs-multiprotocol:8081" aioclient_mock.get(f"{url}/node/dataset/active", status=HTTPStatus.NO_CONTENT) - aioclient_mock.post(f"{url}/node/dataset/active", status=HTTPStatus.ACCEPTED) - aioclient_mock.post(f"{url}/node/state", status=HTTPStatus.OK) + aioclient_mock.put(f"{url}/node/dataset/active", status=HTTPStatus.CREATED) + aioclient_mock.put(f"{url}/node/state", status=HTTPStatus.OK) with patch( "homeassistant.components.otbr.config_flow.async_get_preferred_dataset", @@ -231,14 +231,14 @@ async def test_hassio_discovery_flow_router_not_setup( ) # Check we create a dataset and enable the router - assert aioclient_mock.mock_calls[-2][0] == "POST" + assert aioclient_mock.mock_calls[-2][0] == "PUT" assert aioclient_mock.mock_calls[-2][1].path == "/node/dataset/active" assert aioclient_mock.mock_calls[-2][2] == { "Channel": 15, "NetworkName": "home-assistant", } - assert aioclient_mock.mock_calls[-1][0] == "POST" + assert aioclient_mock.mock_calls[-1][0] == "PUT" assert aioclient_mock.mock_calls[-1][1].path == "/node/state" assert aioclient_mock.mock_calls[-1][2] == "enable" @@ -268,8 +268,8 @@ async def test_hassio_discovery_flow_router_not_setup_has_preferred( """ url = "http://core-silabs-multiprotocol:8081" aioclient_mock.get(f"{url}/node/dataset/active", status=HTTPStatus.NO_CONTENT) - aioclient_mock.put(f"{url}/node/dataset/active", status=HTTPStatus.ACCEPTED) - aioclient_mock.post(f"{url}/node/state", status=HTTPStatus.OK) + aioclient_mock.put(f"{url}/node/dataset/active", status=HTTPStatus.CREATED) + aioclient_mock.put(f"{url}/node/state", status=HTTPStatus.OK) with patch( "homeassistant.components.otbr.config_flow.async_get_preferred_dataset", @@ -287,7 +287,7 @@ async def test_hassio_discovery_flow_router_not_setup_has_preferred( assert aioclient_mock.mock_calls[-2][1].path == "/node/dataset/active" assert aioclient_mock.mock_calls[-2][2] == DATASET_CH15.hex() - assert aioclient_mock.mock_calls[-1][0] == "POST" + assert aioclient_mock.mock_calls[-1][0] == "PUT" assert aioclient_mock.mock_calls[-1][1].path == "/node/state" assert aioclient_mock.mock_calls[-1][2] == "enable" @@ -318,8 +318,8 @@ async def test_hassio_discovery_flow_router_not_setup_has_preferred_2( """ url = "http://core-silabs-multiprotocol:8081" aioclient_mock.get(f"{url}/node/dataset/active", status=HTTPStatus.NO_CONTENT) - aioclient_mock.post(f"{url}/node/dataset/active", status=HTTPStatus.ACCEPTED) - aioclient_mock.post(f"{url}/node/state", status=HTTPStatus.OK) + aioclient_mock.put(f"{url}/node/dataset/active", status=HTTPStatus.CREATED) + aioclient_mock.put(f"{url}/node/state", status=HTTPStatus.OK) networksettings = Mock() networksettings.network_info.channel = 15 @@ -342,14 +342,14 @@ async def test_hassio_discovery_flow_router_not_setup_has_preferred_2( ) # Check we create a dataset and enable the router - assert aioclient_mock.mock_calls[-2][0] == "POST" + assert aioclient_mock.mock_calls[-2][0] == "PUT" assert aioclient_mock.mock_calls[-2][1].path == "/node/dataset/active" assert aioclient_mock.mock_calls[-2][2] == { "Channel": 15, "NetworkName": "home-assistant", } - assert aioclient_mock.mock_calls[-1][0] == "POST" + assert aioclient_mock.mock_calls[-1][0] == "PUT" assert aioclient_mock.mock_calls[-1][1].path == "/node/state" assert aioclient_mock.mock_calls[-1][2] == "enable" diff --git a/tests/components/otbr/test_websocket_api.py b/tests/components/otbr/test_websocket_api.py index e6f492f5e5f..bfc3f09d6fe 100644 --- a/tests/components/otbr/test_websocket_api.py +++ b/tests/components/otbr/test_websocket_api.py @@ -97,9 +97,7 @@ async def test_create_network( assert msg["result"] is None create_dataset_mock.assert_called_once_with( - python_otbr_api.models.OperationalDataSet( - channel=15, network_name="home-assistant" - ) + python_otbr_api.models.ActiveDataSet(channel=15, network_name="home-assistant") ) assert len(set_enabled_mock.mock_calls) == 2 assert set_enabled_mock.mock_calls[0][1][0] is False