Reimplemented group entities
This commit is contained in:
parent
08c4372c4e
commit
e131f58849
4 changed files with 25 additions and 2 deletions
|
@ -1,2 +1,4 @@
|
|||
from .bridge import Bridge, BridgeException
|
||||
from .entity import Entity
|
||||
from .group import Group
|
||||
from .room import Room
|
||||
|
|
|
@ -1,6 +1,13 @@
|
|||
class Entity:
|
||||
|
||||
def __init__(
|
||||
self, *, id: str, name: str, room: str, device_type: str, groups: list[str] = []
|
||||
self,
|
||||
*,
|
||||
id: str,
|
||||
name: str,
|
||||
room: str | None,
|
||||
device_type: str,
|
||||
groups: list[str] = [],
|
||||
) -> None:
|
||||
self._id = id
|
||||
self._name = name
|
||||
|
@ -18,7 +25,8 @@ class Entity:
|
|||
return self._name
|
||||
|
||||
@property
|
||||
def room(self) -> str:
|
||||
def room(self) -> str | None:
|
||||
"""Returns the room of the entity. Meta entities, like groups and rooms, are usually not part of rooms and likely return None."""
|
||||
return self._room
|
||||
|
||||
@property
|
||||
|
|
6
src/core/group.py
Normal file
6
src/core/group.py
Normal file
|
@ -0,0 +1,6 @@
|
|||
from core import Entity
|
||||
|
||||
|
||||
class Group(Entity):
|
||||
def __init__(self, *, id: str, name: str):
|
||||
super().__init__(id=id, name=name, room=None, device_type="group")
|
7
src/core/room.py
Normal file
7
src/core/room.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
from core import Group
|
||||
|
||||
|
||||
class Room(Group):
|
||||
def __init__(self, *, id: str, name: str):
|
||||
super().__init__(id=id, name=name)
|
||||
self._device_type = "room"
|
Loading…
Reference in a new issue