rabin 7 years ago
parent
commit
2d66e1825f
1 changed files with 4 additions and 4 deletions
  1. 4 4
      service/record.py

+ 4 - 4
service/record.py

@@ -40,9 +40,6 @@ class Record(object):
 		if gateway:
 			#更新网关状态
 			self.gateway(config['parent'], gateway['farm_id'], gateway['id'])
-			if config['method'] == 'control' and (value == '0' or value == 0):
-				model.update(status=True,cdate='time')
-				return
 			model_type = Demeter.model('hardware_type')
 			model_type.key = config['method']
 			hard = model_type.select(type='fetchone')
@@ -51,8 +48,11 @@ class Record(object):
 			model.hardware_type = hard['id']
 			device = model.select(type='fetchone')
 			if device:
-				#update
 				model.id = device['id']
+				if config['method'] == 'control' and (value == '0' or value == 0):
+					model.update(status=True, cdate='time')
+					return
+				#update
 				id = device['id']
 				value = Demeter.exp(device['exp'], value)
 				model.update(value=value,status=True,cdate='time')