Esempio n. 1
0
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,
    }
Esempio n. 2
0
    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())
Esempio n. 3
0
 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())
     
Esempio n. 4
0
 def _call(self, *args, **kw):
     problem = core.clocate(self._problem)
     if problem.exists():
         return 0
     return super(DisableByProblem, self)._call(*args, **kw)
Esempio n. 5
0
def trigger(name):
    controller = core.clocate(name)
    controller()
Esempio n. 6
0
 def _call(self, *args, **kw):
     problem = core.clocate(self._problem)
     if problem.exists():
         return 0
     return super(DisableByProblem, self)._call(*args, **kw)
Esempio n. 7
0
def set(name, value):
    sensor = core.clocate(name)
    sensor.value(value)
Esempio n. 8
0
def update(name):
    sensor = core.clocate(name)
    sensor.update()
    return get(name)
Esempio n. 9
0
def trigger(name):
    controller = core.clocate(name)
    controller()