Defer xiaomi ble polling until after startup (#83074)
fixes https://github.com/home-assistant/core/issues/77178pull/83077/head
parent
18e4c065eb
commit
e23007322d
|
@ -17,7 +17,7 @@ from homeassistant.components.bluetooth.active_update_coordinator import (
|
|||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.core import CoreState, HomeAssistant
|
||||
|
||||
from .const import DOMAIN
|
||||
|
||||
|
@ -60,7 +60,17 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
def _needs_poll(
|
||||
service_info: BluetoothServiceInfoBleak, last_poll: float | None
|
||||
) -> bool:
|
||||
return data.poll_needed(service_info, last_poll)
|
||||
# Only poll if hass is running, we need to poll,
|
||||
# and we actually have a way to connect to the device
|
||||
return (
|
||||
hass.state == CoreState.running
|
||||
and data.poll_needed(service_info, last_poll)
|
||||
and bool(
|
||||
async_ble_device_from_address(
|
||||
hass, service_info.device.address, connectable=True
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
async def _async_poll(service_info: BluetoothServiceInfoBleak):
|
||||
# BluetoothServiceInfoBleak is defined in HA, otherwise would just pass it
|
||||
|
|
Loading…
Reference in New Issue