Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add homeassistant.remove_area_from_floor service #707

Merged
merged 1 commit into from
Mar 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""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 area_registry as ar, config_validation as cv

from ....services import AbstractSpookAdminService

if TYPE_CHECKING:
from homeassistant.core import ServiceCall


class SpookService(AbstractSpookAdminService):
"""Home Assistant service to remove an area from a floor."""

domain = DOMAIN
service = "remove_area_from_floor"
schema = {
vol.Required("area_id"): vol.All(cv.ensure_list, [cv.string]),
}

async def async_handle_service(self, call: ServiceCall) -> None:
"""Handle the service call."""
area_registry = ar.async_get(self.hass)
for area_id in call.data["area_id"]:
area_registry.async_update(
area_id,
floor_id=None,
)
14 changes: 14 additions & 0 deletions custom_components/spook/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,20 @@ homeassistant_add_area_to_floor:
area:
multiple: true

homeassistant_remove_area_from_floor:
name: Remove an area from a floor 👻
description: >-
Removes an area from a floor. As an area can only be on one floor, this
call doesn't need to specify the floor.
fields:
area_id:
name: Area ID
description: The ID of the area to remove the floor from.
required: true
selector:
area:
multiple: true

homeassistant_ignore_all_discovered:
name: Ignore all currently discovered devices 👻
description: >-
Expand Down