|
@@ -1,8 +1,8 @@
|
|
|
-from flask import Blueprint, jsonify
|
|
|
|
|
|
|
+from flask import Blueprint, jsonify, request
|
|
|
from hardware.ha_devices_module import (
|
|
from hardware.ha_devices_module import (
|
|
|
turn_on_entrance_lights, turn_off_entrance_lights,
|
|
turn_on_entrance_lights, turn_off_entrance_lights,
|
|
|
turn_on_exhibition_spotlight, turn_off_exhibition_spotlight,
|
|
turn_on_exhibition_spotlight, turn_off_exhibition_spotlight,
|
|
|
- turn_on_exhibition_ceiling_light, turn_off_exhibition_ceiling_light,
|
|
|
|
|
|
|
+ turn_on_exhibition_ceiling_lights, turn_off_exhibition_ceiling_lights, set_exhibition_ceiling_light_level,
|
|
|
turn_on_exhibition_desktop_switch, turn_off_exhibition_desktop_switch,
|
|
turn_on_exhibition_desktop_switch, turn_off_exhibition_desktop_switch,
|
|
|
turn_on_exhibition_3d_fan, turn_off_exhibition_3d_fan,
|
|
turn_on_exhibition_3d_fan, turn_off_exhibition_3d_fan,
|
|
|
turn_on_exhibition_stand_light_strip, turn_off_exhibition_stand_light_strip,
|
|
turn_on_exhibition_stand_light_strip, turn_off_exhibition_stand_light_strip,
|
|
@@ -106,14 +106,14 @@ def turn_off_exhibition_spotlight_api():
|
|
|
"message": f"关闭一楼大门玄关射灯失败: {str(e)}"
|
|
"message": f"关闭一楼大门玄关射灯失败: {str(e)}"
|
|
|
}), 500
|
|
}), 500
|
|
|
|
|
|
|
|
-@ha_bp.route('/api/ha/exhibition_ceiling_light/turn_on', methods=['POST'])
|
|
|
|
|
|
|
+@ha_bp.route('/api/ha/exhibition_ceiling_lights/turn_on', methods=['POST'])
|
|
|
@login_required
|
|
@login_required
|
|
|
-def turn_on_exhibition_ceiling_light_api():
|
|
|
|
|
|
|
+def turn_on_exhibition_ceiling_lights_api():
|
|
|
"""打开一楼展厅顶灯"""
|
|
"""打开一楼展厅顶灯"""
|
|
|
try:
|
|
try:
|
|
|
def task():
|
|
def task():
|
|
|
try:
|
|
try:
|
|
|
- turn_on_exhibition_ceiling_light()
|
|
|
|
|
|
|
+ turn_on_exhibition_ceiling_lights()
|
|
|
except Exception as e:
|
|
except Exception as e:
|
|
|
logger.error(f"异步打开一楼展厅顶灯异常: {str(e)}")
|
|
logger.error(f"异步打开一楼展厅顶灯异常: {str(e)}")
|
|
|
|
|
|
|
@@ -129,14 +129,14 @@ def turn_on_exhibition_ceiling_light_api():
|
|
|
"message": f"打开一楼展厅顶灯失败: {str(e)}"
|
|
"message": f"打开一楼展厅顶灯失败: {str(e)}"
|
|
|
}), 500
|
|
}), 500
|
|
|
|
|
|
|
|
-@ha_bp.route('/api/ha/exhibition_ceiling_light/turn_off', methods=['POST'])
|
|
|
|
|
|
|
+@ha_bp.route('/api/ha/exhibition_ceiling_lights/turn_off', methods=['POST'])
|
|
|
@login_required
|
|
@login_required
|
|
|
-def turn_off_exhibition_ceiling_light_api():
|
|
|
|
|
|
|
+def turn_off_exhibition_ceiling_lights_api():
|
|
|
"""关闭一楼展厅顶灯"""
|
|
"""关闭一楼展厅顶灯"""
|
|
|
try:
|
|
try:
|
|
|
def task():
|
|
def task():
|
|
|
try:
|
|
try:
|
|
|
- turn_off_exhibition_ceiling_light()
|
|
|
|
|
|
|
+ turn_off_exhibition_ceiling_lights()
|
|
|
except Exception as e:
|
|
except Exception as e:
|
|
|
logger.error(f"异步关闭一楼展厅顶灯异常: {str(e)}")
|
|
logger.error(f"异步关闭一楼展厅顶灯异常: {str(e)}")
|
|
|
|
|
|
|
@@ -152,6 +152,35 @@ def turn_off_exhibition_ceiling_light_api():
|
|
|
"message": f"关闭一楼展厅顶灯失败: {str(e)}"
|
|
"message": f"关闭一楼展厅顶灯失败: {str(e)}"
|
|
|
}), 500
|
|
}), 500
|
|
|
|
|
|
|
|
|
|
+@ha_bp.route('/api/ha/exhibition_ceiling_lights/set_level', methods=['POST'])
|
|
|
|
|
+@login_required
|
|
|
|
|
+def set_exhibition_ceiling_light_level_api():
|
|
|
|
|
+ """设置一楼展厅顶灯等级 (0-3)"""
|
|
|
|
|
+ try:
|
|
|
|
|
+ data = request.get_json()
|
|
|
|
|
+ if not data or 'level' not in data:
|
|
|
|
|
+ return jsonify({"success": False, "message": "缺少参数 level"}), 400
|
|
|
|
|
+
|
|
|
|
|
+ level = data['level']
|
|
|
|
|
+
|
|
|
|
|
+ def task():
|
|
|
|
|
+ try:
|
|
|
|
|
+ set_exhibition_ceiling_light_level(level)
|
|
|
|
|
+ except Exception as e:
|
|
|
|
|
+ logger.error(f"异步设置一楼展厅顶灯等级异常: {str(e)}")
|
|
|
|
|
+
|
|
|
|
|
+ threading.Thread(target=task).start()
|
|
|
|
|
+ return jsonify({
|
|
|
|
|
+ "success": True,
|
|
|
|
|
+ "message": f"已发送设置一楼展厅顶灯等级指令 ({level}) - 异步执行"
|
|
|
|
|
+ })
|
|
|
|
|
+ except Exception as e:
|
|
|
|
|
+ logger.error(f"设置一楼展厅顶灯等级异常: {str(e)}")
|
|
|
|
|
+ return jsonify({
|
|
|
|
|
+ "success": False,
|
|
|
|
|
+ "message": f"设置一楼展厅顶灯等级失败: {str(e)}"
|
|
|
|
|
+ }), 500
|
|
|
|
|
+
|
|
|
@ha_bp.route('/api/ha/exhibition_desktop_switch/turn_on', methods=['POST'])
|
|
@ha_bp.route('/api/ha/exhibition_desktop_switch/turn_on', methods=['POST'])
|
|
|
@login_required
|
|
@login_required
|
|
|
def turn_on_exhibition_desktop_switch_api():
|
|
def turn_on_exhibition_desktop_switch_api():
|