type
status
date
slug
summary
tags
category
icon
password
URL
最近,升级HomeAssistant到2025.12版或之后的小伙伴,应该有主意到HA的公告吧:
2025.12 版本中旧版模板实体的弃用公告 / Deprecation of legacy template entities in 2025.12
摘要(TLDR): 旧版模板实体(包括:报警控制面板、二元传感器、遮阳帘、风扇、灯光、锁、传感器、开关、吸尘器、天气)将从 2025.12 版本起正式被弃用。这些旧版模板实体在 2026.6 版本之后将彻底失效,无法继续工作。我曾希望避免这次弃用,但显然由于未来的开发计划,这已无法避免。 TLDR: Legacy template entities (alarm_control_panel, binary_sensor, cover, fan, light, lock, sensor, switch, vacuum, weather) are being deprecated in 2025.12. Legacy template entities will no longer work after 2026.6. I wanted to avoid the deprecation, however it’s apparent that it’s not possible due to future plans.
就算没有注意到上面的公告,估计也注意到自己的HA启动后,一堆的修复提示吧,就像我下面这样的。

如果,只是一个或者两个Sensor要改的话,直接config文件修改。但是像我这样有几十个,或者有小伙伴有一百多个的话,改起来还是很麻烦的。

后来逛官方网站,发现一个插件(或者说集成),可以批量自动化处理,试了下。效果不错。分享给大家。
1. 安装Legacy Template Migration Helper
点击下面的链接,会打开HACS,下载并安装Legacy Template Migration Helper

Link to HACS: Repository – My Home Assistant
Open a repository inside the Home Assistant Community Store in Home Assistant.

2. 添加集成
打开HA,“设置”→“设备与服务”,右下角“添加集成”,搜索“Legacy Template Migtation Helper”,一路下一步就行。

3. 执行动作
“开发者工具”-“动作”,搜索并选择“template_migration.generate_yaml”,并点击“执行动作”

在您的配置目录(configuration)下将生成一个文件夹。该文件夹将被命名为
migrated_templates,其中包含多个文件。每个文件对应一个“域”(domain),并包含该域下的所有模板。4. 修改配置文件
在
configuration.yaml 文件中添加:template migrated: !include_dir_merge_list migrated_templates。注意: 请务必完全按照上述格式添加,即使你的配置文件中已经定义了顶级的
template: 域(domain)。因为它使用了 migrated 这个标签,所以它会与你可能已经定义的任何其他现有模板自动进行合并。5. 验证配置文件
通过以下路径验证 YAML 是否能正常加载:进入“开发者工具 (Developer Tools)” -> “YAML”标签页,点击“检查配置 (Check configuration)”按钮。

6. 移除旧模版的引用
根据‘修复’(Repairs)面板中的提示,删掉配置文件中所有对应的旧版模板代码。
比如我,我需要回到
configuration.yaml 或相关的 YAML 配置文件中,手动删掉那些已经被标记为“过时(Legacy)”的代码块(即那些以 platform: template 开头的部分)。
7. 重启HA
请务必注意:在重启 Home Assistant 之前,请确保“检查配置(Check configuration)”已顺利通过。确认无误后,再重启 Home Assistant。
然后,你就不会看到那些修复提示了。
- Author:AI Innovation
- URL:http://inno4ai.com/article/2f397a38-0bdb-80f7-8e57-c372de1c4811
- Copyright:All articles in this blog, except for special statements, adopt BY-NC-SA agreement. Please indicate the source!
Relate Posts












