|
@@ -44,7 +44,7 @@ class GatewaySubDeviceView(View):
|
|
|
return self.records(request_dict, response)
|
|
|
elif operation == 'records-date': # 查询传感器记录日期
|
|
|
return self.records_date(request_dict, response)
|
|
|
- elif operation == 'home':
|
|
|
+ elif operation == 'home': # 查询传感器主页信息
|
|
|
return self.sensor_home_info(request_dict, response)
|
|
|
else:
|
|
|
return response.json(414)
|
|
@@ -371,14 +371,14 @@ class GatewaySubDeviceView(View):
|
|
|
return response.json(444, {'error param': 'gatewaySubId'})
|
|
|
|
|
|
try:
|
|
|
- sub_device_qs = GatewaySubDevice.objects.filter(id=sub_device_id).values('status', 'is_tampered').first()
|
|
|
- if not sub_device_qs:
|
|
|
+ sub_device_qs = GatewaySubDevice.objects.filter(id=sub_device_id).values('status', 'is_tampered')
|
|
|
+ if not sub_device_qs.exists():
|
|
|
return response.json(173)
|
|
|
- smart_scene_num = SmartScene.objects.filter(sub_device_id=sub_device_id).count()
|
|
|
+ scene_count = SmartScene.objects.filter(sub_device_id=sub_device_id).count()
|
|
|
res = {
|
|
|
- 'smart_scene_num': smart_scene_num,
|
|
|
- 'status': sub_device_qs['status'],
|
|
|
- 'is_tampered': sub_device_qs['is_tampered']
|
|
|
+ 'scene_count': scene_count,
|
|
|
+ 'status': sub_device_qs[0]['status'],
|
|
|
+ 'is_tampered': sub_device_qs[0]['is_tampered']
|
|
|
}
|
|
|
return response.json(0, res)
|
|
|
except Exception as e:
|