From ae7272575a30e73fc9d6cecb0217cd15a4ba0d59 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 15 Nov 2022 15:37:45 -0600 Subject: [PATCH] Enable shelly BLE when the scanner is enabled if it is disabled (#82153) Co-authored-by: Shay Levy --- homeassistant/components/shelly/coordinator.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/shelly/coordinator.py b/homeassistant/components/shelly/coordinator.py index 1de02f56a07..11bdf933037 100644 --- a/homeassistant/components/shelly/coordinator.py +++ b/homeassistant/components/shelly/coordinator.py @@ -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) )