settings.py 4.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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(
  7. default=True, description="Capture photo from printer camera when print completes"
  8. )
  9. default_filament_cost: float = Field(default=25.0, description="Default filament cost per kg")
  10. currency: str = Field(default="USD", description="Currency for cost tracking")
  11. energy_cost_per_kwh: float = Field(default=0.15, description="Electricity cost per kWh for energy tracking")
  12. energy_tracking_mode: str = Field(
  13. default="total",
  14. description="Energy display mode on stats: 'print' shows sum of per-print energy, 'total' shows lifetime plug consumption",
  15. )
  16. # Spoolman integration
  17. spoolman_enabled: bool = Field(default=False, description="Enable Spoolman integration for filament tracking")
  18. spoolman_url: str = Field(default="", description="Spoolman server URL (e.g., http://localhost:7912)")
  19. spoolman_sync_mode: str = Field(
  20. default="auto", description="Sync mode: 'auto' syncs immediately, 'manual' requires button press"
  21. )
  22. # Updates
  23. check_updates: bool = Field(default=True, description="Automatically check for updates on startup")
  24. # Language
  25. notification_language: str = Field(default="en", description="Language for push notifications (en, de)")
  26. # AMS threshold settings for humidity and temperature coloring
  27. ams_humidity_good: int = Field(default=40, description="Humidity threshold for good (green): <= this value")
  28. ams_humidity_fair: int = Field(
  29. default=60, description="Humidity threshold for fair (orange): <= this value, > is red"
  30. )
  31. ams_temp_good: float = Field(default=28.0, description="Temperature threshold for good (blue): <= this value")
  32. ams_temp_fair: float = Field(
  33. default=35.0, description="Temperature threshold for fair (orange): <= this value, > is red"
  34. )
  35. ams_history_retention_days: int = Field(default=30, description="Number of days to keep AMS sensor history data")
  36. # Date/time display format
  37. date_format: str = Field(default="system", description="Date format: system, us, eu, iso")
  38. time_format: str = Field(default="system", description="Time format: system, 12h, 24h")
  39. # Default printer for operations
  40. default_printer_id: int | None = Field(default=None, description="Default printer ID for uploads, reprints, etc.")
  41. # Telemetry
  42. telemetry_enabled: bool = Field(default=True, description="Send anonymous usage data to help improve BamBuddy")
  43. # Virtual Printer
  44. virtual_printer_enabled: bool = Field(default=False, description="Enable virtual printer for slicer uploads")
  45. virtual_printer_access_code: str = Field(default="", description="Access code for virtual printer authentication")
  46. virtual_printer_mode: str = Field(default="immediate", description="Archive mode: 'immediate' or 'queue'")
  47. class AppSettingsUpdate(BaseModel):
  48. """Schema for updating settings (all fields optional)."""
  49. auto_archive: bool | None = None
  50. save_thumbnails: bool | None = None
  51. capture_finish_photo: bool | None = None
  52. default_filament_cost: float | None = None
  53. currency: str | None = None
  54. energy_cost_per_kwh: float | None = None
  55. energy_tracking_mode: str | None = None
  56. spoolman_enabled: bool | None = None
  57. spoolman_url: str | None = None
  58. spoolman_sync_mode: str | None = None
  59. check_updates: bool | None = None
  60. notification_language: str | None = None
  61. ams_humidity_good: int | None = None
  62. ams_humidity_fair: int | None = None
  63. ams_temp_good: float | None = None
  64. ams_temp_fair: float | None = None
  65. ams_history_retention_days: int | None = None
  66. date_format: str | None = None
  67. time_format: str | None = None
  68. default_printer_id: int | None = None
  69. telemetry_enabled: bool | None = None
  70. virtual_printer_enabled: bool | None = None
  71. virtual_printer_access_code: str | None = None
  72. virtual_printer_mode: str | None = None