mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 09:17:10 +00:00
Improve cloud migration (#92520)
* Improve cloud migration * Tweak * Use entity_ids func --------- Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
parent
3f630493ff
commit
b6664ce367
@ -3,7 +3,7 @@ from abc import ABC, abstractmethod
|
|||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.core import CALLBACK_TYPE, callback
|
from homeassistant.core import CALLBACK_TYPE, HomeAssistant, callback
|
||||||
from homeassistant.helpers.storage import Store
|
from homeassistant.helpers.storage import Store
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
@ -19,7 +19,7 @@ class AbstractConfig(ABC):
|
|||||||
|
|
||||||
_unsub_proactive_report: asyncio.Task[CALLBACK_TYPE] | None = None
|
_unsub_proactive_report: asyncio.Task[CALLBACK_TYPE] | None = None
|
||||||
|
|
||||||
def __init__(self, hass):
|
def __init__(self, hass: HomeAssistant) -> None:
|
||||||
"""Initialize abstract config."""
|
"""Initialize abstract config."""
|
||||||
self.hass = hass
|
self.hass = hass
|
||||||
self._store = None
|
self._store = None
|
||||||
|
@ -199,14 +199,10 @@ class CloudAlexaConfig(alexa_config.AbstractConfig):
|
|||||||
# Don't migrate if there's a YAML config
|
# Don't migrate if there's a YAML config
|
||||||
return
|
return
|
||||||
|
|
||||||
for state in self.hass.states.async_all():
|
for entity_id in {
|
||||||
async_expose_entity(
|
*self.hass.states.async_entity_ids(),
|
||||||
self.hass,
|
*self._prefs.alexa_entity_configs,
|
||||||
CLOUD_ALEXA,
|
}:
|
||||||
state.entity_id,
|
|
||||||
self._should_expose_legacy(state.entity_id),
|
|
||||||
)
|
|
||||||
for entity_id in self._prefs.alexa_entity_configs:
|
|
||||||
async_expose_entity(
|
async_expose_entity(
|
||||||
self.hass,
|
self.hass,
|
||||||
CLOUD_ALEXA,
|
CLOUD_ALEXA,
|
||||||
|
@ -175,23 +175,10 @@ class CloudGoogleConfig(AbstractConfig):
|
|||||||
# Don't migrate if there's a YAML config
|
# Don't migrate if there's a YAML config
|
||||||
return
|
return
|
||||||
|
|
||||||
for state in self.hass.states.async_all():
|
for entity_id in {
|
||||||
entity_id = state.entity_id
|
*self.hass.states.async_entity_ids(),
|
||||||
async_expose_entity(
|
*self._prefs.google_entity_configs,
|
||||||
self.hass,
|
}:
|
||||||
CLOUD_GOOGLE,
|
|
||||||
entity_id,
|
|
||||||
self._should_expose_legacy(entity_id),
|
|
||||||
)
|
|
||||||
if _2fa_disabled := (self._2fa_disabled_legacy(entity_id) is not None):
|
|
||||||
async_set_assistant_option(
|
|
||||||
self.hass,
|
|
||||||
CLOUD_GOOGLE,
|
|
||||||
entity_id,
|
|
||||||
PREF_DISABLE_2FA,
|
|
||||||
_2fa_disabled,
|
|
||||||
)
|
|
||||||
for entity_id in self._prefs.google_entity_configs:
|
|
||||||
async_expose_entity(
|
async_expose_entity(
|
||||||
self.hass,
|
self.hass,
|
||||||
CLOUD_GOOGLE,
|
CLOUD_GOOGLE,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user