Skip to main content

Modernizing Modbus in Home Assistant

· 4 min read

Modbus is everywhere in the modern home: solar inverters, energy meters, heat pumps, and all kinds of industrial equipment that has found its way indoors. Home Assistant has long supported these devices through the YAML-based modbus integration, where users hand-write register maps in their configuration. That integration is not going anywhere, and existing setups keep working. But hand-writing register maps puts the burden of understanding a device's protocol on every user, and it does not fit the config-flow, UI-first direction the rest of Home Assistant has taken.

So we are adding a new way to use Modbus: an integration-based approach, where a device integration owns the device-specific knowledge and the user simply picks their device in the UI, the same as any other integration.

Sharing a connection

A Modbus connection is a single, exclusive resource: only one party can talk on the bus at a time. A serial (RS-485) bus, or a TCP-to-serial gateway, can carry many devices at once, sometimes from different manufacturers. If two integrations each open their own connection to the same bus, they fight over it, and historically Home Assistant did not support sharing a bus between integrations at all.

The new modbus_connection integration solves this by making a connection something device integrations route through rather than own. The user sets up a connection once in the UI, and modbus_connection keeps it open and manages its lifecycle, including reconnecting after a drop. Device integrations then borrow what they need from that shared connection instead of managing their own. We have revamped the Modbus developer documentation to cover how that works, with example code.

A standalone library

The connection abstraction underneath modbus_connection lives in modbus-connection, a new library we designed for this purpose and published on PyPI. It is not bound to Home Assistant and can be used standalone in any Python project. It presents a common, backend-neutral interface, so device library authors write against one API regardless of the underlying Modbus implementation, and it ships a device-modelling framework and a pytest plugin to make building and testing a device library straightforward.

This keeps concerns where they belong. A device library is a normal PyPI package that knows how to talk to a specific device, and a consuming integration in Home Assistant wires that library up to a shared connection and exposes entities. Both can be developed and tested independently.

For more background, see our research.

Let's get building

With these new building blocks in place, it is now possible to turn a collection of YAML configuration for Modbus into manufacturer-specific integrations that people can set up via the UI. If you're (interested in) working on this, stop by the #modbus channel on the Home Assistant Discord and we'll be happy to help.

If you're using an AI agent, you can give it the following prompt:

I want to create a new integration for Home Assistant using the new Modbus Connection integration as documented here: https://developers.home-assistant.io/docs/modbus/introduction

The YAML we want to turn into a device library can be found here: TODO INSERT LOCATION OF MODBUS YAML!

The deliverables of this task are going to be 3 folders:

Media sources can now be searched

· One min read

Media sources can now implement search. By adding an async_search_media method to your MediaSource, users can search through your media directly from the media browser.

from homeassistant.components.media_player import SearchMedia, SearchMediaQuery

async def async_search_media(
self, item: MediaSourceItem, query: SearchMediaQuery
) -> SearchMedia:
"""Search media."""
results = [...] # list of BrowseMediaSource items
return SearchMedia(result=results)

To tell the media browser which items can be searched, set the can_search flag to True on the BrowseMediaSource items you return while browsing (typically directories). Other integrations can trigger a search through the new media_source.async_search_media helper.

For more info, see the updated documentation.

Deprecation of the home_assistant_start flag of async_initialize_triggers

· One min read

The dedicated home_assistant_start flag of async_initialize_triggers is deprecated and will be removed in Home Assistant Core 2027.8. During the deprecation period the parameter no longer has any effect.

The flag existed because the homeassistant start trigger was a pseudo trigger: instead of acting like a real trigger, it relied on the caller of the trigger API passing home_assistant_start=True so that async_initialize_triggers would fire the trigger during startup.

The start trigger has been rewritten to work as a real trigger, so the flag is no longer needed. Callers of async_initialize_triggers should simply stop passing home_assistant_start.

