mirror of
https://github.com/howelljiang/baidu-voice.git
synced 2026-07-27 17:43:56 +08:00
根据官网代码规范优化结构,精简代码。使用reconfigure模式支持重设参数。增加多实例支持。去掉debug信息。
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user