mirror of
https://github.com/esphome/aioesphomeapi.git
synced 2024-11-26 12:45:26 +01:00
Use sloted dataclass for BluetoothLEAdvertisement (#422)
This commit is contained in:
parent
a539a6e950
commit
032e921cb3
@ -1,4 +1,5 @@
|
||||
import enum
|
||||
import sys
|
||||
from dataclasses import asdict, dataclass, field, fields
|
||||
from functools import cache, lru_cache
|
||||
from typing import (
|
||||
@ -19,6 +20,13 @@ from uuid import UUID
|
||||
|
||||
from .util import fix_float_single_double_conversion
|
||||
|
||||
if sys.version_info[:2] < (3, 10):
|
||||
_dataclass_decorator = dataclass()
|
||||
else:
|
||||
_dataclass_decorator = dataclass( # pylint: disable=unexpected-keyword-arg
|
||||
slots=True
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .api_pb2 import ( # type: ignore
|
||||
BluetoothLEAdvertisementResponse,
|
||||
@ -842,11 +850,8 @@ def _convert_bluetooth_le_manufacturer_data(
|
||||
return {int(v.uuid, 16): bytes(v.legacy_data) for v in value} # type: ignore
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class BluetoothLEAdvertisement(APIModelBase):
|
||||
def __post_init__(self) -> None:
|
||||
"""Post init hook disabled."""
|
||||
|
||||
@_dataclass_decorator
|
||||
class BluetoothLEAdvertisement:
|
||||
address: int
|
||||
rssi: int
|
||||
address_type: int
|
||||
|
Loading…
Reference in New Issue
Block a user