mirror of
https://github.com/MarkParker5/STARK.git
synced 2024-11-24 08:12:13 +02:00
24 lines
713 B
Python
24 lines
713 B
Python
from .Database import *
|
|
from .Merlin import *
|
|
|
|
class SmartHomeManager:
|
|
house: House
|
|
|
|
def __init__(self, house: House):
|
|
self.house = house
|
|
|
|
def addDevice(name: str, room_id: UUID, urdi: bytes) -> Device:
|
|
device = Device()
|
|
device.name = name
|
|
device.room_id = room_id
|
|
device.urdi = urdi
|
|
DevicesManager(device).save()
|
|
return device
|
|
|
|
def deviceSet(value: Any, parameter_id: UUID, device_id: UUID):
|
|
device = DevicesManager.get(device_id)
|
|
parameter = ParametersManager.get(parameter_id)
|
|
f = device.parameters.index(parameter_id)
|
|
x = parameter.type.toByte(value)
|
|
Merlin.send(MerlinMessage(device.urdi, f, x))
|