From 09cfeb04eea936630fa3c66a6baf9b212efcef8e Mon Sep 17 00:00:00 2001 From: Jiao Haoyang <108573524+XuSenfeng@users.noreply.github.com> Date: Tue, 18 Mar 2025 23:40:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E5=8F=91=E6=9D=BF=E7=9A=84=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E6=9B=B4=E6=96=B0=E9=9C=80=E8=A6=81=E5=9C=A8=E5=BC=80?= =?UTF-8?q?=E5=8F=91=E6=9D=BF=E9=83=A8=E5=88=86=E5=88=B7=E6=96=B0=E4=BB=A5?= =?UTF-8?q?=E5=90=8E=E5=8F=91=E9=80=81=E7=9A=84=E8=AF=B7=E6=B1=82=E9=87=8C?= =?UTF-8?q?=E9=9D=A2=E6=9B=B4=E6=96=B0,=20=E4=B8=8D=E5=BA=94=E8=AF=A5?= =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E6=9C=8D=E5=8A=A1=E5=99=A8=E8=87=AA=E5=B7=B1?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/xiaozhi-server/core/handle/iotHandle.py | 31 -------------------- 1 file changed, 31 deletions(-) diff --git a/main/xiaozhi-server/core/handle/iotHandle.py b/main/xiaozhi-server/core/handle/iotHandle.py index 7de2ef579..2c87249ac 100644 --- a/main/xiaozhi-server/core/handle/iotHandle.py +++ b/main/xiaozhi-server/core/handle/iotHandle.py @@ -90,8 +90,6 @@ def create_iot_query_function(device_name, prop_name, prop_info): logger.bind(tag=TAG).info( f"查询函数接收到的响应参数: success='{response_success}', failure='{response_failure}'") - value = await get_iot_status(conn, device_name, prop_name) - # 查询成功,生成结果 if value is not None: # 使用大模型提供的成功响应,并替换其中的占位符 @@ -114,35 +112,6 @@ def create_iot_query_function(device_name, prop_name, prop_info): return wrap_async_function(iot_query_function) -async def update_state_by_method(conn, device_name, method_name, params): - """根据方法和参数自动更新设备状态""" - try: - # 规则1: 方法名为TurnOn,设置power为True - if method_name == "TurnOn": - await set_iot_status(conn, device_name, "power", True) - - # 规则2: 方法名为TurnOff,设置power为False - elif method_name == "TurnOff": - await set_iot_status(conn, device_name, "power", False) - - # 规则3: Set开头的方法,尝试更新对应参数 - elif method_name.startswith("Set"): - # 从参数中找到可能的状态值 - for param_name, param_value in params.items(): - # 尝试更新对应名称的属性 - await set_iot_status(conn, device_name, param_name, param_value) - - # 其他方法,尝试直接从参数更新状态 - else: - for param_name, param_value in params.items(): - # 检查设备是否有此属性 - status = await get_iot_status(conn, device_name, param_name) - if status is not None: # 属性存在 - await set_iot_status(conn, device_name, param_name, param_value) - except Exception as e: - logger.bind(tag=TAG).warning(f"自动更新状态失败: {e}") - - class IotDescriptor: """ A class to represent an IoT descriptor.