Skip to content

Commit 6159f90

Browse files
authored
feat: expose get_device api (#106)
1 parent 00c3bb1 commit 6159f90

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
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.11.0"],
6+
install_requires=["async_timeout>=4.0.1", "bleak", "bleak-retry-connector>=1.12.2"],
77
version="0.19.1",
88
description="A library to communicate with Switchbot",
99
author="Daniel Hjelseth Hoyer",

switchbot/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"""Library to handle connection with Switchbot."""
22
from __future__ import annotations
33

4+
from bleak_retry_connector import get_device
5+
46
from .adv_parser import SwitchbotSupportedType, parse_advertisement_data
57
from .const import SwitchbotModel
68
from .devices.base_light import SwitchbotBaseLight
@@ -16,6 +18,7 @@
1618
from .models import SwitchBotAdvertisement
1719

1820
__all__ = [
21+
"get_device",
1922
"parse_advertisement_data",
2023
"GetSwitchbotDevices",
2124
"SwitchBotAdvertisement",

switchbot/adv_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
"""Library to handle connection with Switchbot."""
22
from __future__ import annotations
3-
from functools import lru_cache
43

54
import logging
65
from collections.abc import Callable
6+
from functools import lru_cache
77
from typing import TypedDict
88

99
from bleak.backends.device import BLEDevice

switchbot/devices/device.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@
3737
# Base key when encryption is set
3838
KEY_PASSWORD_PREFIX = "571"
3939

40-
BLEAK_EXCEPTIONS = (AttributeError, BleakError, EOFError, asyncio.exceptions.TimeoutError)
40+
BLEAK_EXCEPTIONS = (
41+
AttributeError,
42+
BleakError,
43+
EOFError,
44+
asyncio.exceptions.TimeoutError,
45+
)
4146

4247
# How long to hold the connection
4348
# to wait for additional commands for

0 commit comments

Comments
 (0)