2021.4:献给高级用户 ❤️

愚人节顺利活下来了吗?我向你保证,这次四月发布可不是玩笑!

这次发布是献给更高级用户的一份礼物,因为里面装满了许多进阶功能与增强项,有经验的用户一定会很喜欢。准备好开始调试你的自动化了吗?没错,就是现在……

如果你还没有那么“高级”,也别担心,我相信这里面同样有值得你期待的内容。

哦,对了,你听说 ESPHome 加入 Home Assistant 大家庭的消息了吗?如果还没有,强烈建议你去看看那篇宣布消息的博客文章

祝你享受这次发布!

../Frenck

数据库升级,请耐心等待

这次发布包含数据库迁移,也就是说,你的历史记录存储格式会发生变化。升级后会自动执行这项迁移,但它需要一点时间。具体耗时取决于你保存了多少历史数据,以及你的系统速度有多快。

升级到这个版本时,请耐心等待。

自动化调试

等等,为什么那盏灯没有打开?为什么恒温器没有调整?为什么这个自动化没有工作?到底发生了什么?!这房子闹鬼了吗?!

听起来很熟悉吧?我相信大家都遇到过这种时刻。那么,准备好了吗?我们现在可以调试自动化了!

Screenshot showing the 自动化 trace of a previously ran 自动化 Screenshot showing the 自动化 trace of a previously ran 自动化.

上面的截图展示了一次自动化的历史运行记录。自动化会以交互式图表的形式呈现, 其中会高亮显示自动化实际走过的路径。图中的每个节点都可以点击,以查看该步骤中自动化发生了什么。 它会完整追踪一次自动化的执行过程。

如果某个自动化没有按预期运行,这个功能就能帮助你调试并理解它为什么会这样执行。

这个超级高级、又极其实用的功能,离不开 @emontnemery 为其打造的后端支持。 精美的图形展示由 @thomasloven 完成,而全部前端工作则由 @balloob@bramkragten 负责。 大家干得太漂亮了,感谢你们!

此外,也特别感谢所有参与测试这个功能的(Beta)测试者,以及那些提供追踪样本、帮助我们修复 Bug 的朋友!

对这个功能有疑问?想看看它实际运行的样子?记得稍后锁定 2021.4 发布派对直播!

Home Assistant 分析

先别被这个标题吓到!

今天我们带来的是:Home Assistant Analytics。它采用自愿加入方式、注重隐私、公开透明,而且完全开源。这正是我们希望这个项目该有的样子。

@ludeeus 为这个新集成做了出色的工作。是否启用它,完全由你自己决定; 但我们可以保证,它从设计上就充分考虑了隐私。如果你怀疑?尽管去审查它! 所有内容都是开源的!

觉得这样还不够开放?我们还把结果公开出来,任何人都可以查看:

Screenshot of the Home Assistant Analytics website Screenshot of the Home Assistant Analytics website.

也许你想亲自看看公开结果:

https://analytics.home-assistant.io

那我们为什么要做这件事?因为它能帮助项目和所有贡献者了解很多信息,比如:哪些集成最常被使用。 这会极大帮助我们改进项目优先级安排,也能帮助我们说服厂商与 Home Assistant 合作,加入本地控制和更重视隐私的功能。

“可是 updater 以前不是已经做这件事了吗?”是的,不过 updater 实际上一直都有问题。 所以虽然我们曾经拿到过一些数据,但几乎没法真正使用(事实上可以说完全没法用)。 与其继续修它,我们现在有了一个更好的解决方案,也更符合项目目标。updater 仍然存在, 但它现在只负责一件事:提示是否有可用更新。

如果你愿意帮助这个项目,请启用 Home Assistant Analytics。我们会非常感激!

You can find the 设置 in the general 配置 options, or click the My Home Assistant button below to go directly to it. (Only visible to owner users)

Screenshot of the Home Assistant Analytics options Screenshot of the Home Assistant Analytics options, you control the amount of data you share.

想了解它的工作原理以及会共享哪些数据, 请查看我们的文档

Thanks for sharing already! ❤️

警告 for undefined variables in Templates

This feature is really cool. While technically a small improvement, it is a change that can impact you (as in "breaking"), but also, will greatly help you!

So imaging this little template: ``

Previously, if my_variable would not exist in the template or system as a variable, Home Assistant would just ignore it and skip over it.

