|
@@ -111,14 +111,15 @@ class SmartSceneView(View):
|
|
|
|
|
|
if device_type != SENSOR_TYPE['smart_button']: # 非智能按钮只返回网关
|
|
|
res = [cls.get_gateway_data(device_id)]
|
|
|
- else:
|
|
|
+ else: # 智能按钮返回网关,门磁和人体传感器(如果存在)
|
|
|
gateway_data = cls.get_gateway_data(device_id)
|
|
|
sub_device_qs = GatewaySubDevice.objects.filter(
|
|
|
Q(device_id=device_id) & Q(device_type=SENSOR_TYPE['door_magnet']) | Q(
|
|
|
device_type=SENSOR_TYPE['body_sensor'])).values('id', 'nickname', 'status', 'device_type')
|
|
|
- if not sub_device_qs.exists():
|
|
|
- return response.json(173)
|
|
|
- res = cls.get_sub_device_room_name(sub_device_qs, gateway_data)
|
|
|
+ if sub_device_qs.exists():
|
|
|
+ res = cls.get_sub_device_room_name(sub_device_qs, gateway_data)
|
|
|
+ else:
|
|
|
+ res = [gateway_data]
|
|
|
|
|
|
return response.json(0, res)
|
|
|
except Exception as e:
|