Prechádzať zdrojové kódy

联动摄像头定时任务

locky 1 rok pred
rodič
commit
ddbb63b0d7

+ 8 - 0
Ansjer/Config/gatewaySensorConfig.py

@@ -14,6 +14,7 @@ GET_SCENE_TOPIC = 'loocam/gateway_sensor/get_scene/{}'
 SUB_DEVICE_TOPIC = 'loocam/gateway_sensor/sub_device/{}'
 VOICE_AUDITION_TOPIC = 'loocam/gateway_sensor/voice_audition/{}'
 SMART_SOCKET_TOPIC = 'loocam/smart-socket/{}'
+ANSJER_GENERIC_TOPIC = 'ansjer/generic/{}'
 
 # 智能场景事件
 SCENE_EVENT_CREATE = 1
@@ -88,4 +89,11 @@ EVENT_TYPE = {
     # 插座电源
     'socket_power_on': 2010,
     'socket_power_off': 2011,
+    # 摄像头
+    'detection_reminder_on': 1002,
+    'detection_reminder_off': 1003,
+    'snapshot': 1004,
+    'record_video': 1005,
+    'human_tracking_on': 1006,
+    'human_tracking_off': 1007,
 }

+ 22 - 5
Controller/CeleryTasks/tasks.py

@@ -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: