add type relay
This commit is contained in:
@@ -15,7 +15,7 @@ import uuid
|
||||
from aiomqtt import Client
|
||||
from pydantic import ValidationError
|
||||
|
||||
from packages.home_capabilities import LightState, ThermostatState, ContactState, TempHumidityState
|
||||
from packages.home_capabilities import LightState, ThermostatState, ContactState, TempHumidityState, RelayState
|
||||
from apps.abstraction.transformation import (
|
||||
transform_abstract_to_vendor,
|
||||
transform_vendor_to_abstract
|
||||
@@ -154,6 +154,9 @@ async def handle_abstract_set(
|
||||
if device_type == "light":
|
||||
# Validate light SET payload (power and/or brightness)
|
||||
LightState.model_validate(abstract_payload)
|
||||
elif device_type == "relay":
|
||||
# Validate relay SET payload (power only)
|
||||
RelayState.model_validate(abstract_payload)
|
||||
elif device_type == "thermostat":
|
||||
# For thermostat SET: only allow mode and target fields
|
||||
allowed_set_fields = {"mode", "target"}
|
||||
@@ -216,6 +219,8 @@ async def handle_vendor_state(
|
||||
try:
|
||||
if device_type == "light":
|
||||
LightState.model_validate(abstract_payload)
|
||||
elif device_type == "relay":
|
||||
RelayState.model_validate(abstract_payload)
|
||||
elif device_type == "thermostat":
|
||||
# Validate thermostat state: mode, target, current (required), battery, window_open
|
||||
ThermostatState.model_validate(abstract_payload)
|
||||
|
||||
Reference in New Issue
Block a user