|
@@ -8,7 +8,7 @@
|
|
|
from demeter.core import *
|
|
|
from demeter.mqtt import *
|
|
|
class Device(object):
|
|
|
-
|
|
|
+ type_info = []
|
|
|
|
|
|
def upGatewayStatus(self, farm_id, gateway_id, hardware_id):
|
|
|
if hardware_id and gateway_id > 0:
|
|
@@ -62,6 +62,7 @@ class Device(object):
|
|
|
queue_model.device_id = info['id']
|
|
|
queue_model.status = 1
|
|
|
queue_model.value = switch
|
|
|
+ queue_model.inorder = info['inorder']
|
|
|
queue_model.insert()
|
|
|
return
|
|
|
|
|
@@ -148,8 +149,8 @@ class Device(object):
|
|
|
oper = ''
|
|
|
type_model = Demeter.model('device_type')
|
|
|
type_model.id = type_id
|
|
|
- type_info = type_model.select(type='fetchone')
|
|
|
- if type_info['unit'] == 'button':
|
|
|
+ self.type_info = type_model.select(type='fetchone')
|
|
|
+ if self.type_info['unit'] == 'button':
|
|
|
if switch == 1:
|
|
|
oper = '升起'
|
|
|
elif switch == 2:
|
|
@@ -175,7 +176,10 @@ class Device(object):
|
|
|
model.status = 1
|
|
|
model.device_id = info['id']
|
|
|
oper = self.msg(info['type_id'], v['value']) + msg
|
|
|
+
|
|
|
+ if self.type_info['unit'] == 'button':
|
|
|
+ sleep(15)
|
|
|
if state:
|
|
|
model.update(status=2, oper=oper, operdate=Demeter.time())
|
|
|
else:
|
|
|
- model.update(status=3, oper=oper, operdate=Demeter.time())
|
|
|
+ model.update(status=3, oper=oper, operdate=Demeter.time())
|