1
0
mirror of https://github.com/home-assistant/core.git synced 2026-04-02 00:20:30 +01:00

Bump aiotedee to 0.3.0 (#166321)

Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
This commit is contained in:
Josef Zweck
2026-03-24 15:23:48 +01:00
committed by GitHub
parent d04c5ccc44
commit b518729367
16 changed files with 47 additions and 52 deletions

View File

@@ -7,7 +7,7 @@ from typing import Any
from aiohttp.hdrs import METH_POST
from aiohttp.web import Request, Response
from aiotedee.exception import TedeeDataUpdateException, TedeeWebhookException
from aiotedee.exceptions import TedeeDataUpdateException, TedeeWebhookException
from homeassistant.components.http import HomeAssistantView
from homeassistant.components.webhook import (

View File

@@ -4,7 +4,7 @@ from collections.abc import Callable
from dataclasses import dataclass
from aiotedee import TedeeLock
from aiotedee.lock import TedeeDoorState, TedeeLockState
from aiotedee.models import TedeeDoorState, TedeeLockState
from homeassistant.components.binary_sensor import (
BinarySensorDeviceClass,

View File

@@ -6,10 +6,10 @@ from typing import Any
from aiotedee import (
TedeeAuthException,
TedeeClient,
TedeeClientException,
TedeeDataUpdateException,
TedeeLocalAuthException,
TedeeLocalClient,
)
import voluptuous as vol
@@ -46,7 +46,7 @@ class TedeeConfigFlow(ConfigFlow, domain=DOMAIN):
else:
host = user_input[CONF_HOST]
local_access_token = user_input[CONF_LOCAL_ACCESS_TOKEN]
tedee_client = TedeeClient(
tedee_client = TedeeLocalClient(
local_token=local_access_token,
local_ip=host,
session=async_get_clientsession(self.hass),

View File

@@ -9,14 +9,14 @@ import time
from typing import Any
from aiotedee import (
TedeeClient,
TedeeClientException,
TedeeDataUpdateException,
TedeeLocalAuthException,
TedeeLocalClient,
TedeeLock,
TedeeWebhookException,
)
from aiotedee.bridge import TedeeBridge
from aiotedee.models import TedeeBridge
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_HOST
@@ -52,7 +52,7 @@ class TedeeApiCoordinator(DataUpdateCoordinator[dict[int, TedeeLock]]):
update_interval=SCAN_INTERVAL,
)
self.tedee_client = TedeeClient(
self.tedee_client = TedeeLocalClient(
local_token=self.config_entry.data[CONF_LOCAL_ACCESS_TOKEN],
local_ip=self.config_entry.data[CONF_HOST],
session=async_get_clientsession(hass),

View File

@@ -10,7 +10,7 @@ from homeassistant.core import HomeAssistant
from . import TedeeConfigEntry
TO_REDACT = {
"lock_id",
"id",
}

View File

@@ -1,6 +1,6 @@
"""Bases for Tedee entities."""
from aiotedee.lock import TedeeLock
from aiotedee.models import TedeeLock
from homeassistant.core import callback
from homeassistant.helpers.device_registry import DeviceInfo
@@ -25,21 +25,21 @@ class TedeeEntity(CoordinatorEntity[TedeeApiCoordinator]):
"""Initialize Tedee entity."""
super().__init__(coordinator)
self._lock = lock
self._attr_unique_id = f"{lock.lock_id}-{key}"
self._attr_unique_id = f"{lock.id}-{key}"
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, str(lock.lock_id))},
name=lock.lock_name,
identifiers={(DOMAIN, str(lock.id))},
name=lock.name,
manufacturer="Tedee",
model=lock.lock_type,
model_id=lock.lock_type,
model=lock.type_name,
model_id=lock.type_name,
via_device=(DOMAIN, coordinator.bridge.serial),
)
@callback
def _handle_coordinator_update(self) -> None:
"""Handle updated data from the coordinator."""
self._lock = self.coordinator.data.get(self._lock.lock_id, self._lock)
self._lock = self.coordinator.data.get(self._lock.id, self._lock)
super()._handle_coordinator_update()

View File

@@ -84,7 +84,7 @@ class TedeeLockEntity(TedeeEntity, LockEntity):
@property
def is_jammed(self) -> bool:
"""Return true if lock is jammed."""
return self._lock.is_state_jammed
return self._lock.is_jammed
@property
def available(self) -> bool:
@@ -101,13 +101,13 @@ class TedeeLockEntity(TedeeEntity, LockEntity):
self._lock.state = TedeeLockState.UNLOCKING
self.async_write_ha_state()
await self.coordinator.tedee_client.unlock(self._lock.lock_id)
await self.coordinator.tedee_client.unlock(self._lock.id)
await self.coordinator.async_request_refresh()
except (TedeeClientException, Exception) as ex:
raise HomeAssistantError(
translation_domain=DOMAIN,
translation_key="unlock_failed",
translation_placeholders={"lock_id": str(self._lock.lock_id)},
translation_placeholders={"lock_id": str(self._lock.id)},
) from ex
async def async_lock(self, **kwargs: Any) -> None:
@@ -116,13 +116,13 @@ class TedeeLockEntity(TedeeEntity, LockEntity):
self._lock.state = TedeeLockState.LOCKING
self.async_write_ha_state()
await self.coordinator.tedee_client.lock(self._lock.lock_id)
await self.coordinator.tedee_client.lock(self._lock.id)
await self.coordinator.async_request_refresh()
except (TedeeClientException, Exception) as ex:
raise HomeAssistantError(
translation_domain=DOMAIN,
translation_key="lock_failed",
translation_placeholders={"lock_id": str(self._lock.lock_id)},
translation_placeholders={"lock_id": str(self._lock.id)},
) from ex
@@ -140,11 +140,11 @@ class TedeeLockWithLatchEntity(TedeeLockEntity):
self._lock.state = TedeeLockState.UNLOCKING
self.async_write_ha_state()
await self.coordinator.tedee_client.open(self._lock.lock_id)
await self.coordinator.tedee_client.open(self._lock.id)
await self.coordinator.async_request_refresh()
except (TedeeClientException, Exception) as ex:
raise HomeAssistantError(
translation_domain=DOMAIN,
translation_key="open_failed",
translation_placeholders={"lock_id": str(self._lock.lock_id)},
translation_placeholders={"lock_id": str(self._lock.id)},
) from ex

View File

@@ -9,5 +9,5 @@
"iot_class": "local_push",
"loggers": ["aiotedee"],
"quality_scale": "platinum",
"requirements": ["aiotedee==0.2.27"]
"requirements": ["aiotedee==0.3.0"]
}

2
requirements_all.txt generated
View File

@@ -422,7 +422,7 @@ aiosyncthing==0.7.1
aiotankerkoenig==0.5.1
# homeassistant.components.tedee
aiotedee==0.2.27
aiotedee==0.3.0
# homeassistant.components.tractive
aiotractive==1.0.1

View File

@@ -407,7 +407,7 @@ aiosyncthing==0.7.1
aiotankerkoenig==0.5.1
# homeassistant.components.tedee
aiotedee==0.2.27
aiotedee==0.3.0
# homeassistant.components.tractive
aiotractive==1.0.1

View File

@@ -6,8 +6,7 @@ from collections.abc import Generator
import json
from unittest.mock import AsyncMock, MagicMock, patch
from aiotedee.bridge import TedeeBridge
from aiotedee.lock import TedeeLock
from aiotedee.models import TedeeBridge, TedeeLock
import pytest
from homeassistant.components.tedee.const import CONF_LOCAL_ACCESS_TOKEN, DOMAIN
@@ -52,10 +51,10 @@ def mock_tedee() -> Generator[MagicMock]:
"""Return a mocked Tedee client."""
with (
patch(
"homeassistant.components.tedee.coordinator.TedeeClient", autospec=True
"homeassistant.components.tedee.coordinator.TedeeLocalClient", autospec=True
) as tedee_mock,
patch(
"homeassistant.components.tedee.config_flow.TedeeClient",
"homeassistant.components.tedee.config_flow.TedeeLocalClient",
new=tedee_mock,
),
):
@@ -63,10 +62,6 @@ def mock_tedee() -> Generator[MagicMock]:
tedee.get_locks.return_value = None
tedee.sync.return_value = None
tedee.get_bridges.return_value = [
TedeeBridge(1234, "0000-0000", "Bridge-AB1C"),
TedeeBridge(5678, "9999-9999", "Bridge-CD2E"),
]
tedee.get_local_bridge.return_value = TedeeBridge(0, "0000-0000", "Bridge-AB1C")
tedee.parse_webhook_message.return_value = None
@@ -75,8 +70,8 @@ def mock_tedee() -> Generator[MagicMock]:
locks_json = json.loads(load_fixture("locks.json", DOMAIN))
lock_list = [TedeeLock(**lock) for lock in locks_json]
tedee.locks_dict = {lock.lock_id: lock for lock in lock_list}
lock_list = [TedeeLock.from_dict(lock) for lock in locks_json]
tedee.locks_dict = {lock.id: lock for lock in lock_list}
yield tedee

View File

@@ -1,8 +1,8 @@
[
{
"lock_name": "Lock-1A2B",
"lock_id": 12345,
"lock_type": 2,
"name": "Lock-1A2B",
"id": 12345,
"type": 2,
"state": 2,
"battery_level": 70,
"is_connected": true,
@@ -13,9 +13,9 @@
"door_state": 0
},
{
"lock_name": "Lock-2C3D",
"lock_id": 98765,
"lock_type": 4,
"name": "Lock-2C3D",
"id": 98765,
"type": 4,
"state": 2,
"battery_level": 70,
"is_connected": true,

View File

@@ -5,29 +5,29 @@
'battery_level': 70,
'door_state': 0,
'duration_pullspring': 2,
'id': '**REDACTED**',
'is_charging': False,
'is_connected': True,
'is_enabled_auto_pullspring': False,
'is_enabled_pullspring': 1,
'lock_id': '**REDACTED**',
'lock_name': 'Lock-1A2B',
'lock_type': 2,
'is_enabled_pullspring': True,
'name': 'Lock-1A2B',
'state': 2,
'state_change_result': 0,
'type': 2,
}),
'1': dict({
'battery_level': 70,
'door_state': 2,
'duration_pullspring': 0,
'id': '**REDACTED**',
'is_charging': False,
'is_connected': True,
'is_enabled_auto_pullspring': False,
'is_enabled_pullspring': 0,
'lock_id': '**REDACTED**',
'lock_name': 'Lock-2C3D',
'lock_type': 4,
'is_enabled_pullspring': False,
'name': 'Lock-2C3D',
'state': 2,
'state_change_result': 0,
'type': 4,
}),
})
# ---

View File

@@ -7,7 +7,7 @@ from aiotedee import (
TedeeDataUpdateException,
TedeeLocalAuthException,
)
from aiotedee.bridge import TedeeBridge
from aiotedee.models import TedeeBridge
import pytest
from homeassistant.components.tedee.const import CONF_LOCAL_ACCESS_TOKEN, DOMAIN

View File

@@ -5,7 +5,7 @@ from typing import Any
from unittest.mock import MagicMock, patch
from urllib.parse import urlparse
from aiotedee.exception import (
from aiotedee.exceptions import (
TedeeAuthException,
TedeeClientException,
TedeeWebhookException,

View File

@@ -5,7 +5,7 @@ from unittest.mock import MagicMock, patch
from urllib.parse import urlparse
from aiotedee import TedeeLock, TedeeLockState
from aiotedee.exception import (
from aiotedee.exceptions import (
TedeeClientException,
TedeeDataUpdateException,
TedeeLocalAuthException,