Skip to main content

Relocate dhcp/ssdp/usb/zeroconf ServiceInfo models

· One min read

Summary of changes

To reduce current reliance on optional integrations for names that are in essence used as helpers, the following ServiceInfo models have been relocated:

  • DhcpServiceInfo from homeassistant.components.dhcp to homeassistant.helpers.service_info.dhcp
  • SsdpServiceInfo from homeassistant.components.ssdp to homeassistant.helpers.service_info.ssdp
  • UsbServiceInfo from homeassistant.components.usb to homeassistant.helpers.service_info.usb
  • ZeroconfServiceInfo from homeassistant.components.zeroconf to homeassistant.helpers.service_info.zeroconf

To update your integration:

  1. Replace the import statements as shown in the examples below
  2. Test your integration with the new imports

The old import locations are deprecated and will be removed in Home Assistant 2026.2.

Examples

# Old
# from homeassistant.components.dhcp import DhcpServiceInfo
# from homeassistant.components.ssdp import SsdpServiceInfo
# from homeassistant.components.usb import UsbServiceInfo
# from homeassistant.components.zeroconf import ZeroconfServiceInfo

# New
from homeassistant.helpers.service_info.dhcp import DhcpServiceInfo
from homeassistant.helpers.service_info.ssdp import SsdpServiceInfo
from homeassistant.helpers.service_info.usb import UsbServiceInfo
from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo

class MyConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow."""

async def async_step_dhcp(self, discovery_info: DhcpServiceInfo) -> ConfigFlowResult:
"""Handle dhcp discovery."""
...

async def async_step_ssdp(self, discovery_info: SsdpServiceInfo) -> ConfigFlowResult:
"""Handle ssdp discovery."""
...

async def async_step_usb(self, discovery_info: UsbServiceInfo) -> ConfigFlowResult:
"""Handle usb discovery."""
...

async def async_step_zeroconf(self, discovery_info: ZeroconfServiceInfo) -> ConfigFlowResult:
"""Handle zeroconf discovery."""
...

New area device class

· One min read

Summary of changes

A new AREA device class is now available for number and sensor entities, together with automatic unit conversion based on the unit system. A corresponding UnitOfArea unit enumerator, and AreaConverter converter class have been added to support the new device class.

Backward compatibility

The AREA_SQUARE_METERS constant has been deprecated and will be removed in Home Assistant 2025.12. Custom integrations should be adjusted to use UnitOfArea.SQUARE_METERS.

More details can be found in the Number documentation and Sensor documentation

Moving to Pydantic v2

· One min read

Pydantic is a widely used library in Python for data validation. On June 30, 2023, Pydantic v2 was released, introducing significant changes that are not backward compatible with Pydantic v1.

Starting with Home Assistant Core 2025.1, Pydantic v2 will replace v1. If your custom integration uses Pydantic, it must be updated to support Pydantic v2 to keep working in the upcoming release.

Over the past year, our community has worked hard to ensure that the libraries used by Home Assistant Core are compatible with both Pydantic v1 and v2. This dual compatibility has helped make our transition to Pydantic v2 as smooth as possible.

For a quick migration, you can use the Pydantic v1 shims included in Pydantic v2. Detailed information about using these shims in a v1/v2 environment can be found in the Pydantic migration guide.

Use Kelvin as the preferred color temperature unit

· 2 min read

Summary of changes

In October 2022, Home Assistant migrated the preferred color temperature unit from mired to kelvin.

It is now time to add deprecation warnings for the corresponding attributes, constants and properties:

  • Deprecate state and capability attributes ATTR_COLOR_TEMP, ATTR_MIN_MIREDS and ATTR_MAX_MIREDS
  • Deprecate constants ATTR_KELVIN and ATTR_COLOR_TEMP from the light.turn_on service call
  • Deprecate properties LightEntity.color_temp, LightEntity.min_mireds and LightEntity.max_mireds
  • Deprecate corresponding attributes LightEntity._attr_color_temp, LightEntity._attr_min_mired and LightEntity._attr_max_mired

Examples

Custom minimum/maximum color temperature

class MyLight(LightEntity):
"""Representation of a light."""

# Old
# _attr_min_mireds = 200 # 5000K
# _attr_max_mireds = 400 # 2500K

# New
_attr_min_color_temp_kelvin = 2500 # 400 mireds
_attr_max_color_temp_kelvin = 5000 # 200 mireds

Default minimum/maximum color temperature

from homeassistant.components.light import DEFAULT_MAX_KELVIN, DEFAULT_MIN_KELVIN

class MyLight(LightEntity):
"""Representation of a light."""

# Old did not need to have _attr_min_mireds / _attr_max_mireds set
# New needs to set the default explicitly
_attr_min_color_temp_kelvin = DEFAULT_MIN_KELVIN
_attr_max_color_temp_kelvin = DEFAULT_MAX_KELVIN

Dynamic minimum/maximum color temperature

from homeassistant.util import color as color_util

class MyLight(LightEntity):
"""Representation of a light."""

# Old
# def min_mireds(self) -> int:
# """Return the coldest color_temp that this light supports."""
# return device.coldest_temperature
#
# def max_mireds(self) -> int:
# """Return the warmest color_temp that this light supports."""
# return device.warmest_temperature

# New
def min_color_temp_kelvin(self) -> int:
"""Return the warmest color_temp that this light supports."""
return color_util.color_temperature_mired_to_kelvin(device.warmest_temperature)

def max_color_temp_kelvin(self) -> int:
"""Return the coldest color_temp that this light supports."""
return color_util.color_temperature_mired_to_kelvin(device.coldest_temperature)

Service call

from homeassistant.components.light import ATTR_COLOR_TEMP_KELVIN
from homeassistant.util import color as color_util

class MyLight(LightEntity):
"""Representation of a light."""
def turn_on(self, **kwargs: Any) -> None:
"""Turn on the light."""
# Old
# if ATTR_COLOR_TEMP in kwargs:
# color_temp_mired = kwargs[ATTR_COLOR_TEMP]
# color_temp_kelvin = color_util.color_temperature_mired_to_kelvin(color_temp_mired)

# Old
# if ATTR_KELVIN in kwargs:
# color_temp_kelvin = kwargs[ATTR_KELVIN]
# color_temp_mired = color_util.color_temperature_kelvin_to_mired(color_temp_kelvin)

# New
if ATTR_COLOR_TEMP_KELVIN in kwargs:
color_temp_kelvin = kwargs[ATTR_COLOR_TEMP_KELVIN]
color_temp_mired = color_util.color_temperature_kelvin_to_mired(color_temp_kelvin)

Background information

Changed name of WaterHeaterEntityDescription

· One min read

A naming error of the entity description was found in the Water Heater integration, and we have now renamed WaterHeaterEntityEntityDescription to WaterHeaterEntityDescription in the 2025.1 release. The old WaterHeaterEntityEntityDescription is deprecated, due for removal in 2026.1, and developpers are advised to use the new WaterHeaterEntityDescription instead.

See details in the core PR: #132888.

New vacuum state property

· One min read

As of Home Assistant Core 2025.1, the constants used to return state in StateVacuumEntity are deprecated and replaced by the VacuumActivity enum.

Also with this change, integrations should set the activity property instead of directly setting the state property.

There is a one-year deprecation period, and the constants will stop working from 2026.1 to ensure all custom integration authors have time to adjust.

Example


from homeassistant.components.vacuum import VacuumActivity

class MyVacuumCleaner(StateVacuumEntity):
"""My vacuum cleaner."""

@property
def activity(self) -> VacuumActivity | None:
"""Return the state of the vacuum."""
if self.device.is_cleaning():
return VacuumActivity.CLEANING
return VacuumActivity.DOCKED

More details can be found in the vacuum documentation.

Climate entity now supports independent horizontal swing

· 2 min read

As of Home Assistant Core 2024.12, we have implemented an independent property and method for controlling horizontal swing in ClimateEntity.

Integrations that support completely independent control and state for vertical and horizontal swing can now use the previous swing_mode for vertical swing only and use the new swing_horizontal_mode for providing the horizontal swing state and control.

Integrations that don't have independent control should still keep using the current swing_mode for both vertical and horizontal support.

Example

Example requirements to implement swing and swing_horizontal in your climate entity.


class MyClimateEntity(ClimateEntity):
"""Implementation of my climate entity."""

@property
def supported_features(self) -> ClimateEntityFeature:
"""Return the list of supported features."""
return ClimateEntityFeature.SWING_MODE | ClimateEntityFeature.SWING_HORIZONTAL_MODE

@property
def swing_mode(self) -> str | None:
"""Return the swing setting.

