Enable shelly BLE when the scanner is enabled if it is disabled (#82153)

Co-authored-by: Shay Levy <levyshay1@gmail.com>
This commit is contained in:
J. Nick Koston 2022-11-15 15:37:45 -06:00 committed by GitHub
parent 7614aba401
commit ae7272575a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,7 +8,7 @@ from datetime import timedelta
from typing import Any, cast
import aioshelly
from aioshelly.ble import async_stop_scanner
from aioshelly.ble import async_ensure_ble_enabled, async_stop_scanner
from aioshelly.block_device import BlockDevice
from aioshelly.exceptions import DeviceConnectionError, InvalidAuthError, RpcCallError
from aioshelly.rpc_device import RpcDevice, UpdateType
@ -527,6 +527,10 @@ class ShellyRpcCoordinator(DataUpdateCoordinator):
BLE_MIN_VERSION,
)
return
if await async_ensure_ble_enabled(self.device):
# BLE enable required a reboot, don't bother connecting
# the scanner since it will be disconnected anyway
return
self._disconnected_callbacks.append(
await async_connect_scanner(self.hass, self, ble_scanner_mode)
)