from caspia.gateway.services import GatewayService
from caspia.meadow.services import LightSensorBase
[docs]class LightSensor(GatewayService, LightSensorBase):
def __new__(cls, config, network, storage):
if cls != LightSensor:
return super().__new__(cls, config, network, storage)
elif 'analog' in config:
from .analog import AnalogLightSensor as cls
elif 'apds9300' in config:
from .apds9300 import APDS9300LightSensor as cls
elif 'tsl258x' in config:
from .tsl258x import TSL258XLightSensor as cls
else:
raise RuntimeError('invalid light sensor config')
return cls(config=config, network=network, storage=storage)