diff --git a/homeassistant/components/bring/__init__.py b/homeassistant/components/bring/__init__.py index aec3cd53c94..dc9f053876e 100644 --- a/homeassistant/components/bring/__init__.py +++ b/homeassistant/components/bring/__init__.py @@ -3,8 +3,8 @@ from __future__ import annotations import logging -from python_bring_api.bring import Bring -from python_bring_api.exceptions import ( +from bring_api.bring import Bring +from bring_api.exceptions import ( BringAuthException, BringParseException, BringRequestException, @@ -31,11 +31,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: password = entry.data[CONF_PASSWORD] session = async_get_clientsession(hass) - bring = Bring(email, password, sessionAsync=session) + bring = Bring(session, email, password) try: - await bring.loginAsync() - await bring.loadListsAsync() + await bring.login() + await bring.loadLists() except BringRequestException as e: raise ConfigEntryNotReady( f"Timeout while connecting for email '{email}'" diff --git a/homeassistant/components/bring/config_flow.py b/homeassistant/components/bring/config_flow.py index 122e71feea6..0a2198712c9 100644 --- a/homeassistant/components/bring/config_flow.py +++ b/homeassistant/components/bring/config_flow.py @@ -4,8 +4,8 @@ from __future__ import annotations import logging from typing import Any -from python_bring_api.bring import Bring -from python_bring_api.exceptions import BringAuthException, BringRequestException +from bring_api.bring import Bring +from bring_api.exceptions import BringAuthException, BringRequestException import voluptuous as vol from homeassistant import config_entries @@ -50,13 +50,11 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): errors: dict[str, str] = {} if user_input is not None: session = async_get_clientsession(self.hass) - bring = Bring( - user_input[CONF_EMAIL], user_input[CONF_PASSWORD], sessionAsync=session - ) + bring = Bring(session, user_input[CONF_EMAIL], user_input[CONF_PASSWORD]) try: - await bring.loginAsync() - await bring.loadListsAsync() + await bring.login() + await bring.loadLists() except BringRequestException: errors["base"] = "cannot_connect" except BringAuthException: diff --git a/homeassistant/components/bring/coordinator.py b/homeassistant/components/bring/coordinator.py index eb28f24e085..57cc3d71085 100644 --- a/homeassistant/components/bring/coordinator.py +++ b/homeassistant/components/bring/coordinator.py @@ -4,9 +4,9 @@ from __future__ import annotations from datetime import timedelta import logging -from python_bring_api.bring import Bring -from python_bring_api.exceptions import BringParseException, BringRequestException -from python_bring_api.types import BringItemsResponse, BringList +from bring_api.bring import Bring +from bring_api.exceptions import BringParseException, BringRequestException +from bring_api.types import BringItemsResponse, BringList from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant @@ -40,7 +40,7 @@ class BringDataUpdateCoordinator(DataUpdateCoordinator[dict[str, BringData]]): async def _async_update_data(self) -> dict[str, BringData]: try: - lists_response = await self.bring.loadListsAsync() + lists_response = await self.bring.loadLists() except BringRequestException as e: raise UpdateFailed("Unable to connect and retrieve data from bring") from e except BringParseException as e: @@ -49,7 +49,7 @@ class BringDataUpdateCoordinator(DataUpdateCoordinator[dict[str, BringData]]): list_dict = {} for lst in lists_response["lists"]: try: - items = await self.bring.getItemsAsync(lst["listUuid"]) + items = await self.bring.getItems(lst["listUuid"]) except BringRequestException as e: raise UpdateFailed( "Unable to connect and retrieve data from bring" diff --git a/homeassistant/components/bring/manifest.json b/homeassistant/components/bring/manifest.json index e7d23bfc3df..195fbf05f1f 100644 --- a/homeassistant/components/bring/manifest.json +++ b/homeassistant/components/bring/manifest.json @@ -6,5 +6,5 @@ "documentation": "https://www.home-assistant.io/integrations/bring", "integration_type": "service", "iot_class": "cloud_polling", - "requirements": ["python-bring-api==3.0.0"] + "requirements": ["bring-api==0.1.1"] } diff --git a/homeassistant/components/bring/todo.py b/homeassistant/components/bring/todo.py index 14279c894af..608cc58bfba 100644 --- a/homeassistant/components/bring/todo.py +++ b/homeassistant/components/bring/todo.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import TYPE_CHECKING -from python_bring_api.exceptions import BringRequestException +from bring_api.exceptions import BringRequestException from homeassistant.components.todo import ( TodoItem, @@ -75,8 +75,8 @@ class BringTodoListEntity( """Return the todo items.""" return [ TodoItem( - uid=item["name"], - summary=item["name"], + uid=item["itemId"], + summary=item["itemId"], description=item["specification"] or "", status=TodoItemStatus.NEEDS_ACTION, ) @@ -91,7 +91,7 @@ class BringTodoListEntity( async def async_create_todo_item(self, item: TodoItem) -> None: """Add an item to the To-do list.""" try: - await self.coordinator.bring.saveItemAsync( + await self.coordinator.bring.saveItem( self.bring_list["listUuid"], item.summary, item.description or "" ) except BringRequestException as e: @@ -123,14 +123,14 @@ class BringTodoListEntity( assert item.uid if item.status == TodoItemStatus.COMPLETED: - await self.coordinator.bring.removeItemAsync( + await self.coordinator.bring.removeItem( bring_list["listUuid"], item.uid, ) elif item.summary == item.uid: try: - await self.coordinator.bring.updateItemAsync( + await self.coordinator.bring.updateItem( bring_list["listUuid"], item.uid, item.description or "", @@ -139,11 +139,11 @@ class BringTodoListEntity( raise HomeAssistantError("Unable to update todo item for bring") from e else: try: - await self.coordinator.bring.removeItemAsync( + await self.coordinator.bring.removeItem( bring_list["listUuid"], item.uid, ) - await self.coordinator.bring.saveItemAsync( + await self.coordinator.bring.saveItem( bring_list["listUuid"], item.summary, item.description or "", @@ -157,7 +157,7 @@ class BringTodoListEntity( """Delete an item from the To-do list.""" for uid in uids: try: - await self.coordinator.bring.removeItemAsync( + await self.coordinator.bring.removeItem( self.bring_list["listUuid"], uid ) except BringRequestException as e: diff --git a/requirements_all.txt b/requirements_all.txt index 8c4a57aaa5b..0682d79ebc1 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -599,6 +599,9 @@ boschshcpy==0.2.75 # homeassistant.components.route53 boto3==1.33.13 +# homeassistant.components.bring +bring-api==0.1.1 + # homeassistant.components.broadlink broadlink==0.18.3 @@ -2186,9 +2189,6 @@ python-awair==0.2.4 # homeassistant.components.blockchain python-blockchain-api==0.0.2 -# homeassistant.components.bring -python-bring-api==3.0.0 - # homeassistant.components.bsblan python-bsblan==0.5.18 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 3a9e7576908..a4553a0e2a5 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -507,6 +507,9 @@ bond-async==0.2.1 # homeassistant.components.bosch_shc boschshcpy==0.2.75 +# homeassistant.components.bring +bring-api==0.1.1 + # homeassistant.components.broadlink broadlink==0.18.3 @@ -1689,9 +1692,6 @@ python-MotionMount==0.3.1 # homeassistant.components.awair python-awair==0.2.4 -# homeassistant.components.bring -python-bring-api==3.0.0 - # homeassistant.components.bsblan python-bsblan==0.5.18 diff --git a/tests/components/bring/conftest.py b/tests/components/bring/conftest.py index 81a76c9ee3e..b8504f38e7f 100644 --- a/tests/components/bring/conftest.py +++ b/tests/components/bring/conftest.py @@ -36,8 +36,8 @@ def mock_bring_client() -> Generator[AsyncMock, None, None]: ): client = mock_client.return_value client.uuid = UUID - client.loginAsync.return_value = True - client.loadListsAsync.return_value = {"lists": []} + client.login.return_value = True + client.loadLists.return_value = {"lists": []} yield client diff --git a/tests/components/bring/test_config_flow.py b/tests/components/bring/test_config_flow.py index 531554d584e..f5a8398539a 100644 --- a/tests/components/bring/test_config_flow.py +++ b/tests/components/bring/test_config_flow.py @@ -1,12 +1,12 @@ """Test the Bring! config flow.""" from unittest.mock import AsyncMock -import pytest -from python_bring_api.exceptions import ( +from bring_api.exceptions import ( BringAuthException, BringParseException, BringRequestException, ) +import pytest from homeassistant import config_entries from homeassistant.components.bring.const import DOMAIN @@ -62,7 +62,7 @@ async def test_flow_user_init_data_unknown_error_and_recover( hass: HomeAssistant, mock_bring_client: AsyncMock, raise_error, text_error ) -> None: """Test unknown errors.""" - mock_bring_client.loginAsync.side_effect = raise_error + mock_bring_client.login.side_effect = raise_error result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": "user"} @@ -76,7 +76,7 @@ async def test_flow_user_init_data_unknown_error_and_recover( assert result["errors"]["base"] == text_error # Recover - mock_bring_client.loginAsync.side_effect = None + mock_bring_client.login.side_effect = None result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": "user"} ) diff --git a/tests/components/bring/test_init.py b/tests/components/bring/test_init.py index 59628fa59b7..e5fcedefc22 100644 --- a/tests/components/bring/test_init.py +++ b/tests/components/bring/test_init.py @@ -58,6 +58,6 @@ async def test_init_failure( bring_config_entry: MockConfigEntry | None, ) -> None: """Test an initialization error on integration load.""" - mock_bring_client.loginAsync.side_effect = exception + mock_bring_client.login.side_effect = exception await setup_integration(hass, bring_config_entry) assert bring_config_entry.state == status