refactor: 重构服务层代码结构并优化性能

- 提取公共服务方法 _get_face_recognition、_check_result、_call_service
- 添加 HTTP Session 池化与 LRU 图片缓存
- 完善 create_person 错误处理,返回统一格式
- 卸载时正确关闭 client 连接释放资源
- 传感器适配 API 返回结构变化
- 全面更新 README 文档,补充服务说明与示例
This commit is contained in:
2026-05-02 00:18:57 +08:00
parent d081a51aa0
commit 14c2e56656
6 changed files with 654 additions and 564 deletions
+4 -1
View File
@@ -67,7 +67,10 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
if unload_ok:
await async_unload_services(hass)
hass.data[DOMAIN].pop(entry.entry_id)
entry_data = hass.data[DOMAIN].pop(entry.entry_id, None)
if entry_data and "client" in entry_data:
client = entry_data["client"]
await hass.async_add_executor_job(client.close)
return unload_ok