mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Fix bluetooth calls from automations in esphome (#80683)
This commit is contained in:
parent
92eaa539b6
commit
5589edd814
@ -284,6 +284,7 @@ class HaBleakClientWrapper(BleakClient):
|
|||||||
async def connect(self, **kwargs: Any) -> bool:
|
async def connect(self, **kwargs: Any) -> bool:
|
||||||
"""Connect to the specified GATT server."""
|
"""Connect to the specified GATT server."""
|
||||||
if not self._backend:
|
if not self._backend:
|
||||||
|
assert MANAGER is not None
|
||||||
wrapped_backend = (
|
wrapped_backend = (
|
||||||
self._async_get_backend() or self._async_get_fallback_backend()
|
self._async_get_backend() or self._async_get_fallback_backend()
|
||||||
)
|
)
|
||||||
@ -292,6 +293,7 @@ class HaBleakClientWrapper(BleakClient):
|
|||||||
or wrapped_backend.device,
|
or wrapped_backend.device,
|
||||||
disconnected_callback=self.__disconnected_callback,
|
disconnected_callback=self.__disconnected_callback,
|
||||||
timeout=self.__timeout,
|
timeout=self.__timeout,
|
||||||
|
hass=MANAGER.hass,
|
||||||
)
|
)
|
||||||
return await super().connect(**kwargs)
|
return await super().connect(**kwargs)
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ from bleak.backends.device import BLEDevice
|
|||||||
from bleak.backends.service import BleakGATTServiceCollection
|
from bleak.backends.service import BleakGATTServiceCollection
|
||||||
from bleak.exc import BleakError
|
from bleak.exc import BleakError
|
||||||
|
|
||||||
from homeassistant.core import CALLBACK_TYPE, async_get_hass
|
from homeassistant.core import CALLBACK_TYPE
|
||||||
|
|
||||||
from ..domain_data import DomainData
|
from ..domain_data import DomainData
|
||||||
from .characteristic import BleakGATTCharacteristicESPHome
|
from .characteristic import BleakGATTCharacteristicESPHome
|
||||||
@ -83,7 +83,7 @@ class ESPHomeClient(BaseBleakClient):
|
|||||||
self._address_as_int = mac_to_int(self._ble_device.address)
|
self._address_as_int = mac_to_int(self._ble_device.address)
|
||||||
assert self._ble_device.details is not None
|
assert self._ble_device.details is not None
|
||||||
self._source = self._ble_device.details["source"]
|
self._source = self._ble_device.details["source"]
|
||||||
self.domain_data = DomainData.get(async_get_hass())
|
self.domain_data = DomainData.get(kwargs["hass"])
|
||||||
config_entry = self.domain_data.get_by_unique_id(self._source)
|
config_entry = self.domain_data.get_by_unique_id(self._source)
|
||||||
self.entry_data = self.domain_data.get_entry_data(config_entry)
|
self.entry_data = self.domain_data.get_entry_data(config_entry)
|
||||||
self._client = self.entry_data.client
|
self._client = self.entry_data.client
|
||||||
|
Loading…
x
Reference in New Issue
Block a user