123456789101112131415161718192021 |
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- """
- demeter service
- name:record_sensor.py 处理传感器数据
- author:rabin
- key:sensor/type/gateway/device
- """
- import time
- import json
- from demeter.core import *
- class Record_sensor(object):
- def handle(self, record, config, value):
- self.record = record
- model = Demeter.model('device_type')
- model.key = config['type']
- device_type = model.select(type='fetchone')
- if device_type:
- name = device_type['name'] + '#' + str(config['child'])
- self.record.save(config, value, name, device_type)
|