29 lines
808 B
Python
29 lines
808 B
Python
"""Spook - 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, label_registry as lr
|
|
|
|
from ....services import AbstractSpookAdminService
|
|
|
|
if TYPE_CHECKING:
|
|
from homeassistant.core import ServiceCall
|
|
|
|
|
|
class SpookService(AbstractSpookAdminService):
|
|
"""Home Assistant service to delete labels on the fly."""
|
|
|
|
domain = DOMAIN
|
|
service = "delete_label"
|
|
schema = {vol.Required("label_id"): cv.string}
|
|
|
|
async def async_handle_service(self, call: ServiceCall) -> None:
|
|
"""Handle the service call."""
|
|
label_registry = lr.async_get(self.hass)
|
|
label_registry.async_delete(call.data["label_id"])
|