added availability check to battery sensor
This commit is contained in:
1 parent
1b34ac7f45
commit
344da5d070
2 files changed
+22
-7
No files matched your search
@@ -5,10 +5,12 @@ from __future__ import annotations
|
||||
import re
|
||||
import logging
|
||||
|
||||
from homeassistant.components import bluetooth
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_ADDRESS, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
|
||||
from .const import DOMAIN, MANUFACTURER
|
||||
|
||||
@@ -24,6 +26,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
if address is None:
|
||||
return False
|
||||
|
||||
if not bluetooth.async_address_present(hass, address):
|
||||
raise ConfigEntryNotReady("Bluetti device not present")
|
||||
|
||||
# Setup platforms
|
||||
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
||||
|
||||
|
||||
Reference in new issue
Block a user