parent
4d39a85553
commit
6812596cd7
|
@ -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}'"
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"]
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -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"}
|
||||
)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue