switch added
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, RelayState, ThreePhasePowerState
|
||||
from packages.home_capabilities import LightState, ThermostatState, ContactState, TempHumidityState, RelayState, ThreePhasePowerState, SwitchState
|
||||
from apps.abstraction.transformation import (
|
||||
transform_abstract_to_vendor,
|
||||
transform_vendor_to_abstract
|
||||
@@ -174,6 +174,10 @@ async def handle_abstract_set(
|
||||
# Contact sensors are read-only - SET commands should not occur
|
||||
logger.warning(f"Contact sensor {device_id} received SET command - ignoring (read-only device)")
|
||||
return
|
||||
elif device_type == "switch":
|
||||
# Switches are read-only - SET commands should not occur
|
||||
logger.warning(f"Switch {device_id} received SET command - ignoring (read-only device)")
|
||||
return
|
||||
except ValidationError as e:
|
||||
logger.error(f"Validation failed for {device_type} SET {device_id}: {e}")
|
||||
return
|
||||
@@ -227,6 +231,9 @@ async def handle_vendor_state(
|
||||
elif device_type == "three_phase_powermeter":
|
||||
# Validate three-phase powermeter state
|
||||
ThreePhasePowerState.model_validate(abstract_payload)
|
||||
elif device_type == "switch":
|
||||
# Validate switch state
|
||||
SwitchState.model_validate(abstract_payload)
|
||||
except ValidationError as e:
|
||||
logger.error(f"Validation failed for {device_type} STATE {device_id}: {e}")
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user