1
0

base.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. """Base MQTT handler interface."""
  2. from abc import ABC, abstractmethod
  3. from typing import Dict, Callable, List, Optional, Any
  4. class BaseMQTTHandler(ABC):
  5. """Abstract base class for MQTT handlers."""
  6. @abstractmethod
  7. def start(self) -> None:
  8. """Start the MQTT handler."""
  9. pass
  10. @abstractmethod
  11. def stop(self) -> None:
  12. """Stop the MQTT handler."""
  13. pass
  14. @abstractmethod
  15. def update_state(self, is_running: Optional[bool] = None,
  16. current_file: Optional[str] = None,
  17. patterns: Optional[List[str]] = None,
  18. serial: Optional[str] = None,
  19. playlist: Optional[Dict[str, Any]] = None) -> None:
  20. """Update the state of the sand table and publish to MQTT.
  21. Args:
  22. is_running: Whether the table is currently running a pattern
  23. current_file: The currently playing file
  24. patterns: List of available pattern files
  25. serial: Serial connection status
  26. playlist: Current playlist information if in playlist mode
  27. """
  28. pass
  29. @property
  30. @abstractmethod
  31. def is_enabled(self) -> bool:
  32. """Return whether MQTT functionality is enabled."""
  33. pass
  34. @property
  35. @abstractmethod
  36. def is_connected(self) -> bool:
  37. """Return whether MQTT client is connected to the broker."""
  38. pass