title: '2021.9.0:更多能源功能、USB 发现与模板 ❤️' description: '<a href=''/home-assistant/integrations/版本/2021.9''<img src=''/home-assistant/images/blog/2021-09/social.png'' style=''border: 0;box-shadow: none;''</a。' 带来更多长期统计、USB 发现,以及更高级的模板功能

2021.9.0:更多能源功能、USB 发现与模板 ❤️

上一个发布中,我们推出了家庭能源管理功能,而我们收到的反馈与回应也让我们非常开心 ❤️! 在这个版本中,我们加入了许多大家期待已久的功能,让它变得更加实用,同时也有更多集成开始支持它 ⚡️。

我个人也非常喜欢上个版本带来的长期统计和统计卡片,而这一次我更高兴的是,我们终于可以把它们用在更多传感器上了。

祝你享受这次又一次精彩的发布!别忘了稍后收看 YouTube 上的 2021.9 发布派对(欧洲中部时间晚上 9 点),了解这次发布的更多内容!

家庭能源管理更新

在上一个发布中,我们把全新的家庭能源管理功能带到了 Home Assistant,很高兴看到你喜欢它!

我们也看到不少人在 FacebookTwitter 等社交平台上分享自己的能源仪表板,这真的太棒了。也欢迎你晒出自己的仪表板截图和你的故事!

在这次发布中,这个故事继续向前。以下就是我们这次为你准备的内容:

按时间范围查看能耗

能源仪表板的第一版一次只能显示一天的数据。 这当然很好!但如果你想看看这一周、这个月,甚至这一整年的表现呢?

现在可以了!你现在可以在仪表板右上角选择想查看的分组周期:天、周、月或年。

Screenshot of the new Energy 仪表盘 period selection 新版能源仪表板中的时间范围选择。

箭头按钮可以让你在这些周期之间前后切换。比如当你按“月”查看时,箭头按钮就会带你整个月整个月地向前或向后浏览。

追踪燃气使用量

在一些国家,住宅会接入燃气。燃气可用于烧热水、烹饪,以及为房屋供暖。如果你的家中接了燃气,我们有个好消息告诉你!

也许你已经从上一张截图里发现了:从这个版本开始,我们加入了对燃气使用量监控的支持。

Screenshot of the new Energy 仪表盘 monitoring gas usage 新版能源仪表板中的燃气使用监控。

在某些国家,燃气表有标准化方式可在本地读取燃气用量,或通过电表提供这些信息。比如在荷兰、比利时和卢森堡,你可以使用 SlimmeLezer 来获取燃气使用数据。

支持家庭电池

安装太阳能板是为家庭发电的好方法。 但问题来了:那些当下用不掉的太阳能发电,要存到哪里呢?

对很多人来说,答案就是大容量家庭电池,用来把电储存起来,以便在阳光无法提供电力的时候使用,比如夜晚。

很多人都提出了这个需求,因此我们现在已在 Home Assistant 的能源管理中加入了家庭电池支持。

Animation of a home battery as part of the energy distribution 家庭电池纳入能源流向分配的动画演示。

更多集成加入支持

当我们推出家庭能源管理这样的大功能时,我们知道你一定想立刻上手体验。虽然我们在首发时已经准备并更新了很多集成,但仍然还有不少集成需要继续补上支持。

结果就是,我们收到了大量请求,希望几乎所有还没支持的集成都能尽快加入…… :) 而这些请求中,有很多已经在这次发布中实现了。

例如,Kostal Plenticore Solar InverterPVOutputFroniusSolaX PowerGrowattSolar-LogYouLessEmoncmsModbus 等许多集成都已经加入了对这些能源功能的支持。

如果你是自定义集成开发者,也想加入支持,请务必看看我们的开发者博客,了解最新的变更。

所有传感器都能使用长期统计

在上一个发布中,我们为传感器引入了长期统计,同时还带来了一张很漂亮的 Lovelace 卡片。不过在上个版本中,这项功能只限于温度、湿度、功率和能耗相关的传感器。