To make the new implementation possible, the rewrite adds HomeAssistant.async_add_startup_job, which registers a job to be called after all listeners to EVENT_HOMEASSISTANT_START have executed, but before EVENT_HOMEASSISTANT_STARTED is fired. This mirrors the approach already used for the homeassistant shutdown trigger, and avoids adding yet another core state and event to the already complex relationship between core states and events.

For more details, see core PR 175160.

Introducing new unit enumerators

· One min read

As of Home Assistant Core 2026.7, the following unit constants are deprecated and replaced by a corresponding enum:

  • UnitOfDensity enumerator replaces mass over volume CONCENTRATION_*** constants ("g/m³", "mg/m³", "μg/m³", "μg/ft³")
  • UnitOfRatio enumerator replaces unit-less ratio CONCENTRATION_*** constants ("ppm", "ppb")

CONCENTRATION_PARTS_PER_CUBIC_METER was only used by a single integration and is deprecated without a replacement unit.

Please note that the use of PERCENTAGE constant is also deprecated when used as a unit of measurement, even if the constant itself is not deprecated.

Frontend component updates in 2026.7

· 3 min read

Component updates

Component sizes use Web Awesome names

ha-button, ha-button-toggle-group, and ha-slider now use the short Web Awesome size names.

For ha-button, use:

<ha-button size="s">Save</ha-button>

Supported values are xs, s, m, l, and xl.

For ha-button-toggle-group, use s or m:

<ha-button-toggle-group size="s" .buttons=${buttons}></ha-button-toggle-group>

ha-slider uses s or m.

If your custom card or editor still uses small, medium, or large on these components, migrate them to short values like s, m, or l.

Virtualized lists

We added two list components for large data sets:

  • ha-list-virtualized
  • ha-list-selectable-virtualized

Use these when a picker or dialog can render enough rows to affect scrolling or initial render time. The virtualized list renders only the visible rows while keeping the roving-tabindex keyboard navigation from ha-list-base.

Rows expose accessibility metadata with aria-setsize and aria-posinset, so assistive technologies still get the full list position even though only part of the list is in the DOM.

For selectable lists, render ha-list-item-option rows.

Context and editor infrastructure

Dirty state tracking

Dialogs and editors now have shared dirty-state infrastructure:

  • DirtyStateProviderMixin
  • dirtyStateContext
  • isDirtyState
  • isEffectiveDirtyState

Use DirtyStateProviderMixin for new dialogs or editors that need to block scrim close, enable Save only after edits, or coordinate dirty state with child components.

class MyDialog extends DirtyStateProviderMixin<MyState>()(LitElement) {
public openDialog() {
this._initDirtyTracking({ type: "shallow" }, this._state);
}

private _stateChanged(state: MyState) {
this._updateDirtyState(state);
}
}

isDirtyState is the raw comparison and is usually right for enabling Save. isEffectiveDirtyState can ignore equivalent config output, for example when an editor normalizes an explicit default back to the same effective config.

Pages and editors can now publish related context for nearby pickers:

  • relatedContext
  • fireRelatedContext
  • fireEntityRelatedContext

When a card editor, badge editor, automation trace page, or similar surface knows the current entity, device, or area, it can provide that context. Entity pickers and add-element searches can then prioritize related entities, devices, and areas.

fireEntityRelatedContext(this, "light.kitchen");

Clear the context with undefined when the editor no longer has a related item.

Narrow viewport context

narrowViewportContext exposes whether the main Home Assistant viewport is in the narrow layout.

Components that only need narrow-layout state can consume this context instead of receiving narrow through several layers of properties.

@consume({ context: narrowViewportContext, subscribe: true })
private _narrow!: boolean;

Lovelace updates

Strategy regeneration control

Lovelace strategies can now avoid unnecessary regeneration.

Strategies may declare registryDependencies to use the default reference-change check for only the registries they depend on:

static registryDependencies = ["entities", "areas"] as const;

For custom logic, implement shouldRegenerate():

static shouldRegenerate(config, oldHomeAssistant, newHomeAssistant) {
return oldHomeAssistant.entities !== newHomeAssistant.entities;
}

If neither is provided, strategies keep the previous default behavior and regenerate on changes to entities, devices, areas, or floors.

Changes to device tracker entity models

· 3 min read

Summary

There have been multiple recent changes to the device tracker entity model:

  • The battery_level property has been deprecated
  • The location_name property of TrackerEntity has been deprecated
  • A new entity base class BaseScannerEntity has been introduced
  • Users can associate scanners with other zones than the home zone
  • TrackerEntity has a new property in_zones
  • BaseScannerEntity and ScannerEntity have a new state attribute in_zones
  • A new capability attribute tracking_type has been introduced
  • Zones are now calculated by size, then distance to center when calculating the state of TrackerEntity

Details

Deprecation of battery_level

The battery_level property has been deprecated in all device tracker base classes, and will stop working in Home Assistant Core 2027.7. Integrations should communicate battery level via a battery sensor instead.

More details can be found in architecture proposal #627

Deprecation of location_name

The location_name property of TrackerEntity has been deprecated, and will stop working in Home Assistant Core 2027.7.

Integrations with device trackers which do not know or do not want to report the exact coordinates and today use location_name to report the name of a zone should instead report a list of zone entity IDs through the in_zones property. Device trackers which use location_name to give extra context can instead do that via a separate sensor or an extra state attribute.

More details can be found in architecture proposal #1387

Introduction of the BaseScannerEntity base class

The BaseScannerEntity class should be used by integrations which have scanners which do not track connection to a WLAN or other local network, for example scanners which track connection to a BLE beacon.

Users can associate BaseScannerEntity and ScannerEntity with any zone

BaseScannerEntity and ScannerEntity store the associated zone as an entity registry option. The base class will set the state of the entity to the name of the associated zone when connected, and the in_zones state attribute to all zones which contain the associated zone.

More details can be found in architecture proposal #1389

Introduction of the in_zones state attribute

A new state attribute in_zones is present in the state of device tracker entities. The state attribute is automatically calculated by BaseScannerEntity and ScannerEntity. TrackerEntity will derive the in_zones state attribute from the in_zones property if not None, if it is None it will be calculated from the reported location.

The in_zones state attribute is a list of zone entity IDs sorted by size, with the smallest zone first, then by distance to center.

Introduction of the tracking_type capability attribute

A new capability attribute tracking_type is present in the state of device tracker entities. The state attribute is set to connection by BaseScannerEntity and ScannerEntity and to location by TrackerEntity. Integrations should not override this behavior.

Custom card suggestions in the card picker

· One min read

As of Home Assistant 2026.6, custom cards can show up as suggestions in the card picker. When a user selects an entity, custom cards that opt in are listed under a Community section, below the built-in suggestions.

To opt in, add a getEntitySuggestion function to your window.customCards entry. It receives the hass object and the selected entity id, and returns a suggestion (or null if the entity is not supported):

window.customCards.push({
type: "my-card",
name: "My Card",
getEntitySuggestion: (hass, entityId) => {
if (entityId.split(".")[0] !== "light") {
return null;
}
return {
config: { type: "custom:my-card", entity: entityId },
};
},
});

You can also return an array of suggestions to offer several variants, each with its own label.

Only suggest your card when it makes sense for the entity. Check the domain, device class, or supported features with the hass object, and return null otherwise. Suggesting your card for every entity makes the picker noisy.

See the custom card documentation for the full reference.

Frontend component updates in 2026.6

· 2 min read

Component updates

ha-radio updates

ha-radio was removed from our codebase, we use the webawesome based ha-radio-group with ha-radio-option now. No need for a ha-formfield around a ha-radio anymore and you can use the new CSS properties to customize the radio group and options.

New component specific tokens:

--ha-radio-group-required-marker
--ha-radio-group-required-marker-offset

--ha-radio-option-active-color
--ha-radio-option-heigh
--ha-radio-option-toggle-size
--ha-radio-option-border-width
--ha-radio-option-border-color
--ha-radio-option-border-color-hover
--ha-radio-option-background-color
--ha-radio-option-background-color-hover
--ha-radio-option-checked-background-color
--ha-radio-option-checked-icon-color
--ha-radio-option-checked-icon-scale
--ha-radio-option-control-margin

