mirror of
https://github.com/esphome/aioesphomeapi.git
synced 2024-11-22 12:05:12 +01:00
Remove unneeded local variables from previous refactoring (#676)
This commit is contained in:
parent
e7d27e307e
commit
1f5b538502
@ -435,11 +435,13 @@ class APIClient:
|
|||||||
),
|
),
|
||||||
timeout: float = 10.0,
|
timeout: float = 10.0,
|
||||||
) -> message.Message:
|
) -> message.Message:
|
||||||
msg_types = (response_type, BluetoothGATTErrorResponse)
|
|
||||||
|
|
||||||
message_filter = partial(self._filter_bluetooth_message, address, handle)
|
message_filter = partial(self._filter_bluetooth_message, address, handle)
|
||||||
resp = await self._get_connection().send_messages_await_response_complex(
|
resp = await self._get_connection().send_messages_await_response_complex(
|
||||||
(request,), message_filter, message_filter, msg_types, timeout
|
(request,),
|
||||||
|
message_filter,
|
||||||
|
message_filter,
|
||||||
|
(response_type, BluetoothGATTErrorResponse),
|
||||||
|
timeout,
|
||||||
)
|
)
|
||||||
|
|
||||||
if isinstance(resp[0], BluetoothGATTErrorResponse):
|
if isinstance(resp[0], BluetoothGATTErrorResponse):
|
||||||
@ -532,7 +534,6 @@ class APIClient:
|
|||||||
has_cache: bool = False,
|
has_cache: bool = False,
|
||||||
address_type: int | None = None,
|
address_type: int | None = None,
|
||||||
) -> Callable[[], None]:
|
) -> Callable[[], None]:
|
||||||
msg_types = (BluetoothDeviceConnectionResponse,)
|
|
||||||
debug = _LOGGER.isEnabledFor(logging.DEBUG)
|
debug = _LOGGER.isEnabledFor(logging.DEBUG)
|
||||||
connect_future: asyncio.Future[None] = self._loop.create_future()
|
connect_future: asyncio.Future[None] = self._loop.create_future()
|
||||||
|
|
||||||
@ -563,7 +564,7 @@ class APIClient:
|
|||||||
address,
|
address,
|
||||||
on_bluetooth_connection_state,
|
on_bluetooth_connection_state,
|
||||||
),
|
),
|
||||||
msg_types,
|
(BluetoothDeviceConnectionResponse,),
|
||||||
)
|
)
|
||||||
|
|
||||||
loop = self._loop
|
loop = self._loop
|
||||||
@ -629,14 +630,9 @@ class APIClient:
|
|||||||
async def bluetooth_device_pair(
|
async def bluetooth_device_pair(
|
||||||
self, address: int, timeout: float = DEFAULT_BLE_TIMEOUT
|
self, address: int, timeout: float = DEFAULT_BLE_TIMEOUT
|
||||||
) -> BluetoothDevicePairing:
|
) -> BluetoothDevicePairing:
|
||||||
msg_types = (
|
def predicate_func(
|
||||||
BluetoothDevicePairingResponse,
|
msg: BluetoothDevicePairingResponse | BluetoothDeviceConnectionResponse,
|
||||||
BluetoothDeviceConnectionResponse,
|
) -> bool:
|
||||||
)
|
|
||||||
|
|
||||||
def predicate_func(msg: message.Message) -> bool:
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
assert isinstance(msg, msg_types)
|
|
||||||
if msg.address != address:
|
if msg.address != address:
|
||||||
return False
|
return False
|
||||||
if isinstance(msg, BluetoothDeviceConnectionResponse):
|
if isinstance(msg, BluetoothDeviceConnectionResponse):
|
||||||
@ -650,7 +646,10 @@ class APIClient:
|
|||||||
address,
|
address,
|
||||||
BluetoothDeviceRequestType.PAIR,
|
BluetoothDeviceRequestType.PAIR,
|
||||||
predicate_func,
|
predicate_func,
|
||||||
msg_types,
|
(
|
||||||
|
BluetoothDevicePairingResponse,
|
||||||
|
BluetoothDeviceConnectionResponse,
|
||||||
|
),
|
||||||
timeout,
|
timeout,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -718,11 +717,6 @@ class APIClient:
|
|||||||
async def bluetooth_gatt_get_services(
|
async def bluetooth_gatt_get_services(
|
||||||
self, address: int
|
self, address: int
|
||||||
) -> ESPHomeBluetoothGATTServices:
|
) -> ESPHomeBluetoothGATTServices:
|
||||||
msg_types = (
|
|
||||||
BluetoothGATTGetServicesResponse,
|
|
||||||
BluetoothGATTGetServicesDoneResponse,
|
|
||||||
BluetoothGATTErrorResponse,
|
|
||||||
)
|
|
||||||
append_types = (BluetoothGATTGetServicesResponse, BluetoothGATTErrorResponse)
|
append_types = (BluetoothGATTGetServicesResponse, BluetoothGATTErrorResponse)
|
||||||
stop_types = (BluetoothGATTGetServicesDoneResponse, BluetoothGATTErrorResponse)
|
stop_types = (BluetoothGATTGetServicesDoneResponse, BluetoothGATTErrorResponse)
|
||||||
|
|
||||||
@ -736,7 +730,11 @@ class APIClient:
|
|||||||
(BluetoothGATTGetServicesRequest(address=address),),
|
(BluetoothGATTGetServicesRequest(address=address),),
|
||||||
do_append,
|
do_append,
|
||||||
do_stop,
|
do_stop,
|
||||||
msg_types,
|
(
|
||||||
|
BluetoothGATTGetServicesResponse,
|
||||||
|
BluetoothGATTGetServicesDoneResponse,
|
||||||
|
BluetoothGATTErrorResponse,
|
||||||
|
),
|
||||||
DEFAULT_BLE_TIMEOUT,
|
DEFAULT_BLE_TIMEOUT,
|
||||||
)
|
)
|
||||||
services = []
|
services = []
|
||||||
|
Loading…
Reference in New Issue
Block a user