Skip to content

Commit

Permalink
feat: allow use BLEDevice as device address
Browse files Browse the repository at this point in the history
  • Loading branch information
IATkachenko committed Aug 17, 2022
1 parent 625535a commit b228fb8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tion_btle/tion.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import abc
import asyncio
import inspect
Expand All @@ -8,6 +10,7 @@

from bleak import BleakClient
from bleak import exc
from bleak.backends.device import BLEDevice

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -76,9 +79,9 @@ class Tion:
uuid_notify: str = ""
uuid_write: str = ""

def __init__(self, mac: str):
def __init__(self, mac: str | BLEDevice):
self._mac = mac
self._btle: BleakClient = BleakClient(self.mac)
self._btle: BleakClient = BleakClient(mac)
self._delegation = TionDelegation()
self._fan_speed = 0
self._model: str = self.__class__.__name__
Expand Down Expand Up @@ -257,7 +260,7 @@ async def set(self, new_settings=None) -> None:
@final
@property
def mac(self):
return self._mac
return self._mac.address if isinstance(self._mac, BLEDevice) else self._mac

@staticmethod
def decode_temperature(raw: int) -> int:
Expand Down

0 comments on commit b228fb8

Please sign in to comment.