|
@@ -14,7 +14,7 @@ from django.views import View
|
|
|
|
|
|
from Ansjer.Config.gatewaySensorConfig import SMART_SCENE_TOPIC, SENSOR_TYPE, EVENT_TYPE, SCENE_EVENT_CREATE, \
|
|
|
SCENE_EVENT_EDIT, SCENE_EVENT_DELETE, SCENE_STATUS_ON, SCENE_STATUS_OFF, SCENE_EVENT_EDIT_STATUS, \
|
|
|
- VOICE_AUDITION_TOPIC, DEVICE_TYPE, SMART_SCENE_TASK
|
|
|
+ VOICE_AUDITION_TOPIC, DEVICE_TYPE, SMART_SCENE_TASK, LINKAGE_DEVICE_TYPE_LIST
|
|
|
from Model.models import FamilyRoomDevice, GatewaySubDevice, FamilyRoom, SmartScene, EffectiveTime, Device_Info, \
|
|
|
SceneLog
|
|
|
from Object.CeleryBeatObject import CeleryBeatObj
|
|
@@ -127,8 +127,8 @@ class SmartSceneView(View):
|
|
|
res = cls.get_sub_device_room_name(sub_device_qs, gateway_data)
|
|
|
else:
|
|
|
res = [gateway_data]
|
|
|
- # 添加插座和开关数据
|
|
|
- res = cls.append_plug_and_switch_data(res, user_id)
|
|
|
+ # 添加联动设备数据
|
|
|
+ res = cls.append_linkage_device_data(res, user_id)
|
|
|
return response.json(0, res)
|
|
|
except Exception as e:
|
|
|
return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
@@ -186,14 +186,14 @@ class SmartSceneView(View):
|
|
|
return res
|
|
|
|
|
|
@staticmethod
|
|
|
- def append_plug_and_switch_data(res, user_id):
|
|
|
+ def append_linkage_device_data(res, user_id):
|
|
|
"""
|
|
|
- 添加插座和开关数据
|
|
|
+ 添加联动设备数据
|
|
|
@param res: 网关等设备数据
|
|
|
@param user_id: 用户id
|
|
|
@return: res
|
|
|
"""
|
|
|
- device_info_qs = Device_Info.objects.filter(userID_id=user_id, Type__in=[DEVICE_TYPE['socket']]).\
|
|
|
+ device_info_qs = Device_Info.objects.filter(userID_id=user_id, Type__in=LINKAGE_DEVICE_TYPE_LIST).\
|
|
|
values('id', 'NickName', 'Type', 'serial_number')
|
|
|
if device_info_qs.exists():
|
|
|
for device_info in device_info_qs:
|
|
@@ -1125,9 +1125,9 @@ class SmartSceneView(View):
|
|
|
is_last_task = True
|
|
|
|
|
|
sensor_type = int(task['device_type'])
|
|
|
- # 处理插座数据
|
|
|
- # 不用添加到设备的任务列表,添加到mqtt任务列表
|
|
|
- if sensor_type == DEVICE_TYPE['socket']:
|
|
|
+ # 处理联动设备数据
|
|
|
+ # 不用添加到设备的任务列表,添加到场景数据任务列表
|
|
|
+ if sensor_type in LINKAGE_DEVICE_TYPE_LIST:
|
|
|
serial_number = task['serial_number']
|
|
|
event_type = int(task['event_type'])
|
|
|
delay_time = task['delay_time']
|