|
@@ -12,7 +12,8 @@ from django.db import transaction
|
|
|
from django.db.models import F, Q, Count
|
|
|
from django.views import View
|
|
|
|
|
|
-from Ansjer.Config.gatewaySensorConfig import SMART_SCENE_TOPIC, SENSOR_TYPE, EVENT_TYPE
|
|
|
+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
|
|
|
from Model.models import FamilyRoomDevice, GatewaySubDevice, FamilyRoom, SmartScene, EffectiveTime, Device_Info, \
|
|
|
SceneLog
|
|
|
from Object.ResponseObject import ResponseObject
|
|
@@ -222,7 +223,8 @@ class SmartSceneView(View):
|
|
|
'updated_time': now_time,
|
|
|
}
|
|
|
msg = {
|
|
|
- 'scene_status': 1
|
|
|
+ 'scene_event': SCENE_EVENT_CREATE,
|
|
|
+ 'scene_status': SCENE_STATUS_ON
|
|
|
}
|
|
|
# 处理设置时间
|
|
|
if is_all_day is not None:
|
|
@@ -313,7 +315,7 @@ class SmartSceneView(View):
|
|
|
return response.json(444, {'error param': 'invalid isAllDay'})
|
|
|
|
|
|
msg['time'] = time_dict
|
|
|
- msg['smart_scene_id'] = smart_scene_qs.id
|
|
|
+ msg['scene_id'] = smart_scene_qs.id
|
|
|
task_list = []
|
|
|
for task in tasks_list:
|
|
|
task_temp = {
|
|
@@ -466,8 +468,9 @@ class SmartSceneView(View):
|
|
|
return response.json(444, {'error param': 'smartSceneId and status'})
|
|
|
try:
|
|
|
smart_scene_id = int(smart_scene_id)
|
|
|
- scene_status = 1 if is_enable == 'True' else 0
|
|
|
+ scene_status = SCENE_STATUS_ON if is_enable == 'True' else SCENE_STATUS_OFF
|
|
|
msg = {
|
|
|
+ 'scene_event': SCENE_EVENT_EDIT,
|
|
|
'scene_id': smart_scene_id,
|
|
|
'scene_status': scene_status
|
|
|
}
|
|
@@ -737,7 +740,8 @@ class SmartSceneView(View):
|
|
|
for smart_scene_id in smart_scene_id_list:
|
|
|
# 通知设备删除场景id
|
|
|
msg = {
|
|
|
- 'smart_scene_delete': int(smart_scene_id)
|
|
|
+ 'scene_event': SCENE_EVENT_DELETE,
|
|
|
+ 'scene_id': int(smart_scene_id)
|
|
|
}
|
|
|
success = CommonService.req_publish_mqtt_msg(serial_number, topic_name, msg)
|
|
|
try:
|