-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added service to update an entity's ID (#537)
- Loading branch information
1 parent
9033c39
commit 825ba70
Showing
5 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
custom_components/spook/ectoplasms/homeassistant/services/update_entity_id.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
"""Spook - Not your homie.""" | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
import voluptuous as vol | ||
|
||
from homeassistant.components.homeassistant import DOMAIN | ||
from homeassistant.helpers import config_validation as cv, entity_registry as er | ||
|
||
from ....services import AbstractSpookAdminService | ||
|
||
if TYPE_CHECKING: | ||
from homeassistant.core import ServiceCall | ||
|
||
|
||
class SpookService(AbstractSpookAdminService): | ||
"""Home Assistant Core integration service to update an entity's ID.""" | ||
|
||
domain = DOMAIN | ||
service = "update_entity_id" | ||
schema = { | ||
vol.Required("entity_id"): cv.entity_id, | ||
vol.Required("new_entity_id"): cv.entity_id, | ||
} | ||
|
||
async def async_handle_service(self, call: ServiceCall) -> None: | ||
"""Handle the service call.""" | ||
entity_registry = er.async_get(self.hass) | ||
entity_registry.async_update_entity( | ||
entity_id=call.data["entity_id"], | ||
new_entity_id=call.data["new_entity_id"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters