2023.4: Custom template macros, and many more new entity dialogs!

Home Assistant Core 2023.4! 🎉

The spring (release) is here! And do we have some fine new features for you to play with this upcoming easter weekend! 🐰

I’m thrilled to see more of those new entity dialogs coming in this release. They look beautiful and work exceptionally well from the mobile app. There is even an added bonus of new Tile card features! But…

Oh boy, do I love the new ability to make your own Jinja2 template macros in this release. It is mind-blowing! The best thing about them, it makes them easily shareable as well! Can’t wait to see what you all come up with!

Happy Easter! 🐣 and enjoy the release!

../Frenck

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

New dialogs for alarm, cover, and fan entities

The previous release brought in new entity dialogs for lights, switches, and sirens; it seems many of you really liked it!

So, this release @piitaya kept on trucking, implementing the designs by @matthiasdebaat, bringing the same new clean and neat UI in entity dialogs for alarm control panels, covers, and fans!

Covers

First up, covers! For covers, 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 cover has:

Screenshots showing the new cover entity 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!

Fans

Next up, the fan entities. The UI experience shown in the dialog will automatically adjust to the capabilities of the fan you are controlling, just like with covers.

Screenshots showing the new fan entity information dialogs.

Depending on the number of speed steps your fan 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.

Alarm control panels

Lastly, the alarm control panel entities. They are a bit different compared to others as, more often, these require one to input a code to arm or disarm the alarm.

Screenrecording showing the new alarm control panel entity information dialogs work with the pin-input. This is how arming and disarming an alarm 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 alarm.

New features for the Tile card

The Tile card has two new features: Fan speed & Alarm mode.

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

Screenshots the new fan speed feature for tile cards.

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

The alarm mode feature allows quickly setting your alarm in a different state. The feature provides the option to select which modes are shown as buttons in the card.

Screenshots the new alarm mode feature for tile cards.

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

Macros for your templates

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:

{% macro answer_question(entity_id) %}

Is the {{ state_attr(entity_id, 'friendly_name') }} on?
{{ (states(entity_id) == 'on') | iif('Yes', 'No') }}!

{% endmacro %}

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

{% from 'tools.jinja' import answer_question %}
{{ answer_question('light.kitchen') }}

Which will output:

Is the kitchen light on?
Yes!

An fantastic contribution! Thank you, @depoll!

Reusing templates documentation

More new templating features

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

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 entities using the relative_time and today_at template functions to update their state 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 entity has been marked “hidden” or not. This function also works as a test. Cool!

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

{{ area_entities('kitchen') | reject('is_hidden_entity') | list }}

New areas function

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

A simplistic example:

{{ areas() }}

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.

{%- for value in range(10) %}
    {%- if value == 1 -%}
        {%- continue -%}
    {%- elif value == 3 -%}
        {%- break -%}
    {%- endif -%}
    {{ value }}
{%- endfor -%}

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 entities currently in an unavailable or unknown state.

You could use this conditionally, like so:

{% if has_value('sensor.train_departure_time') %}
  The train leaves at {{ states('sensor.train_departure_time') }}
{% endif %}

Or, maybe list all entities from the living room that currently have no state value:

{{ area_entities('living_room') | reject('has_value') | list }}

Database scalability

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

This version has a new database format that reduces the space needed to store history for your devices. This change comes with a few benefits:

  • Smaller (deduplication), less disk usage
  • Reduced disk IO (SD-card 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 action completes 🚀
  • Home Assistant now keeps history when renaming entities 🤘

If you are accessing the database directly, check out the Data Science Portal and the SQL Integration 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 entity, wait 24 hours after upgrading before renaming.

New selector capabilities

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 device and entity filters on the Area, Entity, Device, and Target selectors. Previously, you could filter with a single set of conditions; 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 devices.

An example, this selector allows you to select the battery sensor 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

Translating entities

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

This includes the entities’ names, their attributes, and translations of the attribute values. These translations will be visible on your dashboards, dialogs, automation editors, etc. Pretty much all places displaying them.

Integrations have to explicitly add support for these. Quite a few integrations have done so in this release, but we expect many to follow in the upcoming releases.

Other noteworthy changes

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

  • @ArturoGuerra added support for locks to Matter! Nice!
  • The new light entity dialog (introduced last release) now better supports white mode. Thanks, @piitaya!
  • @emontnemery added energy storage and volume storage device classes; these will allow differentiating between, for example, consumed energy versus stored energy in a battery.
  • @starkillerOG is rocking the Reolink integration. It now provides button, switch, siren, select, number, and light entities for all kinds of things you Reolink cameras and doorbells can do. Awesome!
  • The Universal Media Player now supports browsing media! Thanks, @Drafteed!
  • The Supervisor integration now provides sensors containing the Home Assistant Core and Supervisor’s stats. Thanks, @ludeeus!
  • The Spotify integration now supports podcasts! Nice @BTMorton!
  • LIVISI Smart Home now supports climate devices, switches (PSSO, ISS, and ISS2), and window sensors (WDS). Thanks @StefanIacobLivisi & @planbnet!
  • ESPHome now supports pairing Bluetooth devices. Nice work @bdraco & @jagheterfredrik!
  • @MarkGodwin extended the TP-Link Omada integration to support update entities; awesome!
  • All sun.sun entity attributes are now also available as sensors, much easier to use, thanks @gjohansson-ST!
  • Covers with the door device class, now appear as actual doors in HomeKit, nice @Dexwell!
  • @loongyh did something similar for Google Assistant. Covers with the window device class now show up as actual windows. Thanks!
  • The SQL integration now supports settings device and state classes, thanks @gjohansson-ST!
  • @teharris1 added support for the new Insteon i3 device, cool!

New Integrations

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

Integrations now available to set up from the UI

The following integrations are now available via the Home Assistant UI:

Release 2023.4.1 - April 6

Release 2023.4.2 - April 8

Release 2023.4.3 - April 12

Release 2023.4.4 - April 13

Release 2023.4.5 - April 17

Release 2023.4.6 - April 21

Need help? Join the community!

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.

Backward-incompatible changes

Aladdin Connect

The previously deprecated YAML configuration of the Aladdin Connect integration has been removed.

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

(@epenet - #88694) (documentation)

AVM FRITZ!Box Tools

The binary sensor providing available firmware updates has been deprecated since 2022.5 and is now removed. Use the new update entity instead.

(@mib1185 - #89940) (documentation)

Bluetooth

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

Any integration or device previously set up using a UUID Bluetooth address will need to be deleted and recreated.

(@bdraco - #89926) (documentation)

Calendar

The calendar.create_event service 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) (documentation)

DSMR Reader

The previously deprecated YAML configuration of the DSMR Reader integration has been removed.

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

(@frenck - #89239) (documentation)

GIOŚ

AQI sensor state values are now in English, and the user interface will display their translation for the selected language. If you have been using this sensor in your automations and scripts, you’ll need to adjust these for this change.

(@bieniu - #89044) (documentation)


The name and station sensor state attributes have been removed because they are static data that do not describe the state of the entity.

The index sensor state attribute has been migrated to a separate entity, for example, sensor.home_no2_index.

(@bieniu - #89389) (documentation)

Groups - Notify

The behavior of passing parameters to service calls targeting notification groups has changed.

Current behavior: data mappings configured in the service override mappings configured in the action.

New behavior: data mappings configured in the action override mappings configured in the service.

(@arychj - #90253) (documentation)

Home Connect

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

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 action is a one-time requirement.

(@stickpin - #88801) (documentation)

IMAP

The previously deprecated YAML configuration of the IMAP integration has been removed.

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

(@jbouwh - #89981) (documentation)

Landis+Gyr Heat Meter

The conversion to MWh and the corresponding MWh-entities 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 automations, scripts, etc., you can replace these with the GJ-entities sensor.heat_meter_heat_usage_gj and sensor.heat_meter_heat_previous_year_gj.
  • If applicable, in the energy dashboard, replace sensor.heat_meter_heat_usage with sensor.heat_meter_heat_usage_gj. Note that the energy dashboard will still convert to MWh or kWh, therefore resulting in the same values as before.

(@vpathuis - #89522) (documentation)

Logbook

Logbook will be unavailable until the database schema migration completes. Logbook script and automation traces from previous runs of Home Assistant will be unavailable until background data migration is completed following the schema migration.

(@bdraco - #88942 #89465) (documentation)


Automation and script traces that include state 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) (documentation)

MySensors
  • The MySensors notify platform has been removed. It’s been deprecated since 2023.2.0. It’s been replaced by a text entity platform.
  • You should update any automations or scripts that use the notify.mysensors* service to instead use the text.set_value service and the corresponding text entity as a target.
  • The MySensors IR switch entity, corresponding to an S_IR child with V_SEND value, has been removed. This entity hasb been deprecated since 2023.2.0. It’s been replaced by a remote entity.
  • You should update any automations or scripts that use the mysensors.send_ir_code service to instead use the remote.send_command service and the corresponding remote entity as a target. Similar changes should be made for actions using the switch.turn_on and switch_turn_off services targeting the removed IR switch entities. Replace these with remote.turn_on and remote.turn_off services and remote entity targets.

(@MartinHjelmare - #90402 #90403) (documentation)

Moon

The previously deprecated YAML configuration of the Moon integration has been removed.

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

(@frenck - #89161) (documentation)

MQTT

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

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


The previously deprecated MQTT broker YAML configuration has been removed.

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

(@jbouwh - #87987) (documentation)

Nextcloud

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

(@mib1185 - #89396) (documentation)

OpenAI Conversation

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

(@balloob - #90423) (documentation)


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:
{%- for area in areas() %}
  {%- set area_info = namespace(printed=false) %}
  {%- for device in area_devices(area) -%}
    {%- if not device_attr(device, "disabled_by") and not device_attr(device, "entry_type") and device_attr(device, "name") %}
      {%- if not area_info.printed %}

{{ area_name(area) }}:
        {%- set area_info.printed = true %}
      {%- endif %}
- {{ device_attr(device, "name") }}{% if device_attr(device, "model") and (device_attr(device, "model") | string) not in (device_attr(device, "name") | string) %} ({{ device_attr(device, "model") }}){% endif %}
    {%- endif %}
  {%- endfor %}
{%- endfor %}

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) (documentation)

Overkiz

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

To sum up, this device is a garage door but cannot be exposed as such within Home Assistant. There is no state 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 entity has been added this release.

(@tetienne - #89043) (documentation)

Pushbullet

The previously deprecated YAML configuration of the Pushbullet integration has been removed.

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

(@gjohansson-ST - #90285) (documentation)

Radio Thermostat

The previously deprecated YAML configuration of the Radio Thermostat integration has been removed.

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

(@gjohansson-ST - #90284) (documentation)

Recorder

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

(@bdraco - #90747) (documentation)

Scrape

The previously deprecated YAML configuration of the Scrape integration has been removed.

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

(@gjohansson-ST - #90272) (documentation)

Season

The previously deprecated YAML configuration of the Season integration has been removed.

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

(@frenck - #89166) (documentation)

Tasmota

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 switch with switchmode set to 13 or 14.

(@DerEnderKeks - #85943) (documentation)

Templates

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

(@Petro31 - #86815)


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

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

{% for state in states | sort(attribute='entity_id') %}
Threshold

The behavior of the threshold binary sensor has changed:

  • The threshold binary sensor’s state is reset to unknown when the monitored sensor’s state is unknown, unavailable, or not a valid float.
  • When the monitored sensor’s state is first valid, or when it’s valid after being unknown, unavailable, or not a valid float:
    • Initialize a threshold sensor with only a lower threshold to state off, with the position attribute set to above.
    • Initialize a threshold sensor with only a upperthreshold to state off, with the position attribute set to below.
    • Initialize a threshold sensor with only an upper and a lower threshold to state on, with the position attribute set to in_range.

(@emontnemery - #88978) (documentation)

Twente Milieu

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

(@bobvandevijver - #89028) (documentation)

Volvo On Call

The previously deprecated YAML configuration of the Volvo On Call integration has been removed.

Volvo On Call is now configured via the UI, any existing YAML configuration has been imported in previous releases and can now be safely removed from your YAML configuration files.

(@gjohansson-ST - #90288) (documentation)

Z-Wave

With this release, you will need to update 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 version 0.1.77.
  • If you use the Z-Wave JS UI add-on, you need at least version 1.8.1.
  • If you use the Z-Wave JS UI Docker container, you need at least version 8.11.1.
  • If you run your own Docker container or some other installation method, you will need to update your zwave-js-server instance to at least 1.27.0.

(@raman325 - #90212) (documentation)

If you are a custom integration developer and want to learn about breaking changes and new features available for your integration: Be sure to follow our developer blog. The following are the most notable for this release:

Farewell to the following

The following integrations are also no longer available as of this release:

  • 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 integration is no longer in a functional state. (@gjohansson-ST - #90277)

All changes

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