Add profile system for automatic target activation
Profiles monitor running processes and foreground windows to automatically start/stop targets when conditions are met. Includes profile engine, platform detector (WMI), REST API, process browser endpoint, and calibration persistence fix. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
58
server/src/wled_controller/api/schemas/profiles.py
Normal file
58
server/src/wled_controller/api/schemas/profiles.py
Normal file
@@ -0,0 +1,58 @@
|
||||
"""Profile-related schemas."""
|
||||
|
||||
from datetime import datetime
|
||||
from typing import List, Optional
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class ConditionSchema(BaseModel):
|
||||
"""A single condition within a profile."""
|
||||
|
||||
condition_type: str = Field(description="Condition type discriminator (e.g. 'application')")
|
||||
apps: Optional[List[str]] = Field(None, description="Process names (for application condition)")
|
||||
match_type: Optional[str] = Field(None, description="'running' or 'topmost' (for application condition)")
|
||||
|
||||
|
||||
class ProfileCreate(BaseModel):
|
||||
"""Request to create a profile."""
|
||||
|
||||
name: str = Field(description="Profile name", min_length=1, max_length=100)
|
||||
enabled: bool = Field(default=True, description="Whether the profile is enabled")
|
||||
condition_logic: str = Field(default="or", description="How conditions combine: 'or' or 'and'")
|
||||
conditions: List[ConditionSchema] = Field(default_factory=list, description="List of conditions")
|
||||
target_ids: List[str] = Field(default_factory=list, description="Target IDs to activate")
|
||||
|
||||
|
||||
class ProfileUpdate(BaseModel):
|
||||
"""Request to update a profile."""
|
||||
|
||||
name: Optional[str] = Field(None, description="Profile name", min_length=1, max_length=100)
|
||||
enabled: Optional[bool] = Field(None, description="Whether the profile is enabled")
|
||||
condition_logic: Optional[str] = Field(None, description="How conditions combine: 'or' or 'and'")
|
||||
conditions: Optional[List[ConditionSchema]] = Field(None, description="List of conditions")
|
||||
target_ids: Optional[List[str]] = Field(None, description="Target IDs to activate")
|
||||
|
||||
|
||||
class ProfileResponse(BaseModel):
|
||||
"""Profile information response."""
|
||||
|
||||
id: str = Field(description="Profile ID")
|
||||
name: str = Field(description="Profile name")
|
||||
enabled: bool = Field(description="Whether the profile is enabled")
|
||||
condition_logic: str = Field(description="Condition combination logic")
|
||||
conditions: List[ConditionSchema] = Field(description="List of conditions")
|
||||
target_ids: List[str] = Field(description="Target IDs to activate")
|
||||
is_active: bool = Field(default=False, description="Whether the profile is currently active")
|
||||
active_target_ids: List[str] = Field(default_factory=list, description="Targets currently owned by this profile")
|
||||
last_activated_at: Optional[datetime] = Field(None, description="Last time this profile was activated")
|
||||
last_deactivated_at: Optional[datetime] = Field(None, description="Last time this profile was deactivated")
|
||||
created_at: datetime = Field(description="Creation timestamp")
|
||||
updated_at: datetime = Field(description="Last update timestamp")
|
||||
|
||||
|
||||
class ProfileListResponse(BaseModel):
|
||||
"""List of profiles response."""
|
||||
|
||||
profiles: List[ProfileResponse] = Field(description="List of profiles")
|
||||
count: int = Field(description="Number of profiles")
|
||||
@@ -40,3 +40,10 @@ class DisplayListResponse(BaseModel):
|
||||
|
||||
displays: List[DisplayInfo] = Field(description="Available displays")
|
||||
count: int = Field(description="Number of displays")
|
||||
|
||||
|
||||
class ProcessListResponse(BaseModel):
|
||||
"""List of running processes."""
|
||||
|
||||
processes: List[str] = Field(description="Sorted list of unique process names")
|
||||
count: int = Field(description="Number of unique processes")
|
||||
|
||||
Reference in New Issue
Block a user