homeassistant.helpers

Helper methods for components within Home Assistant.

homeassistant.helpers.config_per_platform(config: ConfigType, domain: str) → Iterable[tuple[str | None, ConfigType]][source]

Break a component config into different platforms.

For example, will find ‘switch’, ‘switch 2’, ‘switch 3’, .. etc Async friendly.

homeassistant.helpers.extract_domain_configs(config: ConfigType, domain: str) → Sequence[str][source]

Extract keys from config for given domain name.

Async friendly.

homeassistant.helpers.aiohttp_client

homeassistant.helpers.area_registry

homeassistant.helpers.check_config

homeassistant.helpers.collection

homeassistant.helpers.condition

homeassistant.helpers.config_entry_flow

homeassistant.helpers.config_entry_oauth2_flow

homeassistant.helpers.config_validation

homeassistant.helpers.data_entry_flow

homeassistant.helpers.debounce

homeassistant.helpers.deprecation

Deprecation helpers for Home Assistant.

homeassistant.helpers.deprecation.deprecated_class(replacement: str) → Any[source]

Mark class as deprecated and provide a replacement class to be used instead.

homeassistant.helpers.deprecation.deprecated_function(replacement: str) → Callable[..., Callable][source]

Mark function as deprecated and provide a replacement function to be used instead.

homeassistant.helpers.deprecation.deprecated_substitute(substitute_name: str) → Callable[..., Callable][source]

Help migrate properties to new names.

When a property is added to replace an older property, this decorator can be added to the new property, listing the old property as the substitute. If the old property is defined, its value will be used instead, and a log warning will be issued alerting the user of the impending change.

homeassistant.helpers.deprecation.get_deprecated(config: dict[str, Any], new_name: str, old_name: str, default: Any | None = None) → Any | None[source]

Allow an old config name to be deprecated with a replacement.

If the new config isn’t found, but the old one is, the old value is used and a warning is issued to the user.

homeassistant.helpers.device_registry

homeassistant.helpers.discovery

homeassistant.helpers.dispatcher

homeassistant.helpers.entity

homeassistant.helpers.entity_component

homeassistant.helpers.entity_platform

homeassistant.helpers.entity_registry

homeassistant.helpers.entity_values

homeassistant.helpers.entityfilter

homeassistant.helpers.event

homeassistant.helpers.icon

Icon helper methods.

homeassistant.helpers.icon.icon_for_battery_level(battery_level: int | None = None, charging: bool = False) → str[source]

Return a battery icon valid identifier.

homeassistant.helpers.icon.icon_for_signal_level(signal_level: int | None = None) → str[source]

Return a signal icon valid identifier.

homeassistant.helpers.integration_platform

homeassistant.helpers.intent

homeassistant.helpers.json

Helpers to help with encoding Home Assistant objects in JSON.

class homeassistant.helpers.json.ExtendedJSONEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]

Bases: homeassistant.helpers.json.JSONEncoder

JSONEncoder that supports Home Assistant objects and falls back to repr(o).

default(o: Any) → Any[source]

Convert certain objects.

Fall back to repr(o).

class homeassistant.helpers.json.JSONEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]

Bases: json.encoder.JSONEncoder

JSONEncoder that supports Home Assistant objects.

default(o: Any) → Any[source]

Convert Home Assistant objects.

Hand other objects to the original method.

homeassistant.helpers.location

homeassistant.helpers.logging

homeassistant.helpers.network

homeassistant.helpers.restore_state

homeassistant.helpers.script

homeassistant.helpers.service

homeassistant.helpers.signal

homeassistant.helpers.state

homeassistant.helpers.storage

homeassistant.helpers.sun

homeassistant.helpers.system_info

homeassistant.helpers.temperature

homeassistant.helpers.template

homeassistant.helpers.translation

homeassistant.helpers.typing

homeassistant.helpers.update_coordinator