而从这个版本开始,长期统计功能已经向所有传感器开放!

Screenshot of a statistics graph showing the luminosity in the garden versus the front of my house 展示花园与房屋前方照度对比的统计图截图。

只要集成声明其传感器支持长期统计,这项功能就能生效。幸运的是,已经有很多集成完成了这项支持。

USB 发现

感谢 @bdraco,Home Assistant 现在可以发现 USB 设备,以及能与该设备配合使用的集成。这让你在 Home Assistant 中设置 Z-Wave 或 Zigbee 之类的功能变得轻松多了!

例如,如果你把新的 Nortek HubZ USB 棒插到运行 Home Assistant 的机器上,系统就会自动发现它并通知你。

Screenshot of a discovered USB 设备 compatible with Z-Wave JS 发现可与 Z-Wave JS 配合使用的 USB 设备截图。

现在你只需要点一下“配置”按钮,就能完成 Z-Wave JS 集成的设置!非常顺手!

目前,USB 发现支持已经加入 Z-Wave JSZHA 两个集成。

Z-Wave JS 更新

如果你有 Z-Wave 警笛或门铃设备,你大概知道,过去等待 Home Assistant 为 Sound Switch CC(命令类)加入实体支持有多让人抓狂。原因很简单:上游 Z-Wave JS 项目发展得实在太快了,速度往往比 Home Assistant 跟进的速度还快。

有时候也可能是 Home Assistant 无法,或暂时不太可能,直接支持你关心的那个特定命令类。但无论如何,这都不该阻止你为这些设备编写自动化!

因此,在这次发布中,我们引入了新的 zwave_js.value_updated 自动化触发器类型,它可以让你基于 Z-Wave JS 支持的任意命令类值来触发自动化!

如果你想在 UI 中使用这种触发器类型,需要通过设备自动化来操作;如果你是用 YAML 编写自动化,则可以直接使用这个触发器

而 Z-Wave JS 集成的更新还不止这些,我们还有更多内容要分享!

  • 受够了孩子去拨那个本来已经全自动化的开关?现在你可以使用 Protection Command Class 的新 select 实体来禁用本地操作。
  • 不想每次启动警笛时都重新指定音调和音量?现在你可以通过 number 实体设置默认音量,通过 select 实体设置默认音调。
  • 我们让 zwave_js.* 服务变得更灵活了:现在它们支持把区域 ID 和 group 实体作为输入!
  • 我们还把基础 CC 值从 sensor 实体改成了可直接控制的 number 实体。

新的模板实体:Number 和 Select

没错!模板集成现在又多了两个你可以使用的新平台!

感谢 @raman325,你现在可以自己创建模板 selectnumber 实体了!这为构建更高级的用户界面打开了很大的空间 :)

例子胜过千言万语,下面给你两个例子,它们都基于一条 WLED 灯带。你可以把 WLED 灯带中的某些功能抽出来,变成独立实体。

# 示例 number 实体:表示 WLED 灯带的效果速度
# 把 0 到 255 的刻度转换成 0 到 100%。
template:
  number:
    - name: "Example number: WLED effect speed"
      state: ""
      min: 0
      max: 100
      step: ""
      set_value:
        service: wled.effect
        target:
          entity_id: light.wled
        data:
          speed: ""
# 示例 select 实体:从灯光中提取效果列表。
# 当你切换选项时,灯光效果也会跟着改变。
template:
  select:
    - name: "Example select: WLED effect"
      state: ""
      options: ""
      select_option:
        service: light.turn_on
        target:
          entity_id: light.wled
        data:
          effect: ""

哦!而且它们也可以和新的触发器模板一起使用!更多可用选项,请查看文档

新的区域模板函数

