Force migration of cloud settings to exposed_entities (#92499)

This commit is contained in:
Erik Montnemery 2023-05-04 15:53:28 +02:00 committed by GitHub
parent 9b74cb9507
commit e14be8b0ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 2 additions and 20 deletions

View File

@ -24,7 +24,6 @@ from homeassistant.components.binary_sensor import BinarySensorDeviceClass
from homeassistant.components.homeassistant.exposed_entities import ( from homeassistant.components.homeassistant.exposed_entities import (
async_expose_entity, async_expose_entity,
async_get_assistant_settings, async_get_assistant_settings,
async_get_entity_settings,
async_listen_entity_updates, async_listen_entity_updates,
async_should_expose, async_should_expose,
) )
@ -201,10 +200,6 @@ class CloudAlexaConfig(alexa_config.AbstractConfig):
return return
for state in self.hass.states.async_all(): for state in self.hass.states.async_all():
with suppress(HomeAssistantError):
entity_settings = async_get_entity_settings(self.hass, state.entity_id)
if CLOUD_ALEXA in entity_settings:
continue
async_expose_entity( async_expose_entity(
self.hass, self.hass,
CLOUD_ALEXA, CLOUD_ALEXA,
@ -212,10 +207,6 @@ class CloudAlexaConfig(alexa_config.AbstractConfig):
self._should_expose_legacy(state.entity_id), self._should_expose_legacy(state.entity_id),
) )
for entity_id in self._prefs.alexa_entity_configs: for entity_id in self._prefs.alexa_entity_configs:
with suppress(HomeAssistantError):
entity_settings = async_get_entity_settings(self.hass, entity_id)
if CLOUD_ALEXA in entity_settings:
continue
async_expose_entity( async_expose_entity(
self.hass, self.hass,
CLOUD_ALEXA, CLOUD_ALEXA,

View File

@ -1,6 +1,5 @@
"""Google config for Cloud.""" """Google config for Cloud."""
import asyncio import asyncio
from contextlib import suppress
from http import HTTPStatus from http import HTTPStatus
import logging import logging
from typing import Any from typing import Any
@ -178,10 +177,6 @@ class CloudGoogleConfig(AbstractConfig):
for state in self.hass.states.async_all(): for state in self.hass.states.async_all():
entity_id = state.entity_id entity_id = state.entity_id
with suppress(HomeAssistantError):
entity_settings = async_get_entity_settings(self.hass, entity_id)
if CLOUD_GOOGLE in entity_settings:
continue
async_expose_entity( async_expose_entity(
self.hass, self.hass,
CLOUD_GOOGLE, CLOUD_GOOGLE,
@ -197,10 +192,6 @@ class CloudGoogleConfig(AbstractConfig):
_2fa_disabled, _2fa_disabled,
) )
for entity_id in self._prefs.google_entity_configs: for entity_id in self._prefs.google_entity_configs:
with suppress(HomeAssistantError):
entity_settings = async_get_entity_settings(self.hass, entity_id)
if CLOUD_GOOGLE in entity_settings:
continue
async_expose_entity( async_expose_entity(
self.hass, self.hass,
CLOUD_GOOGLE, CLOUD_GOOGLE,

View File

@ -628,7 +628,7 @@ async def test_alexa_config_migrate_expose_entity_prefs(
"cloud.alexa": {"should_expose": True} "cloud.alexa": {"should_expose": True}
} }
assert async_get_entity_settings(hass, entity_migrated.entity_id) == { assert async_get_entity_settings(hass, entity_migrated.entity_id) == {
"cloud.alexa": {"should_expose": False} "cloud.alexa": {"should_expose": True}
} }
assert async_get_entity_settings(hass, entity_config.entity_id) == { assert async_get_entity_settings(hass, entity_config.entity_id) == {
"cloud.alexa": {"should_expose": False} "cloud.alexa": {"should_expose": False}

View File

@ -580,7 +580,7 @@ async def test_google_config_migrate_expose_entity_prefs(
"cloud.google_assistant": {"should_expose": True} "cloud.google_assistant": {"should_expose": True}
} }
assert async_get_entity_settings(hass, entity_migrated.entity_id) == { assert async_get_entity_settings(hass, entity_migrated.entity_id) == {
"cloud.google_assistant": {"should_expose": False} "cloud.google_assistant": {"should_expose": True}
} }
assert async_get_entity_settings(hass, entity_no_2fa_exposed.entity_id) == { assert async_get_entity_settings(hass, entity_no_2fa_exposed.entity_id) == {
"cloud.google_assistant": {"disable_2fa": True, "should_expose": True} "cloud.google_assistant": {"disable_2fa": True, "should_expose": True}