|
@@ -7,16 +7,14 @@
|
|
|
import json
|
|
|
import time
|
|
|
|
|
|
-import requests
|
|
|
from django.core.exceptions import ObjectDoesNotExist
|
|
|
from django.db import transaction
|
|
|
from django.db.models import F, Q, Count
|
|
|
from django.views import View
|
|
|
|
|
|
-from Ansjer.config import DETECT_PUSH_DOMAINS
|
|
|
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, SMART_SOCKET_TOPIC, DEVICE_TYPE, SMART_SCENE_TASK
|
|
|
+ VOICE_AUDITION_TOPIC, DEVICE_TYPE, SMART_SCENE_TASK
|
|
|
from Model.models import FamilyRoomDevice, GatewaySubDevice, FamilyRoom, SmartScene, EffectiveTime, Device_Info, \
|
|
|
SceneLog
|
|
|
from Object.CeleryBeatObject import CeleryBeatObj
|
|
@@ -1385,34 +1383,6 @@ class SmartSceneView(View):
|
|
|
# 删除最后一个逗号并返回结果
|
|
|
return weeks[:-1]
|
|
|
|
|
|
- @staticmethod
|
|
|
- def pub_mqtt(device_type, event_type, serial_number, scene_id=0):
|
|
|
- """
|
|
|
- 发布mqtt消息
|
|
|
- @param device_type: 设备类型
|
|
|
- @param event_type: 事件类型
|
|
|
- @param serial_number: 序列号
|
|
|
- @param scene_id: 场景id
|
|
|
- @return:
|
|
|
- """
|
|
|
- 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}
|
|
|
- }
|
|
|
- CommonService.req_publish_mqtt_msg(serial_number, topic_name, msg)
|
|
|
-
|
|
|
- # 没有设备任务时,最后一个任务上报场景日志
|
|
|
- if scene_id:
|
|
|
- data = {
|
|
|
- 'sceneId': scene_id,
|
|
|
- 'status': 1
|
|
|
- }
|
|
|
- url = DETECT_PUSH_DOMAINS + 'gatewayService/sceneLogPush'
|
|
|
- requests.post(url=url, data=data, timeout=8)
|
|
|
-
|
|
|
@staticmethod
|
|
|
def del_celery_task(scene_data_dict):
|
|
|
"""
|