Add MQTT publish request and response models, and implement publish route
- Introduced MQTTPublishRequest and MQTTPublishResponse models for handling MQTT message publishing. - Implemented a new POST route for publishing MQTT messages, including error handling and logging. - Enhanced the StandaloneAutoRecorder with improved logging during manual recording start. - Updated the frontend to include an MQTT Debug Panel for better monitoring and debugging capabilities.
This commit is contained in:
@@ -334,3 +334,21 @@ class SuccessResponse(BaseModel):
|
||||
message: str
|
||||
data: Optional[Dict[str, Any]] = None
|
||||
timestamp: str = Field(default_factory=lambda: datetime.now().isoformat())
|
||||
|
||||
|
||||
class MQTTPublishRequest(BaseModel):
|
||||
"""MQTT publish request model"""
|
||||
|
||||
topic: str = Field(..., description="MQTT topic to publish to")
|
||||
payload: str = Field(..., description="Message payload")
|
||||
qos: int = Field(default=0, ge=0, le=2, description="Quality of Service level (0-2)")
|
||||
retain: bool = Field(default=False, description="Whether to retain the message")
|
||||
|
||||
|
||||
class MQTTPublishResponse(BaseModel):
|
||||
"""MQTT publish response model"""
|
||||
|
||||
success: bool
|
||||
message: str
|
||||
topic: str
|
||||
payload: str
|
||||
|
||||
Reference in New Issue
Block a user