mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
Use EventType for remaining registry events (#115189)
This commit is contained in:
parent
6116f11e6c
commit
0d18679c8f
@ -8,6 +8,7 @@ from typing import Any, Literal, TypedDict, cast
|
||||
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.util import slugify
|
||||
from homeassistant.util.event_type import EventType
|
||||
|
||||
from . import device_registry as dr, entity_registry as er
|
||||
from .normalized_name_base_registry import (
|
||||
@ -20,7 +21,9 @@ from .storage import Store
|
||||
from .typing import UNDEFINED, UndefinedType
|
||||
|
||||
DATA_REGISTRY = "area_registry"
|
||||
EVENT_AREA_REGISTRY_UPDATED = "area_registry_updated"
|
||||
EVENT_AREA_REGISTRY_UPDATED: EventType[EventAreaRegistryUpdatedData] = EventType(
|
||||
"area_registry_updated"
|
||||
)
|
||||
STORAGE_KEY = "core.area_registry"
|
||||
STORAGE_VERSION_MAJOR = 1
|
||||
STORAGE_VERSION_MINOR = 6
|
||||
@ -219,7 +222,8 @@ class AreaRegistry(BaseRegistry[AreasRegistryStoreData]):
|
||||
self.areas[area.id] = area
|
||||
self.async_schedule_save()
|
||||
self.hass.bus.async_fire(
|
||||
EVENT_AREA_REGISTRY_UPDATED, {"action": "create", "area_id": area.id}
|
||||
EVENT_AREA_REGISTRY_UPDATED,
|
||||
EventAreaRegistryUpdatedData(action="create", area_id=area.id),
|
||||
)
|
||||
return area
|
||||
|
||||
@ -234,7 +238,8 @@ class AreaRegistry(BaseRegistry[AreasRegistryStoreData]):
|
||||
del self.areas[area_id]
|
||||
|
||||
self.hass.bus.async_fire(
|
||||
EVENT_AREA_REGISTRY_UPDATED, {"action": "remove", "area_id": area_id}
|
||||
EVENT_AREA_REGISTRY_UPDATED,
|
||||
EventAreaRegistryUpdatedData(action="remove", area_id=area_id),
|
||||
)
|
||||
|
||||
self.async_schedule_save()
|
||||
@ -262,7 +267,8 @@ class AreaRegistry(BaseRegistry[AreasRegistryStoreData]):
|
||||
picture=picture,
|
||||
)
|
||||
self.hass.bus.async_fire(
|
||||
EVENT_AREA_REGISTRY_UPDATED, {"action": "update", "area_id": area_id}
|
||||
EVENT_AREA_REGISTRY_UPDATED,
|
||||
EventAreaRegistryUpdatedData(action="update", area_id=area_id),
|
||||
)
|
||||
return updated
|
||||
|
||||
|
@ -8,6 +8,7 @@ from dataclasses import dataclass, field
|
||||
from typing import Literal, TypedDict, cast
|
||||
|
||||
from homeassistant.core import Event, HomeAssistant, callback
|
||||
from homeassistant.util.event_type import EventType
|
||||
from homeassistant.util.ulid import ulid_now
|
||||
|
||||
from .registry import BaseRegistry
|
||||
@ -15,7 +16,9 @@ from .storage import Store
|
||||
from .typing import UNDEFINED, UndefinedType
|
||||
|
||||
DATA_REGISTRY = "category_registry"
|
||||
EVENT_CATEGORY_REGISTRY_UPDATED = "category_registry_updated"
|
||||
EVENT_CATEGORY_REGISTRY_UPDATED: EventType[EventCategoryRegistryUpdatedData] = (
|
||||
EventType("category_registry_updated")
|
||||
)
|
||||
STORAGE_KEY = "core.category_registry"
|
||||
STORAGE_VERSION_MAJOR = 1
|
||||
|
||||
|
@ -9,6 +9,7 @@ from typing import Literal, TypedDict, cast
|
||||
|
||||
from homeassistant.core import Event, HomeAssistant, callback
|
||||
from homeassistant.util import slugify
|
||||
from homeassistant.util.event_type import EventType
|
||||
|
||||
from .normalized_name_base_registry import (
|
||||
NormalizedNameBaseRegistryEntry,
|
||||
@ -20,7 +21,9 @@ from .storage import Store
|
||||
from .typing import UNDEFINED, UndefinedType
|
||||
|
||||
DATA_REGISTRY = "floor_registry"
|
||||
EVENT_FLOOR_REGISTRY_UPDATED = "floor_registry_updated"
|
||||
EVENT_FLOOR_REGISTRY_UPDATED: EventType[EventFloorRegistryUpdatedData] = EventType(
|
||||
"floor_registry_updated"
|
||||
)
|
||||
STORAGE_KEY = "core.floor_registry"
|
||||
STORAGE_VERSION_MAJOR = 1
|
||||
|
||||
|
@ -9,6 +9,7 @@ from typing import Literal, TypedDict, cast
|
||||
|
||||
from homeassistant.core import Event, HomeAssistant, callback
|
||||
from homeassistant.util import slugify
|
||||
from homeassistant.util.event_type import EventType
|
||||
|
||||
from .normalized_name_base_registry import (
|
||||
NormalizedNameBaseRegistryEntry,
|
||||
@ -20,7 +21,9 @@ from .storage import Store
|
||||
from .typing import UNDEFINED, UndefinedType
|
||||
|
||||
DATA_REGISTRY = "label_registry"
|
||||
EVENT_LABEL_REGISTRY_UPDATED = "label_registry_updated"
|
||||
EVENT_LABEL_REGISTRY_UPDATED: EventType[EventLabelRegistryUpdatedData] = EventType(
|
||||
"label_registry_updated"
|
||||
)
|
||||
STORAGE_KEY = "core.label_registry"
|
||||
STORAGE_VERSION_MAJOR = 1
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user