While this can be convenient, it can become problematic when it was misspelled or referring to a variable that doesn't exist at all. For example, if you would have mistyped it: ``, you would never know something is wrong, unless you spotted it.

从今天开始,Home Assistant 会通过日志中的警告把这件事明确告诉你!

Screenshot of undefined variable warning log Screenshot of undefined variable warning log.

This helps to find templates that behave unexpectedly because the variable you thought was there, isn't. It is quite possible you get a bunch of warnings after upgrading to this release. Fixing those warnings, really helps to improve your setup.

So, what if a variable isn't always there, but I still want to use it? Well, you can give it a default, for example: . Or even a default value (10 in this example): .

Please note that these are just warnings for now. We plan to replace the warning with an error as of Home Assistant 2021.10 (in October).

筛选自动化、脚本与场景

Categorizing automations, is definitely one of the most requested things in our history. This became clear again during last year's month of what the heck and various issues/discussions/feature requests.

Suggestions for labels, folders, and many more have been created. However, we already have some great categorizing features in Home Assistant itself:

设备, Areas & 实体.

Screenshot of filtering automations by the living room area Screenshot of filtering automations by living room area.

从今天开始,你可以按区域、设备或实体来筛选自动化、脚本和场景。对于自动化和脚本,它甚至还能更进一步:自动找出那些会影响当前筛选区域、设备或实体的项目。

So, you can now look at the automations affecting your living room area (even if those automations itself are not in the living room area) and also filter the 自动化 list with just the ones that touch your thermostat.

Z-Wave JS update

So before we talk about The nice new things in Z-Wave JS, there are breaking changes in this release for the Z-Wave JS 集成 that could affect your existing automations. Be sure to read the backward-incompatible changes section for more info.

好了,现在来说点更有趣的!你现在可以直接在 Home Assistant 中配置每一个 Z-Wave 设备。当你在前端查看某个设备时,可以在设备页面上看到 CONFIGURE DEVICE 按钮。通过它,你就能管理并调整该设备(节点)专属的配置参数。

Screenshot of configuring a Z-Wave 设备 from within Home Assistant Screenshot of configuring a Z-Wave 设备 from within Home Assistant.

Furthermore two new, advanced, 服务 are introduced:

  • , a 服务 that is capable of setting a value on a Z-Wave 设备 directly, bypassing Home Assistant.
  • , a 服务 that will allow you to set 配置 parameters in bulk.

基于触发器的模板传感器

这次发布为一项相当高级、但也非常实用的新功能带来了初步支持:基于触发器及其携带数据进行更新的模板传感器。

Whenever the trigger fires, the template 传感器 will re-render and it will have access to the trigger data in the templates. This feature is a great way to create data based on webhook data, or have 传感器 be updated based on a time schedule.

See, for example, these two template 传感器 that update based on a single webhook trigger using data pushed into the webhook:

# Example configuration entry
template:
  - trigger:
      - platform: webhook
        webhook_id: my-super-secret-webhook-id
    sensor:
      - name: "Webhook Temperature"
        state: ""
      - name: "Webhook Humidity"
        state: ""

You can test this trigger 实体 with the following CURL command:

curl --header "Content-Type: application/json" \
  --request POST \
  --data '{"temperature": 5, "humidity": 34}' \
  http://homeassistant.local:8123/api/webhook/my-super-secret-webhook-id

It is not just webhooks! Any trigger that you can use in automations, can be used to update these types of template 传感器.

For this release, it only works for 传感器; other platforms are not supported yet.

Please note: that these new template 传感器 are configured under the template: key in the 配置 and is using a new 配置 format and keys. For more information, see the documentation.

脚本字段的 UI 选择器

你现在可以在脚本字段参数中使用 UI 选择器了。这把蓝图拥有的同类 UI 能力带到了脚本中,让你能够创建更高级的脚本,并在 UI 中轻松复用,甚至可以直接在 UI 自动化中使用。

Screenshot of scripts using selects in its fields Screenshot of scripts using selects in its fields.

For more details on these new field 配置 options, see the scripts documentation

其他值得注意的变化

这次发布还有更多值得一看的内容;下面是一些其他值得注意的变化:

  • The Supervisor is now also in the 集成 仪表盘, and provides 实体 for all kinds of things! These 实体 are disabled by default, so head over to the 集成 and see if there anything in there you could use. Thanks @raman325!
  • The develo Home Control (@Shutgun), Apple TV (@bdraco), August (@bdraco) and MQTT (@RadekHvizdos) 集成 can now suggest areas.
  • You can now configure additional Google Cast 设备 by IP address via the 集成 options. This is helpful in case of mDNS issues. Thanks @emontnemery!
  • @joshmcrty added support for selecting the number formatting you like on your profile! Awesome work!

Screenshot of selecting the number format you prefer in your profile Screenshot of selecting the number format you prefer.

  • @marvin-w added support for unique IDs to KNX 实体. So, as a KNX user you can now tweak your 实体 in the frontend and group them into areas!
  • HomeKit now supports CO/CO2 设备 classes, thanks to @iMicknl!
  • @robertdelpeut added monthly and yearly totals to the DSMR 传感器, thanks!
  • Hyperion users can now hide certain effects from the UI using 集成 options. Thanks, @dermotduffy!
  • Got that one message in your logs that you don't care about? @jshufro added support for filtering log messages using regular expression!
  • The Plex 集成 now provides library count 传感器! These are disabled by default by can be enabled if you like that. Thanks, @jjlawren.
  • The Quickbar had an update from @donkawechico! So press those C & E keys on you keyboard to see those beautiful new labels.

新集成

我们欢迎以下新集成加入这次发布:

新平台

以下集成新增了平台支持:

现已支持通过 UI 设置的集成

以下集成现已可通过 Home Assistant UI 进行设置:

Release 2021.4.1 - April 8

Release 2021.4.2 - April 9

Release 2021.4.3 - April 10

Release 2021.4.4 - April 13

Release 2021.4.5 - April 16

Release 2021.4.6 - April 19

If you need help...

如果你需要帮助,欢迎前往我们非常活跃的 论坛,或加入我们的 Discord 聊天

如果这次发布带来了问题,请到我们的 问题追踪器 提交反馈,并确保完整填写 issue 模板中的所有字段。

Backward-incompatible changes

Below is a listing of the breaking change for this release, per subject or 集成. Click on one of those to read more about the breaking change for that specific item.

Custom 集成 now require a 版本 key in their manifest file, this also means that all custom 集成 now require a manifest file.

If you are using a legacy custom 集成 like custom_components/awesome.py this now needs to move to custom_components/awesome/__init__.py so you can add custom_components/awesome/manifest.json to it.

For more information about 集成, manifests have a look here: https://developers.home-assistant.io/docs/creating_integration_manifest

For now, this will create a warning on startup. But this will be blocked from loading if it's missing a version in the manifest starting with Home Assistant 2021.6.

If you see these warnings, please report the issue with the author of that custom 集成.