ha-drawer updates

ha-drawer was updated to use the webawesome drawer component. The API is mostly the same it just uses now --ha-sidebar-width instead of --mdc-drawer-width

top bar

  • ha-top-app-bar was removed entirely.
  • ha-top-app-bar-fixed was migrated from MWC to plain Lit.
  • ha-two-pane-top-app-bar-fixed was rewritten to extend the new implementation instead of Material base code.
  • ha-header-bar was rewritten from a Material top-app-bar styled wrapper to a native Lit component.

The --ha-top-app-bar-width token replaces --mdc-top-app-bar-width.

New decorators

@consumeLocalize

Following up on the context entry decorators introduced last release, we added a shortcut for the most common single-field read off internationalizationContext: the localize function.

Before:

@state()
@consume({ context: internationalizationContext, subscribe: true })
@transform<HomeAssistantInternationalization, LocalizeFunc>({
transformer: ({ localize }) => localize,
})
private _localize!: LocalizeFunc;

After:

@state()
@consumeLocalize()
private _localize!: LocalizeFunc;

Use @consumeLocalize() whenever a component only needs the localize function. For other single-field reads off internationalizationContext (e.g. locale, language), keep using @consume + @transform.

Deprecation of advanced mode in data entry flow

· One min read

Summary

User profile advanced mode is going away, which means integrations can no longer check if advanced mode is enabled or not in data entry flows.

Integrations authors need to update integrations to use an alternative user friendly way to present additional options in the UI, for example group additional options in a section.

FlowHandler.show_advanced_options

The FlowHandler.show_advanced_options property has been deprecated and will be removed with the release of Home Assistant Core 2027.6. During the deprecation period, FlowHandler.show_advanced_options unconditionally returns True to not make options gated by this flag inaccessible to users.

FlowHandler.context['show_advanced_options']

There is no longer a show_advanced_options key in FlowHandler.context.

Background

The Advanced mode toggle in the user profile is a single binary switch that gates a collection of unrelated features across Home Assistant, from app (add-on) visibility (Terminal & SSH) to configuration options and UI elements, and we've been working on removing it during the past year.

For a more in-depth explanation, see roadmap issue #54.

BrowseMediaSource: domain is now required

· 2 min read

The BrowseMediaSource class in the media_source integration has been tightened up. The domain parameter is now a required str instead of str | None, and the special "list every media source" root node has moved to its own class, RootBrowseMediaSource.

Previously, domain was optional only to represent one edge case: the top-level node returned when browsing media-source:// with no specific source selected. That made the type hint misleading for the 99% case — every actual media source has a domain — and added a None branch that consumers had to think about. Splitting the root into its own class removes that branch.

What changed

  • BrowseMediaSource.__init__ now requires domain: str.
  • A new RootBrowseMediaSource class represents the root browse node listing all available media sources. It hardcodes domain=None and identifier=None and uses media-source:// as its content ID.
  • media_source.async_browse_media() and MediaSourceItem.async_browse() now return BrowseMediaSource | RootBrowseMediaSource.

Impact on custom integrations

Most integrations don't need any changes. If you implement a media_source.py platform, you were already passing your own domain to BrowseMediaSource — that keeps working.

You only need to act if:

  • You pass domain=None to BrowseMediaSource. This is no longer allowed. Set your integration domain instead.

  • You call media_source.async_browse_media() and annotate the result. Update the type hint to BrowseMediaSource | RootBrowseMediaSource, or narrow with isinstance() before using domain-specific attributes:

    from homeassistant.components.media_source import (
    BrowseMediaSource,
    async_browse_media,
    )

    result = await async_browse_media(hass, media_content_id)
    if isinstance(result, BrowseMediaSource):
    # result.domain is guaranteed to be a str here
    ...

See the updated media source platform documentation for the full reference.