2023.4:自定义模板宏,以及更多全新的实体对话框!

Home Assistant 核心 2023.4 来了!🎉

春天(以及发布)已经到来!而这个复活节周末,我们也准备了一些很棒的新功能让你尽情体验!🐰

我很高兴看到这次发布又加入了更多全新的实体对话框。它们看起来很漂亮,而且在移动应用中的使用体验也格外出色。更棒的是,Tile 卡片还带来了新功能!不过……

天啊,我真的太喜欢这次发布中新加入的自定义 Jinja2 模板宏能力了,简直让人震撼!最棒的一点是,它们还非常容易分享。我已经等不及想看看大家会玩出什么新花样了!

复活节快乐!🐣 也祝你享受这次发布!

../Frenck

Don't forget to join our 发布 party live stream on YouTube 5 April 2023, at 12:00 PDT / 21:00 CEST!

报警、遮盖与风扇实体的新对话框

上一期发布 带来了灯光、开关和警笛的全新实体对话框;看起来 大家都非常喜欢!

所以,这次发布中 @piitaya 继续推进了这项工作, 将 @matthiasdebaat 的设计落地,把同样清爽整洁的新 UI 带到了报警控制面板、遮盖和风扇的实体对话框中!

遮盖

First up, 遮盖! For 遮盖, there are many variants, doors, windows, curtains, blinds, shutters, etc. Not just that, some can be controlled by how far they are open/closed, and others can only be opened and closed.

This is no problem for the new dialogs. They will adjust to the capabilities your 遮盖 has:

Screenshots showing the new 遮盖 实体 information dialogs.

The one on the left is interesting, as the first slider controls how far down the blinds are. Notice how it slides in from the top! The slider directly next to it controls the tilt. Nice!

风扇

Next up, the 风扇 实体. The UI experience shown in the dialog will automatically adjust to the capabilities of the 风扇 you are controlling, just like with 遮盖.

Screenshots showing the new 风扇 实体 information dialogs.

Depending on the number of speed steps your 风扇 has, the dialog will automatically adjust the UI. In case it has four speed steps or less, it will show the speed buttons as on the left screenshot. Otherwise, it will use the slider shown on the most right screenshot.

报警控制面板

Lastly, the 报警 control 面板 实体. They are a bit different compared to others as, more often, these require one to input a code to arm or disarm the 报警.

Screenrecording showing the new 报警 control 面板 实体 information dialogs work with the pin-input. This is how arming and disarming an 报警 now looks like.


When needed, the pin-pad will pop up! A nice finishing touch is the neat little animation is shown during the process of arming and disarming the 报警.

Tile 卡片的新功能

The Tile 卡片 has two new features: 风扇 speed & 报警 mode.

Both look and feel similar to the new 实体 dialogs from above, making the look and feel, nice and consistent. Take a look; aren't they beautiful?

Screenshots the new 风扇 speed feature for tile 卡片.

Like the new 风扇 实体 dialog, the 风扇 speed feature will show buttons if there are 4 speeds or less; in all other cases, it will use the slider. If the 风扇 can only be turned on/off, like the 风扇 in the middle in the above screenshot, the regular tile can be used.

The 报警 mode feature allows quickly setting your 报警 in a different 状态. The feature provides the option to select which modes are shown as buttons in the 卡片.

Screenshots the new 报警 mode feature for tile 卡片.

Just like with the new 实体 dialog, the pin pad will pop up once a code entry is needed and even the nice little animation is there. 🤩

模板宏

If you are an advanced Home Assistant user, you most likely will be familiar with Home Assistant's templating language: Jinja2. It allows you to do amazing powerful things in your templates. However, if you have lots of them, you often end up repeating similar logic everywhere!

@depoll to the rescue! He found a way to add the ability to centrally define your own Jinja2 macros and import and use them anywhere in Home Assistant! 🤯

To support this, Home Assistant now has a new custom_templates folder, where you can store your macros. For example, assume this file /config/custom_templates/tools.jinja:


Is the  on?
!

This macro answer_question will ask and answer a question based on a given 实体 ID. You can now import and use this macro anywhere in Home Assistant. For example:

Which will output:

Is the kitchen light on?
Yes!

An fantastic contribution! Thank you, @depoll!

Reusing templates 文档

更多新的模板功能

As if the reusability of your macros wasn't good enough already, there is much more templating goodness in this 发布!

Thanks, @depoll, @ehendrix23, @petro31, and @rokam, for these amazing additions down below! ❤️

Adjusted behavior of relative_time and today_at

@Petro31 adjust the behavior for template 实体 using the relative_time and today_at template functions to 更新 their 状态 once a minute. Nice!

New is_hidden_entity function

The brand new is_hidden_entity function was added by @depoll, which can tell if a given 实体 has been marked "hidden" or not. This function also works as a test. Cool!

