settings.py 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. from pydantic import BaseModel, Field
  2. class AppSettings(BaseModel):
  3. """Application settings schema."""
  4. auto_archive: bool = Field(default=True, description="Automatically archive prints when completed")
  5. save_thumbnails: bool = Field(default=True, description="Extract and save preview images from 3MF files")
  6. capture_finish_photo: bool = Field(default=True, description="Capture photo from printer camera when print completes")
  7. default_filament_cost: float = Field(default=25.0, description="Default filament cost per kg")
  8. currency: str = Field(default="USD", description="Currency for cost tracking")
  9. energy_cost_per_kwh: float = Field(default=0.15, description="Electricity cost per kWh for energy tracking")
  10. energy_tracking_mode: str = Field(default="total", description="Energy display mode on stats: 'print' shows sum of per-print energy, 'total' shows lifetime plug consumption")
  11. # Spoolman integration
  12. spoolman_enabled: bool = Field(default=False, description="Enable Spoolman integration for filament tracking")
  13. spoolman_url: str = Field(default="", description="Spoolman server URL (e.g., http://localhost:7912)")
  14. spoolman_sync_mode: str = Field(default="auto", description="Sync mode: 'auto' syncs immediately, 'manual' requires button press")
  15. # Updates
  16. check_updates: bool = Field(default=True, description="Automatically check for updates on startup")
  17. # Language
  18. notification_language: str = Field(default="en", description="Language for push notifications (en, de)")
  19. # AMS threshold settings for humidity and temperature coloring
  20. ams_humidity_good: int = Field(default=40, description="Humidity threshold for good (green): <= this value")
  21. ams_humidity_fair: int = Field(default=60, description="Humidity threshold for fair (orange): <= this value, > is red")
  22. ams_temp_good: float = Field(default=28.0, description="Temperature threshold for good (blue): <= this value")
  23. ams_temp_fair: float = Field(default=35.0, description="Temperature threshold for fair (orange): <= this value, > is red")
  24. class AppSettingsUpdate(BaseModel):
  25. """Schema for updating settings (all fields optional)."""
  26. auto_archive: bool | None = None
  27. save_thumbnails: bool | None = None
  28. capture_finish_photo: bool | None = None
  29. default_filament_cost: float | None = None
  30. currency: str | None = None
  31. energy_cost_per_kwh: float | None = None
  32. energy_tracking_mode: str | None = None
  33. spoolman_enabled: bool | None = None
  34. spoolman_url: str | None = None
  35. spoolman_sync_mode: str | None = None
  36. check_updates: bool | None = None
  37. notification_language: str | None = None
  38. ams_humidity_good: int | None = None
  39. ams_humidity_fair: int | None = None
  40. ams_temp_good: float | None = None
  41. ams_temp_fair: float | None = None