|
@@ -14,7 +14,7 @@ django.setup()
|
|
|
|
|
|
# 其他导入在setup之后
|
|
|
import requests
|
|
|
-from Ansjer.Config.gatewaySensorConfig import DEVICE_TYPE, SMART_SOCKET_TOPIC, EVENT_TYPE
|
|
|
+from Ansjer.Config.gatewaySensorConfig import DEVICE_TYPE, SMART_SOCKET_TOPIC, EVENT_TYPE, ANSJER_GENERIC_TOPIC
|
|
|
from Service.CommonService import CommonService
|
|
|
import time
|
|
|
from Ansjer.config import LOGGER, CONFIG_INFO, DETECT_PUSH_DOMAINS
|
|
@@ -59,14 +59,31 @@ def loocam_smart_scene(device_type, event_type, serial_number, scene_id=0):
|
|
|
"""
|
|
|
LOGGER.info('loocam智能场景任务,device_type:{},event_type:{},serial_number:{},scene_id:{}'.
|
|
|
format(device_type, event_type, serial_number, scene_id))
|
|
|
+
|
|
|
+ msg = {}
|
|
|
+ # 插座
|
|
|
if device_type == DEVICE_TYPE['socket']:
|
|
|
topic_name = SMART_SOCKET_TOPIC.format(serial_number)
|
|
|
status = 1 if event_type == EVENT_TYPE['socket_power_on'] else 0
|
|
|
- msg = {
|
|
|
- 'type': 1,
|
|
|
- 'data': {'deviceSwitch': status}
|
|
|
+ msg['type'] = 1
|
|
|
+ msg['data'] = {
|
|
|
+ 'deviceSwitch': status
|
|
|
}
|
|
|
- CommonService.req_publish_mqtt_msg(serial_number, topic_name, msg)
|
|
|
+ # 摄像头
|
|
|
+ elif device_type == DEVICE_TYPE['C516']:
|
|
|
+ topic_name = ANSJER_GENERIC_TOPIC.format(serial_number)
|
|
|
+ if event_type == EVENT_TYPE['detection_reminder_on']:
|
|
|
+ msg['commandType'] = 'detection_reminder'
|
|
|
+ msg['enable'] = 1
|
|
|
+ elif event_type == EVENT_TYPE['detection_reminder_off']:
|
|
|
+ msg['commandType'] = 'detection_reminder'
|
|
|
+ msg['enable'] = 0
|
|
|
+ else:
|
|
|
+ return
|
|
|
+ else:
|
|
|
+ return
|
|
|
+
|
|
|
+ CommonService.req_publish_mqtt_msg(serial_number, topic_name, msg)
|
|
|
|
|
|
# 没有设备任务时,最后一个任务上报场景日志
|
|
|
if scene_id:
|