This example returns a list of all 实体 in the kitchen area that are not hidden.

New areas function

Talking about areas, @rokam added an areas function, which returns a list of all areas you have!

A simplistic example:

Added break and continue for use in for loops

@depoll added support for break and continue in for loops, which allows short-circuiting those loops, allowing you to make them more efficient.


    
        
    
        
    
    

New has_value function

Lastly, @ehendrix23 added a requested template function from the Month of "What the Heck?!": has_value. The has_value function can also be used as test and can filter out 实体 currently in an unavailable or unknown 状态.

You could use this conditionally, like so:


  The train leaves at 

Or, maybe list all 实体 from the living room that currently have no 状态 value:

数据库可扩展性

As your smart home grows and you add more 设备, this means more data to keep track of. This 发布 includes significant advancements to the recorder database design to help Home Assistant scale.

This 版本 has a new database format that reduces the space needed to store history for your 设备. This change comes with a few benefits:

  • Smaller (deduplication), less disk usage
  • Reduced disk IO (SD-卡片 lifetime improvements)
  • Reduced CPU-usage 📉
  • Quicker startup 🏎️
  • Faster history graphs and logbook
  • Reduced latency in the entire system which means less waiting from the time you hit a button until an 动作 completes 🚀
  • Home Assistant now keeps history when renaming 实体 🤘

If you are accessing the database directly, check out the Data Science Portal and the SQL integrations for updated example queries.

It may take a while to complete background data migration, depending on the size of your stored data. To ensure Home Assistant keeps history when renaming an 实体, wait 24 hours after upgrading before renaming.

新的选择器能力

Selectors are user inputs for the user interface that drive things like Blueprints. A new selector for use in Blueprints has been added by @emontnemery and @piitaya: The constant selector.

The constant selector provides an optional input, which returns a fixed value (the constant) when enabled, otherwise doesn't provide any value at all.

Example use in a Blueprint:

example:
  name: Constant selector example
  selector:
    constant:
      label: Enabled
      value: true

Which results in the following:

A screenshot showing the new constant selector. When checked, the selector returns the set value.

Also improved are the 设备 and 实体 filters on the Area, 实体, 设备, and Target selectors. Previously, you could filter with a single set of 条件; now, you can pass in a list of filters.

If you are building Blueprints, this can be really helpful if a user should be able to select one of multiple different 设备.

An example, this selector allows you to select the battery 传感器 of either a Philips Hue RWL020 (US) or RWL021 (EU) remote in your Blueprint.

device:
  filter:
    - integration: deconz
      manufacturer: Philips
      model: RWL020
    - integration: deconz
      manufacturer: Philips
      model: RWL021
  entity:
    - domain: sensor
      device_class: battery

实体翻译

Over the past releases, we’ve been slowly extending translation support in more places in Home Assistant. This 发布 completes support for translating 实体!

This includes the 实体' names, their 属性, and translations of the 属性 values. These translations will be visible on your 仪表盘, dialogs, 自动化 editors, etc. Pretty much all places displaying them.

集成 have to explicitly add support for these. Quite a few 集成 have done so in this 发布, but we expect many to follow in the upcoming releases.

其他值得注意的变化

There are much more easter bunnies in this 发布; here are some of the other noteworthy changes this 发布:

  • @ArturoGuerra added support for 门锁 to Matter! Nice!
  • The new 灯光 实体 dialog (introduced last 发布) now better supports white mode. Thanks, @piitaya!
  • @emontnemery added energy storage and volume storage 设备 classes; these will allow differentiating between, for example, consumed energy versus stored energy in a battery.
  • @starkillerOG is rocking the Reolink 集成. It now provides button, 开关, siren, select, number, and 灯光 实体 for all kinds of things you Reolink 摄像头 and doorbells can do. Awesome!
  • The Universal Media Player now supports browsing media! Thanks, @Drafteed!
  • The Supervisor 集成 now provides 传感器 containing the Home Assistant 核心 and Supervisor's stats. Thanks, @ludeeus!
  • The Spotify 集成 now supports podcasts! Nice @BTMorton!
  • LIVISI Smart Home now supports 温控 设备, 开关 (PSSO, ISS, and ISS2), and window 传感器 (WDS). Thanks @StefanIacobLivisi & @planbnet!
  • ESPHome now supports pairing 蓝牙 设备. Nice work @bdraco & @jagheterfredrik!
  • @MarkGodwin extended the TP-Link Omada 集成 to support 更新 实体; awesome!
  • All sun.sun 实体 属性 are now also available as 传感器, much easier to use, thanks @gjohansson-ST!
  • 遮盖 with the door 设备 class, now appear as actual doors in HomeKit, nice @Dexwell!
  • @loongyh did something similar for Google Assistant. 遮盖 with the window 设备 class now show up as actual windows. Thanks!
  • The SQL 集成 now supports 设置 设备 and 状态 classes, thanks @gjohansson-ST!
  • @teharris1 added support for the new Insteon i3 设备, cool!

新集成

This 发布 has no new 集成, but does provide a couple of new virtual 集成. Virtual 集成 are stubs handled by other (existing) 集成 to help with findability. These are new:

现在可通过 UI 设置的集成

The following 集成 are now available via the Home Assistant UI:

发布 2023.4.1 - April 6

发布 2023.4.2 - April 8

发布 2023.4.3 - April 12

发布 2023.4.4 - April 13

发布 2023.4.5 - April 17

发布 2023.4.6 - April 21

需要帮助?加入社区!

Home Assistant has a great community of users who are all more than willing to help each other out. So, join us!

Our very active Discord chat server is an excellent place to be at, and don't forget to join our amazing forums.

Found a bug or issue? Please report it in our issue tracker, to get it fixed! Or, check our help page for guidance for more places you can go.

Are you more into email? Sign-up for our Building the Open Home Newsletter to get the latest news about features, things happening in our community and other news about building an Open Home; straight into your inbox.

不向后兼容的变更

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

Aladdin Connect 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 - #88694) (文档)

The 二元sensor providing available firmware updates has been deprecated since 2022.5 and is now removed. Use the new update 实体 instead.

(@mib1185 - #89940) (文档)

This change only affects Home Assistant instances running directly on MacOS (not inside a virtual machine).

Any 集成 or 设备 previously set up using a UUID 蓝牙 address will need to be deleted and recreated.

(@bdraco - #89926) (文档)

The calendar.create_event 服务 now enforces that start and end dates are exclusive. This has always been part of the specification but was not clearly documented and enforced.

(@allenporter - #89533) (文档)

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

DSMR Reader 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 - #89239) (文档)

AQI 传感器 状态 values are now in English, and the user interface will display their translation for the selected language. If you have been using this 传感器 in your 自动化 and 脚本, you'll need to adjust these for this change.

(@bieniu - #89044) (文档)


The name and station 传感器 状态 属性 have been removed because they are static data that do not describe the 状态 of the 实体.

The index 传感器 状态 属性 has been migrated to a separate 实体, for example, sensor.home_no2_index.

(@bieniu - #89389) (文档)

The behavior of passing parameters to 服务 calls targeting 通知 groups has changed.

Current behavior: data mappings configured in the 服务 override mappings configured in the 动作.

New behavior: data mappings configured in the 动作 override mappings configured in the 服务.

(@arychj - #90253) (文档)

In order to obtain an up-to-date list of compatible programs for your appliances, it will be necessary to reconfigure the 集成.

Please note that due to limitations on the Home Connect side, it is important to have your appliances Turned on during the reconfiguration process.

This 动作 is a one-time requirement.

(@stickpin - #88801) (文档)

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

IMAP 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.

(@jbouwh - #89981) (文档)

The conversion to MWh and the corresponding MWh-实体 have been removed.

To resolve the breaking change :

  • If you make use of any of sensor.heat_meter_heat_usage or sensor.heat_meter_heat_previous_year for 自动化, 脚本, etc., you can replace these with the GJ-实体 sensor.heat_meter_heat_usage_gj and sensor.heat_meter_heat_previous_year_gj.
  • If applicable, in the energy 仪表盘, replace sensor.heat_meter_heat_usage with sensor.heat_meter_heat_usage_gj. Note that the energy 仪表盘 will still convert to MWh or kWh, therefore resulting in the same values as before.

(@vpathuis - #89522) (文档)

Logbook will be unavailable until the database schema migration completes. Logbook 脚本 and 自动化 traces from previous runs of Home Assistant will be unavailable until background data migration is completed following the schema migration.

(@bdraco - #88942 #89465) (文档)


自动化 and 脚本 traces that include 状态 change events recorded with Home Assistant 2022.5.x or older will no longer display context information for these events in the logbook tab.

(@bdraco - #89945) (文档)

  • The MySensors notify platform has been removed. It's been deprecated since 2023.2.0. It's been replaced by a text 实体 platform.
  • You should 更新 any 自动化 or 脚本 that use the notify.mysensors* 服务 to instead use the text.set_value 服务 and the corresponding text 实体 as a target.
  • The MySensors IR switch 实体, corresponding to an S_IR child with V_SEND value, has been removed. This 实体 hasb been deprecated since 2023.2.0. It's been replaced by a remote 实体.
  • You should 更新 any 自动化 or 脚本 that use the mysensors.send_ir_code 服务 to instead use the remote.send_command 服务 and the corresponding remote 实体 as a target. Similar changes should be made for 动作 using the switch.turn_on and switch_turn_off 服务 targeting the removed IR switch 实体. Replace these with remote.turn_on and remote.turn_off 服务 and remote 实体 targets.

(@MartinHjelmare - #90402 #90403) (文档)

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

Moon 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 - #89161) (文档)

The tls_version 配置 parameter (deprecated June 2020) has been removed. All other MQTT broker 设置 have been moved to the UI before.

When the tls_version setting is still in your YAML 配置, MQTT will not start up.


The previously deprecated MQTT broker YAML 配置 has been removed.

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

(@jbouwh - #87987) (文档)

The option to define your own scan interval has been removed, data is now updated every 60 seconds.

(@mib1185 - #89396) (文档)

Your previously selected model has been reset to the new and cheaper GPT 3.5 model.

(@balloob - #90423) (文档)


The built-in areas variable is no longer overwritten and is now the same as areas in every template. The new default template is now:

This smart home is controlled by Home Assistant.

An overview of the areas and the devices in this smart home:

  
  
    
      

:
        
      
-  ()
    
  

Answer the user's questions about the world truthfully.

If the user wants to control a device, reject the request and suggest using the Home Assistant app.

(@balloob - #90481) (文档)

The open and close commands for the io:CyclicGarageOpenerIOComponent device Have been removed, see this issue for more details on this 设备.

To sum up, this 设备 is a garage door but cannot be exposed as such within Home Assistant. There is no 状态 returned and no clear open and close command.

Only one command is available: cycle. A button is a perfect fit for this use case and remove all confusion; this button 实体 has been added this 发布.

(@tetienne - #89043) (文档)

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

Pushbullet 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.

(@gjohansson-ST - #90285) (文档)

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

Radio Thermostat 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.

(@gjohansson-ST - #90284) (文档)

Oversized events with data larger than 32KiB are no longer recorded to avoid overloading the database and polluting the memory cache.

(@bdraco - #90747) (文档)

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

Scrape 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.

(@gjohansson-ST - #90272) (文档)

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

Season 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 - #89166) (文档)

Tasmota sensor no longer sets the force_update flag to True.

Tasmota binary_sensor no longer sets the force_update flag to True, except for binary_sensor mapped to a Tasmota 开关 with switchmode set to 13 or 14.

(@DerEnderKeks - #85943) (文档)

The relative_time and today_at template functions and filters are no longer supported in limited templates.

(@Petro31 - #86815)


Enumerating 状态 using templates are no longer sorted by entity_id by default, as it was computationally expensive.

To 恢复 the original behavior, a sort filter can be added to any existing template using the below example:

The behavior of the threshold 二元sensor has changed:

  • The threshold 二元sensor's 状态 is reset to unknown when the monitored 传感器's 状态 is unknown, unavailable, or not a valid float.
  • When the monitored 传感器's 状态 is first valid, or when it's valid after being unknown, unavailable, or not a valid float:
    • Initialize a threshold 传感器 with only a lower threshold to 状态 off, with the position 属性 set to above.
    • Initialize a threshold 传感器 with only a upperthreshold to 状态 off, with the position 属性 set to below.
    • Initialize a threshold 传感器 with only an upper and a lower threshold to 状态 on, with the position 属性 set to in_range.

(@emontnemery - #88978) (文档)

The end-date for garbage collection events on the calendar 实体, will now be one day later compared to the start date. This is because in calendaring, the end-date is exclusive.

(@bobvandevijver - #89028) (文档)

The previously deprecated YAML 配置 of the Volvo On Call 集成 has been removed.

Volvo On Call 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.

(@gjohansson-ST - #90288) (文档)

With this 发布, you will need to 更新 your zwave-js-server instance. You must use zwave-js-server 1.27.0 or greater (schema 27).

  • If you use the Z-Wave JS add-on, you need at least 版本 0.1.77.
  • If you use the Z-Wave JS UI add-on, you need at least 版本 1.8.1.
  • If you use the Z-Wave JS UI Docker 容器, you need at least 版本 8.11.1.
  • If you run your own Docker 容器 or some other 安装 method, you will need to 更新 your zwave-js-server instance to at least 1.27.0.

(@raman325 - #90212) (文档)

If you are a custom 集成 developer and want to learn about breaking changes and new features available for your 集成: Be sure to follow our developer 博客. The following are the most notable for this 发布:

Farewell to the following

The following 集成 are also no longer available as of this 发布:

  • Dark Sky has been removed. Apple acquired Dark Sky, and the API has now been shut down. (@gjohansson-ST - #90322)
  • Magicseaweed has been removed. Magicseedweed no longer provides API keys to users. Additionally, the 集成 is no longer in a functional 状态. (@gjohansson-ST - #90277)

All changes

Of course, there is a lot more in this 发布. You can find a list of all changes made here: Full changelog for Home Assistant 核心 2023.4