Requires ClimateEntityFeature.SWING_MODE.
"""
return self._attr_swing_mode

@property
def swing_modes(self) -> list[str] | None:
"""Return the list of available swing modes.

Requires ClimateEntityFeature.SWING_MODE.
"""
return self._attr_swing_modes

@property
def swing_horizontal_mode(self) -> str | None:
"""Return the swing setting.

Requires ClimateEntityFeature.SWING_HORIZONTAL_MODE.
"""
return self._attr_swing_horizontal_mode

@property
def swing_horizontal_modes(self) -> list[str] | None:
"""Return the list of available swing modes.

Requires ClimateEntityFeature.SWING_HORIZONTAL_MODE.
"""
return self._attr_swing_horizontal_modes

async def async_set_swing_mode(self, swing_mode: str) -> None:
"""Set new target swing operation."""
await self.api.set_swing_mode(swing_mode)

async def async_set_swing_horizontal_mode(self, swing_horizontal_mode: str) -> None:
"""Set new target horizontal swing operation."""
await self.api.set_swing_horizontal_mode(swing_horizontal_mode)

More details can be found in the climate documentation.

Utility function homeassistant.util.dt.utc_to_timestamp is deprecated

· One min read

The utility function homeassistant.util.dt.utc_to_timestamp is deprecated and will be removed in Home Assistant Core 2026.1, custom integrations which call it should instead call the stdlib method datetime.datetime.timestamp()

The reason for deprecation is that the stdlib method is just as fast as the utility function.

More details can be found in the core PR.

Camera API changes

· One min read

With Home Assistant 2024.11 we added WebRTC for most cameras. To add support for it we needed to refactor and improve the camera entity. Today we would like to announce that with the upcoming Home Assistant release 2024.12 the following methods are deprecated and will be removed with Home Assistant version 2025.6:

  • The property frontend_stream_type will be removed. As of 2024.11 Home assistant will identify the frontend stream type by checking if the camera entity implements the native WebRTC methods (#130932). Card developers can use the new websocket command camera/capabilities to get the frontend stream types.

  • The method async_handle_web_rtc_offer will be removed. Please use async_handle_async_webrtc_offer and the async WebRTC signaling approach (#131285).

  • The method async_register_rtsp_to_web_rtc_provider has been deprecated. Please use async_register_webrtc_provider, which offers more flexibility and supports the async WebRTC signaling approach (#131462).

More information about the replacements can be found in the camera entity documentation.

Translating units of measurement

· One min read

Home Assistant 2024.12 will support the translation of custom units of measurement. Previously, those would have been hardcoded in their integrations.

Just like for entity names, integrations just need to set the translation_key on the entity definition and provide the unit designation in the strings.json file (with the new unit_of_measurement key):

{
"entity": {
"sensor": {
"subscribers_count": {
"unit_of_measurement": "subscribers"
},
}
}
}

Check our backend localization documentation for details.