From b8ccf53799615f6ecf5381da63d89236c4cdad52 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 17 Sep 2022 22:45:04 -0500 Subject: [PATCH] Fix switchbot not accepting the first advertisement (#78610) --- homeassistant/components/switchbot/__init__.py | 2 +- homeassistant/components/switchbot/coordinator.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/switchbot/__init__.py b/homeassistant/components/switchbot/__init__.py index 7307187bf54..58e77dfe1bf 100644 --- a/homeassistant/components/switchbot/__init__.py +++ b/homeassistant/components/switchbot/__init__.py @@ -110,7 +110,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: ) entry.async_on_unload(coordinator.async_start()) if not await coordinator.async_wait_ready(): - raise ConfigEntryNotReady(f"Switchbot {sensor_type} with {address} not ready") + raise ConfigEntryNotReady(f"{address} is not advertising state") entry.async_on_unload(entry.add_update_listener(_async_update_listener)) await hass.config_entries.async_forward_entry_setups( diff --git a/homeassistant/components/switchbot/coordinator.py b/homeassistant/components/switchbot/coordinator.py index 94018c1b46b..ee93c74af37 100644 --- a/homeassistant/components/switchbot/coordinator.py +++ b/homeassistant/components/switchbot/coordinator.py @@ -73,7 +73,7 @@ class SwitchbotDataUpdateCoordinator(PassiveBluetoothDataUpdateCoordinator): if adv := switchbot.parse_advertisement_data( service_info.device, service_info.advertisement ): - if "modelName" in self.data: + if "modelName" in adv.data: self._ready_event.set() _LOGGER.debug("%s: Switchbot data: %s", self.ble_device.address, self.data) if not self.device.advertisement_changed(adv):