Fix switchbot not accepting the first advertisement (#78610)

This commit is contained in:
J. Nick Koston 2022-09-17 22:45:04 -05:00 committed by GitHub
parent f7ef9eb91b
commit b8ccf53799
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View file

@ -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(

View file

@ -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):