Files
brewpi/components/sensor/tempsensor_factory.py
jensandClaude Sonnet 4.6 f7355270c8 Extract shared factory dispatch into ComponentFactory base class
All four name-dispatch factories repeated the same if/elif lazy-import
pattern. Replace with a ComponentFactory base class holding a callable
registry and a _lazy() helper for the common import-and-construct case.
PlantFactory is an orchestrator, not a dispatcher, and is left as-is.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tqxrk8uj4M3w3d3eXm3xK8
2026-06-25 20:44:43 +02:00

9 lines
288 B
Python

from components.factory import ComponentFactory, _lazy
class TempSensorFactory(ComponentFactory):
_registry = {
"sim": _lazy("components.sensor.tempSensorSim", "TempSensorSim"),
"31865": _lazy("components.sensor.tempSensor_max31865", "TempSensor_max31865"),
}