我们新增了两个模板函数,让你在 YAML 中处理区域时更轻松一些。

  • area_id("value") 会返回给定值对应的区域 ID。value 可以是设备 ID、实体 ID,或区域名称。这个函数也可以作为过滤器使用。

    example: ""
    example: ""
    example: ""
  • area_name("value") 会返回给定值对应的区域名称。value 可以是设备 ID、实体 ID,或区域 ID。这个函数同样也可以作为过滤器使用。

    service: notify.frenck
    data:
      title: "Motion detected!"
      message: >-
        Motion has been detected in the  area.

感谢 @raman325

其他值得注意的变化

这次发布当然还有更多内容,下面是其中一些值得关注的变化:

  • @balloob 为能源配置界面加入了更多校验,并补充了更多警告/错误提示;@ludeeus 则为这类消息设计了漂亮的新样式。
  • 如果 Home Assistant 离线,错过了生成能源/长期统计的时机?现在不会了!Home Assistant 会在启动时自动补算,感谢 @emontnemery
  • 感谢 @bdraco,摄像头图像现在可以按你当前查看设备/屏幕的分辨率进行缩放;此外,它们只会在可见时更新。这让摄像头在各种带宽环境下都更实用了。
  • The Shelly 集成 now supports transitions for 灯光! Thanks @bieniu!
  • Yeelight now supports local push (instead of polling), awesome @starkillerOG!
  • @emontnemery upgraded DSMR to support Swedish smart energy meters! Nice!
  • For Yamaha MusicCast, @micha91 has unlocked the Media Browser features!
  • The Rainforest Eagle will now provide pricing data if that is available, thanks @balloob!
  • @giannello added the ability to ask your Google Home where your 吸尘器 cleaner is :)
  • If you use the shopping list feature of Home Assistant, you can now remove all completed items at once using a 服务 call. Thanks, @GrumpyMeow!
  • @bdraco 为 HomeKit 加入了一项新的高级功能,允许把设备事件转发给 HomeKit,从而解锁触发 HomeKit 自动化或场景的能力。
  • 感谢 @ludeeus,现在当 UI 处于深色模式时,我们可以使用不同的品牌图片。
  • 如果你有 Sonos 音箱,现在可以通过服务调用来调节低音和高音,感谢 @Tigger2014
  • Utility Meter 的周期配置现在借助新的 cron 模式选项变得非常灵活,@dgomes 干得漂亮!
  • Bond 现在提供了新的服务,可用于开始/停止提高或降低灯光亮度。感谢 @bdraco

新集成

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

现在可在 UI 中配置的集成

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

发布 2021.9.1 - September 2

发布 2021.9.2 - September 3

发布 2021.9.3 - September 4

发布 2021.9.4 - September 6

发布 2021.9.5 - September 8

发布 2021.9.6 - September 11

发布 2021.9.7 - September 18

如果你需要帮助……

……欢迎随时使用我们非常活跃的 论坛,或者加入我们的 聊天频道

如果你遇到了这次发布引入的问题,请到我们的 issue tracker 提交反馈,并确保填写问题模板中的所有字段。

破坏性变更

下面按主题或集成列出了本次发布中的破坏性变更。点击对应项目即可阅读该条变更的更多说明。

The previously deprecated YAML 配置 of the 1-Wire 集成 has been removed.

1-Wire is now configured via the UI, any existing YAML 配置 has been imported in previous releases and can now be safely removed from your YAML 配置 files.