(@ludeeus - [#45919])

The Xiaomi Miio Fan, 传感器 & Light platforms can now be configured via the UI.

If you currently have them configured using YAML 配置, they will be automatically imported into the UI on upgrade. After upgrading, you can safely remove the YAML 配置 for these 设备.

(@starkillerOG - #46866 #46964 #47161) (xiaomi_miio docs)

The config_file YAML option for KNX is deprecated, please remove it from your YAML 配置 if you have it configured.

Float types are no longer valid for 传感器 / expose 传感器 type because the trailing zeros caused troubles when splitting to two integers.

(@farmio - #46874 #48005) (knx docs)

The LIFX Legacy platform is deprecated and will be removed in Home Assistant Core 2021.6.0. Use the LIFX 集成 instead.

(@frenck - #47235) (lifx_legacy docs)

At this moment, we are unsure if this is a breaking change or not, so we list it, just to be sure.

We are now explicitly only supporting secrets inside your Home Assistant Core and Lovelace 配置 files (and anything included from there). Secrets are no longer supported in other loaded YAML files.

This change should not affect regular users of Home Assistant, however, we have been made aware that some custom 集成 may cause problems. If you are a user of Dwains theme, the HomeKit Infused theme or lovelace_gen, please make sure to update those or check with the upstream project.

(@balloob - #47034)

The HomeKit auto_start 配置 option has been deprecated. It dates from the "old"-days to prevent 实体 not being available yet when HomeKit started. However, nowadays, Home Assistant ensures all 实体 are available on startup instantly.

Therefore, this option is no longer needed. If you still have it in your 配置 (and have automations for it to start HomeKit); those can be safely removed as well.

(@frenck - #47470) (homekit docs)

The Hive 集成 can now be configured via the UI and configuring it via YAML is now deprecated. If you have an existing YAML 配置, it will be automatically imported on upgrade. After the upgrade, the YAML 配置 can be safely removed.

(@KJonline - #47300) (hive docs)

Wake on LAN component now assumes a dummy state if a host is not provided. Before, the state was only based on the host config parameter, which is listed as optional.

With this change the host config is still optional, but if it is not defined, the state of the switch is simply the last action that was taken. If you're relying on a Wake on LAN 实体 in an 自动化 or script, please make sure that your assumptions about state still hold.

(@ntilley905 - #47719) (wake_on_lan docs)

The Verisure 集成 largely rewritten and is now configured via the Home Assistant user interface.

Your existing YAML 配置 will be automatically imported when upgrading Home Assistant Core. After the upgrade completes, you can safely remove the existing Verisure YAML 配置.

If after upgrade your Verisure alarm system doesn't appear, please check your integrations 仪表盘. In rare cases (with accounts that have access to multiple Verisure alarm systems), it might be needed to select the specific Verisure alarm system to migrate.

This also means the YAML 配置 for the Verisure 集成 is now deprecated and will be removed in Home Assistant Core 2021.6.0.

The 服务 provided by the Verisure 集成 have changed to match the standard way of how Home Assistant handles 服务. The following 服务 are affected by this change:

Previously these 服务 required a device_serial parameter, they have now changed to accept a regular Home Assistant 实体, 设备 or area as a target. For example:

- service: verisure.enable_autolock
  target:
     entity_id: lock.my_verisure_lock

If you used any of these 服务 in your automations or scripts, please make sure you update them after updating to Home Assistant Core 2021.4.0.

(@frenck - #47880 #47905) (verisure docs)

Before this change, all 传感器 in an unknown state when the Prometheus exporter starts (i.e.: when Home Assistant starts) were being setup and metrics were exported with a default value of 0. Now, they will not be exported anymore (unless they become available again) - they can be found by searching for metrics where entity_available is 0 (will reveal both 实体 that are in unknown or unavailable state).

You should update any automations, scripts or 3rd party data consumers that depend on the old prometheus export with default value 0.

(@inetAnt - #47840) (prometheus docs)

August has fully transitioned to 配置 via UI. YAML 配置 is no longer supported. Existing YAML 配置 has already been imported automatically in the previous releases and can now safely be removed from your 配置 files.

(@bdraco - #47615) (august docs)

The Workday 集成 used to operate on the timezone configured on the system, instead of the timezone configured in Home Assistant. This can become problematic, for example, if your system runs on UTC, but you are 11 hours ahead of that.

This behavior has been correct and the workday 传感器 now rely on the timezone configured in Home Assistant. You might need to adjust to this, if you have automations, scripts or templates that previously manually corrected this.

(@schiermi - #47927) (workday docs)

The datetime returned in the last_recording_start_time state attribute of the uvc camera 实体 was changed from local time to be UTC time. All times in state attributes must be UTC time. You should update any automations or scripts that depends on this state attribute.

(@sycx2 - #41438) (uvc docs)

Zwave JS climate 设备 that report their temperature in Fahrenheit will now report in tenth precision instead of whole precision, when the 设备 supports it.

Previously, when those 设备 reported a temperature of, for example, 67.6F it would be rounded and reported in whole precision as 68F. Those 设备 will now report the temperature with tenth precision, thus 67.6F.

This means that if you currently have 自动化 that depends on the temperature reported by these 设备 you may have to adjust their functionality to work properly with how the temperature is now being reported.

(@chilicheech - #48133) (zwave_js docs)

The event names for Z-Wave JS value notification (central scene) events will now be called zwave_js_value_notification and notification (e.g., locking or unlocking a lock) events will now be called zwave_js_notification.

For notification events, the properties that Z-Wave JS provides have changed, and we have changed the HA event property names to reflect that. The parameter that used to be called label (The human-readable label for the notification event) is now called event_label as there is now a new label property which is the human-readable label for the notification type.

In addition, we now support notification events for two command classes, Entry Control and Notification, so the command class is reflected in the event data. You can learn more about the different command class notifications and what each parameter means for the different notifications here:

https://zwave-js.github.io/node-zwave-js/#/api/node?id=quotnotificationquot

(@raman325 - #48094) (zwave_js docs)

Previously, during template rendering, undefined variables are replaced with an empty string. As an example the template `` will render as the empty string. This is error prone as it means misspelled or non existent variables are silently accepted by the template engine.

Starting this release, there will be a warning message in the log when a variable is undefined, but it is still rendered as the empty string. So, besides the warning, right now, nothing changes.

Starting with Home Assistant 2021.10, undefined variables will be treated as an error and template rendering will fail.

To allow rendering of templates where it is expected that a variably may not be defined without logging a warning or failing to render, use the default filter: ``.

(@emontnemery - #48140)

Zeroconf will now only listen on the default interface by default.

If you need to broadcast mDNS responses to all interfaces or retain the previous behavior, set default_interface to false.

With multiple interfaces, mDNS traffic processing happened numerous times since the duplicate packets appeared on each interface. This behavior was not desirable for most cases which necessitated a change in the default.

The Home Assistant Operating System has multiple interfaces and was affected.

(@bdraco - #48302) (zeroconf docs)

The YAML 配置 for the Google Cast 集成 has been deprecated and will be fully removed in Home Assistant Core 2021.6.0.

If you have existing YAML 配置 for the Google Cast 集成, please remove it from your 配置.

(@emontnemery - #47269) (cast docs)

Vacuum attributes clean start, clean stop and camera attribute generated_at are now in a timestamp format.

New format is "2021-03-20T10:35:47Z". This allow 自动化 to use their value based on as_timestamp().

If you relies on these attributes in your 自动化 or script, you might need to adjust them to match this change.

(@chemelli74 - #48150) (neato docs)

The fan entity model has been changed. This impacts the way the MQTT Fan supports speeds and the following 配置 options are deprecated and will be removed in Home Assistant Core 2021.7.0:

  • speed_command_topic
  • speed_state_topic
  • speed_value_template
  • speeds
  • payload_off_speed
  • payload_low_speed
  • payload_medium_speed
  • payload_high_speed

Additionally,preset_modes and percentage are added to replace the legacy model supporting only three speeds low, medium and high. Therefore, command templates for 状态, oscillation, preset_mode and percentage are introduced.

(@jbouwh - #47944 #48413) (mqtt docs)

Block detectable I/O in the event loop

We added a warning when this happens last April and gave developers a year to fix the instability. We now prevent the instability by raising RuntimeError when code attempts to do known I/O in the event loop instead of the executor.

We now provide a suggestion on how to fix the code that is causing the issue.

(@bdraco - #48387)

You can now use the new style 配置 when configuring the modbus 集成. The existing 配置 style is kept, allowing you to change gradually.

Remark the existing 配置 style will be removed in a couple of releases.

Example of an existing 配置:

modbus:
  - name: "hub1"
    type: tcp
    host: IP_ADDRESS
    port: 502

sensor:
  platform: modbus
  registers:
    - name: "Sensor1"
      hub: "hub1"
      unit_of_measurement: "°C"
      slave: 1
      register: 100

Same 配置 in new style:

modbus:
  - name: "hub1"
    type: tcp
    host: IP_ADDRESS
    port: 502
    sensors:
      - name: "Sensor1"
        slave: 1
        address: 100

(@janiversen - #46591) (modbus docs)

The reporting and include_used_components 配置 options have now been deprecated, the updater 集成 will no longer report any analytics.

The analytics has moved to its own 集成. See the analytics integration for more details on how to configure it.

(@ludeeus - #48518) (updater docs)

The SolarEdge 配置 via YAML has been deprecated and will be removed in a future release of Home Assistant. The 集成 is using a 配置 via the UI for two years now.

Existing YAML configurations are automatically imported into the UI, and can be safely removed from your YAML 配置.

(@frenck - #48533) (solaredge docs)

MQTT JSON light now supports color_mode which should be used together with supported_color_modes to signal the light's features.

Feature flags color_temp, hs, rgb, white_value, xy are all deprecated and support will be removed in 2021.10.

(@emontnemery - #47993) (mqtt docs)

When restarting Home Assistant, the previous ping 传感器 state is now restored and then updated in the background to allow startup to proceed without the risk of timing out.

When the user has many ping 传感器, the ping 集成 could timeout starting up because each ping has to happen in the executor.

(@bdraco - #43869) (ping docs)

设备 representing Plex Web media_player 设备 are now removed. Any automations, scenes, or scripts based on the 设备 will need to be changed to use the media_player 实体.

(@jjlawren - #48369) (plex docs)

Farewell to the following

The following 集成 are no longer available as of this release:

  • Griddy has been removed, Ercot shut down Griddy after the massive power mess in Texas in mid February. (@bdraco - #47218)

All changes