Fetch iCloud family devices only when wanted (#32644)
* Fetch iCloud family devices only when wanted * Review: form data_schema as init schema
This commit is contained in:
parent
cea5cac6e2
commit
01dc81d8fb
7 changed files with 59 additions and 11 deletions
|
@ -14,8 +14,10 @@ from .account import IcloudAccount
|
|||
from .const import (
|
||||
CONF_GPS_ACCURACY_THRESHOLD,
|
||||
CONF_MAX_INTERVAL,
|
||||
CONF_WITH_FAMILY,
|
||||
DEFAULT_GPS_ACCURACY_THRESHOLD,
|
||||
DEFAULT_MAX_INTERVAL,
|
||||
DEFAULT_WITH_FAMILY,
|
||||
DOMAIN,
|
||||
PLATFORMS,
|
||||
STORAGE_KEY,
|
||||
|
@ -71,6 +73,7 @@ ACCOUNT_SCHEMA = vol.Schema(
|
|||
{
|
||||
vol.Required(CONF_USERNAME): cv.string,
|
||||
vol.Required(CONF_PASSWORD): cv.string,
|
||||
vol.Optional(CONF_WITH_FAMILY, default=DEFAULT_WITH_FAMILY): cv.boolean,
|
||||
vol.Optional(CONF_MAX_INTERVAL, default=DEFAULT_MAX_INTERVAL): cv.positive_int,
|
||||
vol.Optional(
|
||||
CONF_GPS_ACCURACY_THRESHOLD, default=DEFAULT_GPS_ACCURACY_THRESHOLD
|
||||
|
@ -110,6 +113,7 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool
|
|||
|
||||
username = entry.data[CONF_USERNAME]
|
||||
password = entry.data[CONF_PASSWORD]
|
||||
with_family = entry.data[CONF_WITH_FAMILY]
|
||||
max_interval = entry.data[CONF_MAX_INTERVAL]
|
||||
gps_accuracy_threshold = entry.data[CONF_GPS_ACCURACY_THRESHOLD]
|
||||
|
||||
|
@ -120,7 +124,13 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool
|
|||
icloud_dir = hass.helpers.storage.Store(STORAGE_VERSION, STORAGE_KEY)
|
||||
|
||||
account = IcloudAccount(
|
||||
hass, username, password, icloud_dir, max_interval, gps_accuracy_threshold,
|
||||
hass,
|
||||
username,
|
||||
password,
|
||||
icloud_dir,
|
||||
with_family,
|
||||
max_interval,
|
||||
gps_accuracy_threshold,
|
||||
)
|
||||
await hass.async_add_executor_job(account.setup)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue