mirror of
https://github.com/home-assistant/core.git
synced 2025-07-09 14:27:07 +00:00
Fix duplicate and missing decorators in ESPHome Bluetooth client (#97027)
This commit is contained in:
parent
123cf07920
commit
24b9bde9e5
@ -364,16 +364,18 @@ class ESPHomeClient(BaseBleakClient):
|
|||||||
await connected_future
|
await connected_future
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await self.get_services(dangerous_use_bleak_cache=dangerous_use_bleak_cache)
|
await self._get_services(
|
||||||
|
dangerous_use_bleak_cache=dangerous_use_bleak_cache
|
||||||
|
)
|
||||||
except asyncio.CancelledError:
|
except asyncio.CancelledError:
|
||||||
# On cancel we must still raise cancelled error
|
# On cancel we must still raise cancelled error
|
||||||
# to avoid blocking the cancellation even if the
|
# to avoid blocking the cancellation even if the
|
||||||
# disconnect call fails.
|
# disconnect call fails.
|
||||||
with contextlib.suppress(Exception):
|
with contextlib.suppress(Exception):
|
||||||
await self.disconnect()
|
await self._disconnect()
|
||||||
raise
|
raise
|
||||||
except Exception:
|
except Exception:
|
||||||
await self.disconnect()
|
await self._disconnect()
|
||||||
raise
|
raise
|
||||||
|
|
||||||
return True
|
return True
|
||||||
@ -381,6 +383,9 @@ class ESPHomeClient(BaseBleakClient):
|
|||||||
@api_error_as_bleak_error
|
@api_error_as_bleak_error
|
||||||
async def disconnect(self) -> bool:
|
async def disconnect(self) -> bool:
|
||||||
"""Disconnect from the peripheral device."""
|
"""Disconnect from the peripheral device."""
|
||||||
|
return await self._disconnect()
|
||||||
|
|
||||||
|
async def _disconnect(self) -> bool:
|
||||||
self._async_disconnected_cleanup()
|
self._async_disconnected_cleanup()
|
||||||
await self._client.bluetooth_device_disconnect(self._address_as_int)
|
await self._client.bluetooth_device_disconnect(self._address_as_int)
|
||||||
await self._wait_for_free_connection_slot(DISCONNECT_TIMEOUT)
|
await self._wait_for_free_connection_slot(DISCONNECT_TIMEOUT)
|
||||||
@ -454,6 +459,18 @@ class ESPHomeClient(BaseBleakClient):
|
|||||||
A :py:class:`bleak.backends.service.BleakGATTServiceCollection`
|
A :py:class:`bleak.backends.service.BleakGATTServiceCollection`
|
||||||
with this device's services tree.
|
with this device's services tree.
|
||||||
"""
|
"""
|
||||||
|
return await self._get_services(
|
||||||
|
dangerous_use_bleak_cache=dangerous_use_bleak_cache, **kwargs
|
||||||
|
)
|
||||||
|
|
||||||
|
@verify_connected
|
||||||
|
async def _get_services(
|
||||||
|
self, dangerous_use_bleak_cache: bool = False, **kwargs: Any
|
||||||
|
) -> BleakGATTServiceCollection:
|
||||||
|
"""Get all services registered for this GATT server.
|
||||||
|
|
||||||
|
Must only be called from get_services or connected
|
||||||
|
"""
|
||||||
address_as_int = self._address_as_int
|
address_as_int = self._address_as_int
|
||||||
cache = self._cache
|
cache = self._cache
|
||||||
# If the connection version >= 3, we must use the cache
|
# If the connection version >= 3, we must use the cache
|
||||||
@ -538,6 +555,7 @@ class ESPHomeClient(BaseBleakClient):
|
|||||||
raise BleakError(f"Characteristic {char_specifier} was not found!")
|
raise BleakError(f"Characteristic {char_specifier} was not found!")
|
||||||
return characteristic
|
return characteristic
|
||||||
|
|
||||||
|
@verify_connected
|
||||||
@api_error_as_bleak_error
|
@api_error_as_bleak_error
|
||||||
async def clear_cache(self) -> bool:
|
async def clear_cache(self) -> bool:
|
||||||
"""Clear the GATT cache."""
|
"""Clear the GATT cache."""
|
||||||
@ -726,6 +744,7 @@ class ESPHomeClient(BaseBleakClient):
|
|||||||
wait_for_response=False,
|
wait_for_response=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@verify_connected
|
||||||
@api_error_as_bleak_error
|
@api_error_as_bleak_error
|
||||||
async def stop_notify(
|
async def stop_notify(
|
||||||
self,
|
self,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user