Skip to content

Commit 09fee63

Browse files
authored
Update to support bleak 0.17 (#113)
1 parent 3755d3c commit 09fee63

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
setup(
44
name="PySwitchbot",
55
packages=["switchbot", "switchbot.devices", "switchbot.adv_parsers"],
6-
install_requires=["async_timeout>=4.0.1", "bleak", "bleak-retry-connector>=1.14.0"],
6+
install_requires=["async_timeout>=4.0.1", "bleak>=0.17.0", "bleak-retry-connector>=1.15.0"],
77
version="0.19.6",
88
description="A library to communicate with Switchbot",
99
author="Daniel Hjelseth Hoyer",

switchbot/devices/device.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ def __init__(
107107
binascii.crc32(password.encode("ascii")) & 0xFFFFFFFF
108108
)
109109
self._client: BleakClientWithServiceCache | None = None
110-
self._cached_services: BleakGATTServiceCollection | None = None
111110
self._read_char: BleakGATTCharacteristic | None = None
112111
self._write_char: BleakGATTCharacteristic | None = None
113112
self._disconnect_timer: asyncio.TimerHandle | None = None
@@ -229,15 +228,14 @@ async def _ensure_connected(self):
229228
self._device,
230229
self.name,
231230
self._disconnected,
232-
cached_services=self._cached_services,
231+
use_services_cache=True,
233232
ble_device_callback=lambda: self._device,
234233
)
235234
_LOGGER.debug("%s: Connected; RSSI: %s", self.name, self.rssi)
236235
resolved = self._resolve_characteristics(client.services)
237236
if not resolved:
238237
# Try to handle services failing to load
239238
resolved = self._resolve_characteristics(await client.get_services())
240-
self._cached_services = client.services if resolved else None
241239
self._client = client
242240
self._reset_disconnect_timer()
243241

@@ -399,8 +397,6 @@ def update_from_advertisement(self, advertisement: SwitchBotAdvertisement) -> No
399397
"""Update device data from advertisement."""
400398
# Only accept advertisements if the data is not missing
401399
# if we already have an advertisement with data
402-
if self._device and ble_device_has_changed(self._device, advertisement.device):
403-
self._cached_services = None
404400
self._device = advertisement.device
405401

406402
async def get_device_data(

0 commit comments

Comments
 (0)