221 files
This commit is contained in:
@@ -11,6 +11,8 @@ from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
from homeassistant.helpers.entity_component import DATA_INSTANCES, EntityComponent
|
||||
|
||||
from ....const import DOMAIN as SPOOK_DOMAIN
|
||||
from ....errors import entity_not_found
|
||||
from ....services import AbstractSpookAdminService
|
||||
|
||||
if TYPE_CHECKING:
|
||||
@@ -46,13 +48,17 @@ class SpookService(AbstractSpookAdminService):
|
||||
zone_ids = []
|
||||
for entity_id in call.data["entity_id"]:
|
||||
if not (entity := entity_component.get_entity(entity_id)):
|
||||
message = f"Could not find entity_id: {entity_id}"
|
||||
raise HomeAssistantError(message)
|
||||
raise entity_not_found(entity_id)
|
||||
|
||||
# pylint: disable-next=protected-access
|
||||
if not entity.editable or "id" not in entity._config: # noqa: SLF001
|
||||
message = f"This zone is not editable: {entity_id}"
|
||||
raise HomeAssistantError(message)
|
||||
raise HomeAssistantError(
|
||||
translation_domain=SPOOK_DOMAIN,
|
||||
translation_key="zone_not_editable",
|
||||
translation_placeholders={
|
||||
"entity_id": entity_id,
|
||||
},
|
||||
)
|
||||
|
||||
# pylint: disable-next=protected-access
|
||||
zone_ids.append(entity._config["id"]) # noqa: SLF001
|
||||
|
||||
Reference in New Issue
Block a user