Entity Registry
registry
In-memory entity registry.
The registry stores Entity instances keyed by their fully-qualified
entity_id and supports lookup by short object-id scoped to a domain.
It is owned by each HAClient instance — there are no global singletons.
EntityRegistry
Mapping of entity_id to Entity.
Source code in src/haclient/core/registry.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
register
register(entity: Entity) -> None
Register entity, overwriting any existing entry.
Source code in src/haclient/core/registry.py
25 26 27 | |
unregister
unregister(entity_id: str) -> None
Remove the entity identified by entity_id if present.
Source code in src/haclient/core/registry.py
29 30 31 | |
get
get(entity_id: str) -> Entity | None
Return the entity for entity_id or None if missing.
Source code in src/haclient/core/registry.py
33 34 35 | |
require
require(entity_id: str) -> Entity
Return the entity for entity_id or raise.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity_id
|
str
|
Fully-qualified entity id. |
required |
Returns:
| Type | Description |
|---|---|
Entity
|
The registered entity. |
Raises:
| Type | Description |
|---|---|
EntityNotFoundError
|
If no entity is registered under |
Source code in src/haclient/core/registry.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | |
clear
clear() -> None
Remove all registered entities.
Source code in src/haclient/core/registry.py
69 70 71 | |
resolve
resolve(domain: str, name: str) -> str
Build a fully-qualified entity_id from domain and name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
domain
|
str
|
The HA domain. |
required |
name
|
str
|
The short object-id (no dot allowed). |
required |
Returns:
| Type | Description |
|---|---|
str
|
The fully-qualified entity id. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If name contains a dot. |
Source code in src/haclient/core/registry.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
in_domain
in_domain(domain: str) -> list[Entity]
Return all entities whose id starts with {domain}..
Source code in src/haclient/core/registry.py
101 102 103 104 | |