def get(name): sensor = core.clocate(name) model = ctx.session.get(SensorModel, name) return { 'error_rate': model.error_rate if model is not None else 0, 'name': name, 'interval': sensor.interval, 'time': model.time if model is not None else datetime(1970, 1, 1), 'value': json.loads(model.value) if model is not None else None, }
def test(self): # set up class ThermometerDevice(AbstractDevice): @Sensor def room(self): return 25 # test comp = core.clocate('thermometer.room') self.assertEqual('thermometer.room', comp.full_name())
def _call(self, *args, **kw): problem = core.clocate(self._problem) if problem.exists(): return 0 return super(DisableByProblem, self)._call(*args, **kw)
def trigger(name): controller = core.clocate(name) controller()
def set(name, value): sensor = core.clocate(name) sensor.value(value)
def update(name): sensor = core.clocate(name) sensor.update() return get(name)