支持ha2026.01版本

This commit is contained in:
xiaochao
2026-01-12 11:29:55 +08:00
parent b6fabe3d68
commit b82123637a
2 changed files with 12 additions and 4 deletions

View File

@@ -29,8 +29,13 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
async def async_delayed_setup(hass: HomeAssistant, entry: ConfigEntry, coordinator: FlynasCoordinator):
try:
# 不阻塞等待NAS上线直接尝试刷新数据
# 检查配置条目状态,只有在 SETUP_IN_PROGRESS 时才调用 async_config_entry_first_refresh
from homeassistant.config_entries import ConfigEntryState
if entry.state == ConfigEntryState.SETUP_IN_PROGRESS:
await coordinator.async_config_entry_first_refresh()
else:
# 如果配置条目已经加载,则直接刷新数据
await coordinator.async_refresh()
enable_docker = coordinator.config.get(CONF_ENABLE_DOCKER, False)
if enable_docker:
from .docker_manager import DockerManager
@@ -40,7 +45,10 @@ async def async_delayed_setup(hass: HomeAssistant, entry: ConfigEntry, coordinat
coordinator.docker_manager = None
_LOGGER.debug("未启用Docker容器监控")
ups_coordinator = UPSDataUpdateCoordinator(hass, coordinator.config, coordinator)
if entry.state == ConfigEntryState.SETUP_IN_PROGRESS:
await ups_coordinator.async_config_entry_first_refresh()
else:
await ups_coordinator.async_refresh()
hass.data[DOMAIN][entry.entry_id]["ups_coordinator"] = ups_coordinator
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
entry.async_on_unload(entry.add_update_listener(async_update_entry))

View File

@@ -1,7 +1,7 @@
{
"domain": "fn_nas",
"name": "飞牛NAS",
"version": "1.4.1",
"version": "1.4.2",
"documentation": "https://github.com/xiaochao99/fn_nas",
"dependencies": [],
"codeowners": ["@xiaochao99"],