sensoren
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
|
||||
from packages.home_capabilities import LightState, ThermostatState, ContactState, TempHumidityState
|
||||
from apps.abstraction.transformation import (
|
||||
transform_abstract_to_vendor,
|
||||
transform_vendor_to_abstract
|
||||
@@ -222,12 +222,16 @@ async def handle_vendor_state(
|
||||
elif device_type in {"contact", "contact_sensor"}:
|
||||
# Validate contact sensor state
|
||||
ContactState.model_validate(abstract_payload)
|
||||
elif device_type in {"temp_humidity", "temp_humidity_sensor"}:
|
||||
# Validate temperature & humidity sensor state
|
||||
TempHumidityState.model_validate(abstract_payload)
|
||||
except ValidationError as e:
|
||||
logger.error(f"Validation failed for {device_type} STATE {device_id}: {e}")
|
||||
return
|
||||
|
||||
# Normalize device type for topic (use 'contact' for both 'contact' and 'contact_sensor')
|
||||
topic_type = "contact" if device_type in {"contact", "contact_sensor"} else device_type
|
||||
topic_type = "temp_humidity" if device_type in {"temp_humidity", "temp_humidity_sensor"} else topic_type
|
||||
|
||||
# Publish to abstract state topic (retained)
|
||||
abstract_topic = f"home/{topic_type}/{device_id}/state"
|
||||
|
||||
Reference in New Issue
Block a user