根据官网代码规范优化结构,精简代码。使用reconfigure模式支持重设参数。增加多实例支持。去掉debug信息。

This commit is contained in:
Howell Jiang
2025-04-18 15:42:59 +08:00
parent c8415edaeb
commit 2d3f8cd3b0
12 changed files with 129 additions and 200 deletions
+4 -5
View File
@@ -20,18 +20,17 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""设置百度语音配置项."""
# 存储配置数据
hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN] = entry.data.copy() # 保存所有配置数据
# 加载平台
hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN] = entry.data.copy()
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
return True
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""卸载百度语音配置项."""
# 卸载平台
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
if unload_ok: