Skip to content

Commit b228fb8

Browse files
committed
feat: allow use BLEDevice as device address
1 parent 625535a commit b228fb8

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

tion_btle/tion.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import abc
24
import asyncio
35
import inspect
@@ -8,6 +10,7 @@
810

911
from bleak import BleakClient
1012
from bleak import exc
13+
from bleak.backends.device import BLEDevice
1114

1215
_LOGGER = logging.getLogger(__name__)
1316

@@ -76,9 +79,9 @@ class Tion:
7679
uuid_notify: str = ""
7780
uuid_write: str = ""
7881

79-
def __init__(self, mac: str):
82+
def __init__(self, mac: str | BLEDevice):
8083
self._mac = mac
81-
self._btle: BleakClient = BleakClient(self.mac)
84+
self._btle: BleakClient = BleakClient(mac)
8285
self._delegation = TionDelegation()
8386
self._fan_speed = 0
8487
self._model: str = self.__class__.__name__
@@ -257,7 +260,7 @@ async def set(self, new_settings=None) -> None:
257260
@final
258261
@property
259262
def mac(self):
260-
return self._mac
263+
return self._mac.address if isinstance(self._mac, BLEDevice) else self._mac
261264

262265
@staticmethod
263266
def decode_temperature(raw: int) -> int:

0 commit comments

Comments
 (0)