(@epenet - #53728) (onewire docs)

The 属性 of the 开关 provided by AVM FRITZ!Box Tools have been adjusted to match the naming rules and schema of Home Assistant.

If you relied on one of these 属性 in your 自动化 or 脚本, you'll need to adopt to this change.

(@AaronDavidSchneider - #54842) (fritz docs)

The unit of measurement of gas 传感器 for DSMR has changed from m3 to .

(@bramkragten - #54110) (dsmr docs)

The previously deprecated YAML 配置 of the Epson 集成 has been removed.

Epson is now configured via the UI, any existing YAML 配置 has been imported in previous releases and can now be safely removed from your YAML 配置 files.

(@pszafer - #55045) (epson docs)

The previously deprecated YAML 配置 of the Growatt 集成 has been removed.

Growatt is now configured via the UI, any existing YAML 配置 has been imported in previous releases and can now be safely removed from your YAML 配置 files.

(@frenck - #54325) (growatt_server docs)

The underlying HomeKit protocol 版本 has changed from 版本 1.0 to 版本 1.1.

摄像头 with motion 传感器 and some other accessories may need to be reset using the homekit.reset_accessory 服务 or unpaired and paired again.

If after unpairing with your iOS the QR code does not show, the pairings can manually be removed with the homekit.unpair 服务 using the 开发者工具.

(@bdraco - #53780) (homekit docs)

A future 发布 (currently scheduled for 2021.12.0) will remove the (deprecated) air quality platform from the HomeKit Controller 集成.

Starting from this 发布 the air quality values have been broken out as their own 传感器, making them easier to incorporate in your 仪表盘 widgets, graphs and 自动化.

If you relied on an air quality 实体 (provided by the HomeKit Controller 集成) in your 自动化 or 脚本, you'll need to adopt to this change.

(@Jc2k - #54673) (homekit_controller docs)

The legacy code, which imported hosts from a JSON file have been removed. If you relied on that, please follow the instructions to 设置 the hosts (can be detected automatically).

To avoid this, 升级 to 2021.8.x first (which will automatically import the hosts from the JSON file) and then 升级 to latest 发布.

(@janiversen - #54452) (tradfri docs)

If (and only if) you currently attempt to make use of the (previously ambiguous) Lutron button events in an 自动化, then you will need to 开关 to the new, unambiguous name. That said, since the current events are ambiguous they are not very useful.

(@nickovs - #53666) (lutron docs)

MQTT 风扇 no longer supports the legacy speeds (OFF, LOW, MEDIUM, HIGH). With 发布 2021.3 the support for legacy speeds was announced to be removed after a quarter (2021.7).

With removing the legacy speeds support, 集成 that rely on MQTT 风扇 platform that still use legacy speeds would break because they can not be 设置 if deprecated 属性 are used. This includes the MQTT auto discovery.

To prevent that these 集成 will fail to 设置, the deprecated 属性 listed here are still allowed in the config:

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

(@jbouwh - #54768) (MQTT docs)

The last_reset_topic 配置 variable for MQTT 传感器 is deprecated, last_reset_value_template is still supported but will use the state_topic if no last_reset_topic is configured.

In Home Assistant 核心 2021.10, it will no longer be possible to 配置 a last_reset_topic.

(@emontnemery - #55463) (MQTT docs)

MySensors 灯光 no longer supports deprecated white_value, use rgbw_color instead.

(@emontnemery - #52068) (mysensors docs)

The Nanoleaf 集成 migrated to 配置 via the UI. Configuring Nanoleaf via YAML 配置 has been deprecated and will be removed in a future Home Assistant 发布.

Your existing YAML 配置 is automatically imported on 升级 to this 发布; and thus can be safely removed from your YAML 配置 after upgrading.

If you have configured Nanoleaf with the discovery 集成: You can remove discovery: from your YAML 配置 if you only used it for Nanoleaf. The .nanoleaf.conf file in your 配置 folder is no longer used, you can delete it after upgrading.

(@milanmeu - #52199) (nanoleaf docs)

The Nmap Tracker 集成 migrated to 配置 via the UI. Configuring Nmap Tracker via YAML 配置 has been deprecated and will be removed in a future Home Assistant 发布.

Your existing YAML 配置 is automatically imported on 升级 to this 发布; and thus can be safely removed from your YAML 配置 after upgrading.

To disable creation of new 实体, use the the system option to disable new 实体 for the config entry, and manually enable 实体 as needed.

(@bdraco - #54715) (nmap_tracker docs)

These 属性 have been removed and replaced with full 传感器 for both gas and electricity:

  • start_time
  • end_time

If you relied on one of these 属性 in your 自动化 or 脚本, you'll need to adopt to this change.

(@timmo001 - #54952) (ovo_energy docs)

The Rainforest Eagle-200 集成 migrated to 配置 via the UI. Configuring Rainforest Eagle-200 via YAML 配置 has been deprecated and will be removed in a future Home Assistant 发布.

Your existing YAML 配置 is automatically imported on 升级 to this 发布; and thus can be safely removed from your YAML 配置 after upgrading.

(@balloob - #54846) (rainforest_eagle docs)

SimpliSafe 门锁 no longer have a jammed 属性; instead, when jammed, they will show a jammed 状态.

If you are currently using the jammed 属性 in your 自动化 or 脚本, you'll need to adapt them to this change.

(@bachya - #54006) (simplisafe docs)

The power and energy 属性 from 开关 实体 have been removed and replaced by 传感器.

If you relied on these 属性 in your 自动化, 脚本 or Lovelace 仪表盘, you'll need to 更新 your 配置 to match this change.

(@bsmappee - #54329) (smappee docs)

The Watt-peak unit of measurement has changed to W.

(@Ernst79 - #55110) (solarlog docs)

The usage of "snapshot" is deprecated, from now "备份" is used instead.

  • The 服务 snapshot_full is now named backup_full, the 服务 snapshot_full will be removed in Home Assistant 2021.11.
  • The 服务 snapshot_partial is now named backup_partial, the 服务 snapshot_partial will be removed in Home Assistant 2021.11.
  • Using snapshot in the data for the restore_full and restore_partial 服务 is deprecated and will be removed in Home Assistant 2021.11, use slug instead.

Old examples:

service: hassio.snapshot_full
data:
  name: "Awesome full snapshot"
...
service: hassio.snapshot_partial
data:
  name: "Awesome partial snapshot"
  addons:
    - awesome_addon
...
service: hassio.restore_full
data:
  snapshot: sn2321
...
service: hassio.restore_partial
data:
  snapshot: sn2321
  addons:
    - awesome_addon

New examples:

service: hassio.backup_full
data:
  name: "Awesome full snapshot"
...
service: hassio.backup_partial
data:
  name: "Awesome partial snapshot"
  addons:
    - awesome_addon
...
service: hassio.restore_full
data:
  slug: sn2321
...
service: hassio.restore_partial
data:
  slug: sn2321
  addons:
    - awesome_addon

(@ludeeus - #53851) (hassio docs) (zwave_js docs)

The Tesla Powerwall 属性 for energy_exported_(in_kW) and energy_imported_(in_kW) have been converted to their own energy 传感器.

If you relied on those 属性 in your 自动化 or 脚本, you'll need to adapt them to this change.

(@bdraco - #54018) (powerwall docs)

The unit of measurement of gas and water 传感器 for Toon has changed from m3 to .

(@bramkragten - #54110) (toon docs)

The previously deprecated YAML 配置 of the UpCloud 集成 has been removed.

UpCloud is now configured via the UI, any existing YAML 配置 has been imported in previous releases and can now be safely removed from your YAML 配置 files.

(@scop - #54516) (upcloud docs)

The Uptime Robot 集成 migrated to 配置 via the UI. Configuring Uptime Robot via YAML 配置 has been deprecated and will be removed in a future Home Assistant 发布.

Your existing YAML 配置 is automatically imported on 升级 to this 发布; and thus can be safely removed from your YAML 配置 after upgrading.

(@ludeeus - #53938) (uptimerobot docs)

The Wink 集成 has been deprecated and is pending removal in Home Assistant 2021.11.

Their developer portal, needed for obtaining an API token, has been taken offline and their customer support has confirmed no new token or client/secret can be obtained. This makes it impossible to use 此integrations.

(@frenck - #54496) (wink docs)

The following 风扇 实体 属性 temperature, humidity, aqi, purify volume, filter life remaining, filter hours used, co2, illuminance, motor speed and motor2 speed have been migrated to their own 传感器 实体.

If you relied on those 属性 in your 自动化 or 脚本, you'll need to adapt them to this change.

The filter_rfid_product_id and filter_rfid_tag 风扇 实体 属性 have been removed as they are of little use to keep around.

(@bieniu - #54564) (xiaomi_miio docs)


The 服务 fan_set_led_brightness is removed and the Led Brightness select 实体 has been 创建 instead.

If you relied on this 服务 in your 自动化 or 脚本, you'll need to adapt them to this change.

(@bieniu - #54702) (xiaomi_miio docs)


The previously (deprecated and old style) speeds, speed list and speed 服务 have been removed.

(@SmaginPV - #54182) (xiaomi_miio docs)


The 服务 fan_set_buzzer_on, fan_set_buzzer_off, fan_set_led_on, fan_set_led_off, fan_set_child_lock_on, fan_set_child_lock_off, fan_set_auto_detect_on, fan_set_auto_detect_off, fan_set_learn_mode_on and fan_set_learn_mode_off have been removed.

开关 实体 have been 创建 to replace those.

If you relied on one of these 服务 in your 自动化 or 脚本, you'll need to adapt them to this change.

(@bieniu - #54834) (xiaomi_miio docs)


The previously deprecated YAML 配置 of the Xiaomi Miio 集成 has been removed (with the exception of the remote platform).

Xiaomi Miio is now configured via the UI, any existing YAML 配置 has been imported in previous releases and can now be safely removed from your YAML 配置 files.

(@rytilahti - #54930) (xiaomi_miio docs)


The 服务 fan_set_favorite_level, fan_set_fan_level, and fan_set_volume have been removed and number 实体 have been 创建 instead.

If you relied on one of these 服务 in your 自动化 or 脚本, you'll need to adapt them to this change.

(@bieniu - #54977) (xiaomi_miio docs)

The Basic CC always comes with two values, currentValue and targetValue.

We currently only have a discovery schema for currentValue which creates a 传感器, making these Basic CC values noninteractive. As of this 发布 we will create a number platform 实体 for Basic CC values instead of 传感器.

(@raman325 - #54512) (zwave_js docs)


If you have 创建 an 自动化 with the zwave_js 设备 条件 Current value of a Z-Wave Value for the CONFIGURATION Command Class, your 自动化 will no longer work.

Instead, you should use the Config parameter 设备 条件 for the value you were trying to use for your 条件.

(@raman325 - #54962) (zwave_js docs)

This breaking change is only relevant to custom 集成 authors!

The function signature for async_camera_image and camera_image has changed to include a width and height.

    async def async_camera_image(
        self, width: int | None = None, height: int | None = None
    ) -> bytes | None:

The goal of the change is to reduce the overhead of sending large images that will only be displayed as small images as this can quickly consume hundred of megabytes of bandwidth / mobile data allocation. Scaling should be done on a best effort basis and is not a strict requirement as the existing behavior of falling back to scaling at the display layer is preserved.

  • 集成 should pass on the width and height if the underlying 摄像头 is capable of scaling the image.

  • 集成 may choose to ignore the height parameter in order to preserve aspect ratio

  • If the 集成 cannot scale the image and returns a jpeg image, it will automatically be scaled by the 摄像头 集成 when requested.

(@bdraco - #53835)

This breaking change is only relevant to custom 集成 authors!

Although not a breaking change from a user's perspective, this is a significant change from a developer's perspective.

Temperature conversions are moving from the Entity base class to the SensorEntity base class.

Additionally, we have two new properties, native_value (which replaces state) and native_unit_of_measurement which replaces unit_of_measurement.

Read all about it in the developer 博客:

https://开发者.home-assistant.io/博客/2021/08/12/sensor_temperature_conversion/

(@emontnemery - #48261) (abode docs) (传感器 docs)


Additionally, a new 传感器 状态 class has been introduced: total_increasing.

This changes the measurement 状态 class that was used in conjunction with the last_reset 属性. 更多信息 about his can be found in the developer 博客 about it:

https://开发者.home-assistant.io/博客/2021/08/16/state_class_total/

全部变更