1
0
mirror of https://github.com/home-assistant/core.git synced 2026-05-08 17:49:37 +01:00

Remove bind_hass usage (#168369)

This commit is contained in:
Artur Pragacz
2026-04-16 15:38:59 +02:00
committed by GitHub
parent fa85d0d6c2
commit f5fef37210
67 changed files with 13 additions and 274 deletions
@@ -157,7 +157,6 @@ from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.config_entry_oauth2_flow import OAuth2AuthorizeCallbackView
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import bind_hass
from homeassistant.util import dt as dt_util
from homeassistant.util.hass_dict import HassKey
@@ -173,7 +172,6 @@ CONFIG_SCHEMA = cv.empty_config_schema(DOMAIN)
DELETE_CURRENT_TOKEN_DELAY = 2
@bind_hass
def create_auth_code(
hass: HomeAssistant, client_id: str, credential: Credentials
) -> str:
@@ -83,7 +83,6 @@ from homeassistant.helpers.trace import (
trace_path,
)
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import bind_hass
from homeassistant.util.dt import parse_datetime
from homeassistant.util.hass_dict import HassKey
@@ -238,7 +237,6 @@ class IfAction(Protocol):
"""AND all conditions."""
@bind_hass
def is_on(hass: HomeAssistant, entity_id: str) -> bool:
"""Return true if specified automation entity_id is on.
@@ -58,7 +58,6 @@ from homeassistant.helpers.event import async_track_time_interval
from homeassistant.helpers.network import get_url
from homeassistant.helpers.template import Template
from homeassistant.helpers.typing import ConfigType, VolDictType
from homeassistant.loader import bind_hass
from .const import (
CAMERA_IMAGE_TIMEOUT,
@@ -163,7 +162,6 @@ class CameraCapabilities:
frontend_stream_types: set[StreamType]
@bind_hass
async def async_request_stream(hass: HomeAssistant, entity_id: str, fmt: str) -> str:
"""Request a stream for a camera entity."""
camera = get_camera_from_entity_id(hass, entity_id)
@@ -212,7 +210,6 @@ async def _async_get_image(
raise HomeAssistantError("Unable to get image")
@bind_hass
async def async_get_image(
hass: HomeAssistant,
entity_id: str,
@@ -247,14 +244,12 @@ async def _async_get_stream_image(
return None
@bind_hass
async def async_get_stream_source(hass: HomeAssistant, entity_id: str) -> str | None:
"""Fetch the stream source for a camera entity."""
camera = get_camera_from_entity_id(hass, entity_id)
return await camera.stream_source()
@bind_hass
async def async_get_mjpeg_stream(
hass: HomeAssistant, request: web.Request, entity_id: str
) -> web.StreamResponse | None:
+1 -7
View File
@@ -36,7 +36,7 @@ from homeassistant.helpers.dispatcher import (
from homeassistant.helpers.event import async_call_later
from homeassistant.helpers.service import async_register_admin_service
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import async_get_integration, bind_hass
from homeassistant.loader import async_get_integration
from homeassistant.util.signal_type import SignalType
# Pre-import backup to avoid it being imported
@@ -181,7 +181,6 @@ class CloudConnectionState(Enum):
CLOUD_DISCONNECTED = "cloud_disconnected"
@bind_hass
@callback
def async_is_logged_in(hass: HomeAssistant) -> bool:
"""Test if user is logged in.
@@ -191,7 +190,6 @@ def async_is_logged_in(hass: HomeAssistant) -> bool:
return DATA_CLOUD in hass.data and hass.data[DATA_CLOUD].is_logged_in
@bind_hass
@callback
def async_is_connected(hass: HomeAssistant) -> bool:
"""Test if connected to the cloud."""
@@ -207,7 +205,6 @@ def async_listen_connection_change(
return async_dispatcher_connect(hass, SIGNAL_CLOUD_CONNECTION_STATE, target)
@bind_hass
@callback
def async_active_subscription(hass: HomeAssistant) -> bool:
"""Test if user has an active subscription."""
@@ -230,7 +227,6 @@ async def async_get_or_create_cloudhook(hass: HomeAssistant, webhook_id: str) ->
return await async_create_cloudhook(hass, webhook_id)
@bind_hass
async def async_create_cloudhook(hass: HomeAssistant, webhook_id: str) -> str:
"""Create a cloudhook."""
if not async_is_connected(hass):
@@ -245,7 +241,6 @@ async def async_create_cloudhook(hass: HomeAssistant, webhook_id: str) -> str:
return cloudhook_url
@bind_hass
async def async_delete_cloudhook(hass: HomeAssistant, webhook_id: str) -> None:
"""Delete a cloudhook."""
if DATA_CLOUD not in hass.data:
@@ -272,7 +267,6 @@ def async_listen_cloudhook_change(
)
@bind_hass
@callback
def async_remote_ui_url(hass: HomeAssistant) -> str:
"""Get the remote UI URL."""
@@ -25,7 +25,6 @@ from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.entity import async_generate_entity_id
from homeassistant.helpers.event import async_call_later
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import bind_hass
from homeassistant.util.async_ import run_callback_threadsafe
_KEY_INSTANCE = "configurator"
@@ -54,7 +53,6 @@ type ConfiguratorCallback = Callable[[list[dict[str, str]]], None]
CONFIG_SCHEMA = cv.empty_config_schema(DOMAIN)
@bind_hass
@async_callback
def async_request_config(
hass: HomeAssistant,
@@ -93,7 +91,6 @@ def async_request_config(
return request_id
@bind_hass
def request_config(hass: HomeAssistant, *args: Any, **kwargs: Any) -> str:
"""Create a new request for configuration.
@@ -104,7 +101,6 @@ def request_config(hass: HomeAssistant, *args: Any, **kwargs: Any) -> str:
).result()
@bind_hass
@async_callback
def async_notify_errors(hass: HomeAssistant, request_id: str, error: str) -> None:
"""Add errors to a config request."""
@@ -112,7 +108,6 @@ def async_notify_errors(hass: HomeAssistant, request_id: str, error: str) -> Non
_get_requests(hass)[request_id].async_notify_errors(request_id, error)
@bind_hass
def notify_errors(hass: HomeAssistant, request_id: str, error: str) -> None:
"""Add errors to a config request."""
return run_callback_threadsafe(
@@ -120,7 +115,6 @@ def notify_errors(hass: HomeAssistant, request_id: str, error: str) -> None:
).result()
@bind_hass
@async_callback
def async_request_done(hass: HomeAssistant, request_id: str) -> None:
"""Mark a configuration request as done."""
@@ -128,7 +122,6 @@ def async_request_done(hass: HomeAssistant, request_id: str) -> None:
_get_requests(hass).pop(request_id).async_request_done(request_id)
@bind_hass
def request_done(hass: HomeAssistant, request_id: str) -> None:
"""Mark a configuration request as done."""
return run_callback_threadsafe(
@@ -23,7 +23,6 @@ from homeassistant.helpers import config_validation as cv, intent
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.reload import async_integration_yaml_config
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import bind_hass
from .agent_manager import (
AgentInfo,
@@ -127,7 +126,6 @@ CONFIG_SCHEMA = vol.Schema(
@callback
@bind_hass
def async_set_agent(
hass: HomeAssistant,
config_entry: ConfigEntry,
@@ -138,7 +136,6 @@ def async_set_agent(
@callback
@bind_hass
def async_unset_agent(
hass: HomeAssistant,
config_entry: ConfigEntry,
@@ -29,7 +29,6 @@ from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.entity import Entity, EntityDescription
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import bind_hass
from homeassistant.util.hass_dict import HassKey
from .condition import make_cover_is_closed_condition, make_cover_is_open_condition
@@ -87,7 +86,6 @@ __all__ = [
]
@bind_hass
def is_closed(hass: HomeAssistant, entity_id: str) -> bool:
"""Return if the cover is closed based on the statemachine."""
return hass.states.is_state(entity_id, CoverState.CLOSED)
@@ -5,7 +5,6 @@ from __future__ import annotations
from homeassistant.const import ATTR_GPS_ACCURACY, STATE_HOME # noqa: F401
from homeassistant.core import HomeAssistant
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import bind_hass
from .config_entry import ( # noqa: F401
ScannerEntity,
@@ -52,7 +51,6 @@ from .legacy import ( # noqa: F401
)
@bind_hass
def is_on(hass: HomeAssistant, entity_id: str) -> bool:
"""Return the state if any or a specified device is home."""
return hass.states.is_state(entity_id, STATE_HOME)
-2
View File
@@ -25,7 +25,6 @@ from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.entity import ToggleEntity, ToggleEntityDescription
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import bind_hass
from homeassistant.util.hass_dict import HassKey
from homeassistant.util.percentage import (
percentage_to_ranged_value,
@@ -88,7 +87,6 @@ class NotValidPresetModeError(ServiceValidationError):
)
@bind_hass
def is_on(hass: HomeAssistant, entity_id: str) -> bool:
"""Return if the fans are on based on the statemachine."""
entity = hass.states.get(entity_id)
@@ -20,7 +20,6 @@ from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import bind_hass
from homeassistant.util.system_info import is_official_image
from .const import (
@@ -71,7 +70,6 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
return True
@bind_hass
def get_ffmpeg_manager(hass: HomeAssistant) -> FFmpegManager:
"""Return the FFmpegManager."""
if DATA_FFMPEG not in hass.data:
@@ -79,7 +77,6 @@ def get_ffmpeg_manager(hass: HomeAssistant) -> FFmpegManager:
return hass.data[DATA_FFMPEG]
@bind_hass
async def async_get_image(
hass: HomeAssistant,
input_source: str,
@@ -34,7 +34,7 @@ from homeassistant.helpers.json import json_dumps_sorted
from homeassistant.helpers.storage import Store
from homeassistant.helpers.translation import async_get_translations
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import async_get_integration, bind_hass
from homeassistant.loader import async_get_integration
from homeassistant.util.hass_dict import HassKey
from .pr_download import download_pr_artifact
@@ -354,7 +354,6 @@ class Panel:
return response
@bind_hass
@callback
def async_register_built_in_panel(
hass: HomeAssistant,
@@ -393,7 +392,6 @@ def async_register_built_in_panel(
hass.bus.async_fire(EVENT_PANELS_UPDATED)
@bind_hass
@callback
def async_remove_panel(
hass: HomeAssistant, frontend_url_path: str, *, warn_if_unknown: bool = True
+2 -5
View File
@@ -28,7 +28,6 @@ from homeassistant.helpers.group import (
)
from homeassistant.helpers.reload import async_reload_integration_platforms
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import bind_hass
#
# Below we ensure the config_flow is imported so it does not need the import
@@ -103,7 +102,6 @@ CONFIG_SCHEMA = vol.Schema(
)
@bind_hass
def is_on(hass: HomeAssistant, entity_id: str) -> bool:
"""Test if the group state is in its ON-state."""
if REG_KEY not in hass.data:
@@ -117,11 +115,10 @@ def is_on(hass: HomeAssistant, entity_id: str) -> bool:
# expand_entity_ids and get_entity_ids are for backwards compatibility only
expand_entity_ids = bind_hass(_expand_entity_ids)
get_entity_ids = bind_hass(_get_entity_ids)
expand_entity_ids = _expand_entity_ids
get_entity_ids = _get_entity_ids
@bind_hass
def groups_with_entity(hass: HomeAssistant, entity_id: str) -> list[str]:
"""Get all groups that contain this entity.
@@ -26,7 +26,6 @@ from homeassistant.helpers import device_registry as dr
from homeassistant.helpers.debounce import Debouncer
from homeassistant.helpers.device_registry import DeviceInfo
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
from homeassistant.loader import bind_hass
from .const import (
ATTR_AUTO_UPDATE,
@@ -74,7 +73,6 @@ _LOGGER = logging.getLogger(__name__)
@callback
@bind_hass
def get_info(hass: HomeAssistant) -> dict[str, Any] | None:
"""Return generic information from Supervisor.
@@ -84,7 +82,6 @@ def get_info(hass: HomeAssistant) -> dict[str, Any] | None:
@callback
@bind_hass
def get_host_info(hass: HomeAssistant) -> dict[str, Any] | None:
"""Return generic host information.
@@ -94,7 +91,6 @@ def get_host_info(hass: HomeAssistant) -> dict[str, Any] | None:
@callback
@bind_hass
def get_store(hass: HomeAssistant) -> dict[str, Any] | None:
"""Return store information.
@@ -104,7 +100,6 @@ def get_store(hass: HomeAssistant) -> dict[str, Any] | None:
@callback
@bind_hass
def get_supervisor_info(hass: HomeAssistant) -> dict[str, Any] | None:
"""Return Supervisor information.
@@ -114,7 +109,6 @@ def get_supervisor_info(hass: HomeAssistant) -> dict[str, Any] | None:
@callback
@bind_hass
def get_network_info(hass: HomeAssistant) -> dict[str, Any] | None:
"""Return Host Network information.
@@ -124,7 +118,6 @@ def get_network_info(hass: HomeAssistant) -> dict[str, Any] | None:
@callback
@bind_hass
def get_addons_info(hass: HomeAssistant) -> dict[str, dict[str, Any] | None] | None:
"""Return Addons info.
@@ -143,7 +136,6 @@ def get_addons_list(hass: HomeAssistant) -> list[dict[str, Any]] | None:
@callback
@bind_hass
def get_addons_stats(hass: HomeAssistant) -> dict[str, dict[str, Any] | None]:
"""Return Addons stats.
@@ -153,7 +145,6 @@ def get_addons_stats(hass: HomeAssistant) -> dict[str, dict[str, Any] | None]:
@callback
@bind_hass
def get_core_stats(hass: HomeAssistant) -> dict[str, Any]:
"""Return core stats.
@@ -163,7 +154,6 @@ def get_core_stats(hass: HomeAssistant) -> dict[str, Any]:
@callback
@bind_hass
def get_supervisor_stats(hass: HomeAssistant) -> dict[str, Any]:
"""Return supervisor stats.
@@ -173,7 +163,6 @@ def get_supervisor_stats(hass: HomeAssistant) -> dict[str, Any]:
@callback
@bind_hass
def get_os_info(hass: HomeAssistant) -> dict[str, Any] | None:
"""Return OS information.
@@ -183,7 +172,6 @@ def get_os_info(hass: HomeAssistant) -> dict[str, Any] | None:
@callback
@bind_hass
def get_core_info(hass: HomeAssistant) -> dict[str, Any] | None:
"""Return Home Assistant Core information from Supervisor.
@@ -193,7 +181,6 @@ def get_core_info(hass: HomeAssistant) -> dict[str, Any] | None:
@callback
@bind_hass
def get_issues_info(hass: HomeAssistant) -> SupervisorIssues | None:
"""Return Supervisor issues info.
@@ -51,7 +51,6 @@ from homeassistant.helpers.http import (
from homeassistant.helpers.importlib import async_import_module
from homeassistant.helpers.network import NoURLAvailableError, get_url
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import bind_hass
from homeassistant.setup import (
SetupPhases,
async_start_setup,
@@ -175,7 +174,6 @@ class ConfData(TypedDict, total=False):
ssl_profile: str
@bind_hass
async def async_get_last_config(hass: HomeAssistant) -> dict[str, Any] | None:
"""Return the last known working config."""
store = storage.Store[dict[str, Any]](hass, STORAGE_VERSION, STORAGE_KEY)
@@ -24,7 +24,6 @@ from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.entity import ToggleEntity, ToggleEntityDescription
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import bind_hass
from homeassistant.util.hass_dict import HassKey
from .const import ( # noqa: F401
@@ -78,7 +77,6 @@ DEVICE_CLASSES = [cls.value for cls in HumidifierDeviceClass]
# mypy: disallow-any-generics
@bind_hass
def is_on(hass: HomeAssistant, entity_id: str) -> bool:
"""Return if the humidifier is on based on the statemachine.
@@ -26,7 +26,6 @@ from homeassistant.helpers.restore_state import RestoreEntity
import homeassistant.helpers.service
from homeassistant.helpers.storage import Store
from homeassistant.helpers.typing import ConfigType, VolDictType
from homeassistant.loader import bind_hass
DOMAIN = "input_boolean"
@@ -81,7 +80,6 @@ class InputBooleanStorageCollection(collection.DictStorageCollection):
return {CONF_ID: item[CONF_ID]} | update_data
@bind_hass
def is_on(hass: HomeAssistant, entity_id: str) -> bool:
"""Test if input_boolean is True."""
return hass.states.is_state(entity_id, STATE_ON)
@@ -26,7 +26,6 @@ from homeassistant.helpers.entity import ToggleEntity, ToggleEntityDescription
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.frame import ReportBehavior, report_usage
from homeassistant.helpers.typing import ConfigType, VolDictType
from homeassistant.loader import bind_hass
from homeassistant.util import color as color_util
from .const import ( # noqa: F401
@@ -223,7 +222,6 @@ LIGHT_TURN_OFF_SCHEMA: VolDictType = {
_LOGGER = logging.getLogger(__name__)
@bind_hass
def is_on(hass: HomeAssistant, entity_id: str) -> bool:
"""Return if the lights are on based on the statemachine."""
return hass.states.is_state(entity_id, STATE_ON)
@@ -30,7 +30,6 @@ from homeassistant.helpers.integration_platform import (
async_process_integration_platforms,
)
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import bind_hass
from homeassistant.util.event_type import EventType
from . import rest_api, websocket_api
@@ -62,7 +61,6 @@ LOG_MESSAGE_SCHEMA = vol.Schema(
)
@bind_hass
def log_entry(
hass: HomeAssistant,
name: str,
@@ -76,7 +74,6 @@ def log_entry(
@callback
@bind_hass
def async_log_entry(
hass: HomeAssistant,
name: str,
@@ -59,7 +59,6 @@ from homeassistant.helpers.entity import Entity, EntityDescription
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.network import get_url
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import bind_hass
from homeassistant.util.hass_dict import HassKey
from .browse_media import ( # noqa: F401
@@ -246,7 +245,6 @@ class _ImageCache(TypedDict):
_ENTITY_IMAGE_CACHE = _ImageCache(images=collections.OrderedDict(), maxsize=16)
@bind_hass
def is_on(hass: HomeAssistant, entity_id: str | None = None) -> bool:
"""Return true if specified media player entity_id is on.
@@ -8,7 +8,6 @@ from homeassistant.components.media_player import BrowseError, BrowseMedia
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.frame import report_usage
from homeassistant.helpers.typing import UNDEFINED, UndefinedType
from homeassistant.loader import bind_hass
from .const import DOMAIN, MEDIA_SOURCE_DATA
from .error import UnknownMediaSource, Unresolvable
@@ -37,7 +36,6 @@ def _get_media_item(
return item
@bind_hass
async def async_browse_media(
hass: HomeAssistant,
media_content_id: str | None,
@@ -71,7 +69,6 @@ async def async_browse_media(
return item
@bind_hass
async def async_resolve_media(
hass: HomeAssistant,
media_content_id: str,
-3
View File
@@ -45,7 +45,6 @@ from homeassistant.helpers.dispatcher import (
from homeassistant.helpers.importlib import async_import_module
from homeassistant.helpers.start import async_at_started
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import bind_hass
from homeassistant.setup import SetupPhases, async_pause_setup
from homeassistant.util.collection import chunked_or_all
from homeassistant.util.logging import catch_log_exception, log_exception
@@ -221,7 +220,6 @@ def async_on_subscribe_done(
)
@bind_hass
async def async_subscribe(
hass: HomeAssistant,
topic: str,
@@ -273,7 +271,6 @@ def async_subscribe_internal(
return client.async_subscribe(topic, msg_callback, qos, encoding, job_type)
@bind_hass
def subscribe(
hass: HomeAssistant,
topic: str,
@@ -10,7 +10,6 @@ from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import config_validation as cv, issue_registry as ir
from homeassistant.helpers.typing import UNDEFINED, ConfigType, UndefinedType
from homeassistant.loader import bind_hass
from homeassistant.util import package
from . import util
@@ -42,7 +41,6 @@ def _check_docker_without_host_networking() -> bool:
return False
@bind_hass
async def async_get_adapters(hass: HomeAssistant) -> list[Adapter]:
"""Get the network adapter configuration."""
network: Network = await async_get_network(hass)
@@ -55,7 +53,6 @@ def async_get_loaded_adapters(hass: HomeAssistant) -> list[Adapter]:
return async_get_loaded_network(hass).adapters
@bind_hass
async def async_get_source_ip(
hass: HomeAssistant, target_ip: str | UndefinedType = UNDEFINED
) -> str:
@@ -90,7 +87,6 @@ async def async_get_source_ip(
return source_ip if source_ip in all_ipv4s else all_ipv4s[0]
@bind_hass
async def async_get_enabled_source_ips(
hass: HomeAssistant,
) -> list[IPv4Address | IPv6Address]:
@@ -128,7 +124,6 @@ def async_only_default_interface_enabled(adapters: list[Adapter]) -> bool:
)
@bind_hass
async def async_get_ipv4_broadcast_addresses(hass: HomeAssistant) -> set[IPv4Address]:
"""Return a set of broadcast addresses."""
broadcast_addresses: set[IPv4Address] = {IPv4Address(IPV4_BROADCAST_ADDR)}
+1 -3
View File
@@ -14,7 +14,7 @@ from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import discovery
from homeassistant.helpers.service import async_set_service_schema
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
from homeassistant.loader import async_get_integration, bind_hass
from homeassistant.loader import async_get_integration
from homeassistant.setup import (
SetupPhases,
async_prepare_setup_platform,
@@ -159,7 +159,6 @@ def async_setup_legacy(
]
@bind_hass
async def async_reload(hass: HomeAssistant, integration_name: str) -> None:
"""Register notify services for an integration."""
if not _async_integration_has_notify_services(hass, integration_name):
@@ -173,7 +172,6 @@ async def async_reload(hass: HomeAssistant, integration_name: str) -> None:
await asyncio.gather(*tasks)
@bind_hass
async def async_reset_platform(hass: HomeAssistant, integration_name: str) -> None:
"""Unregister notify services for an integration."""
notify_discovery_dispatcher = hass.data.get(NOTIFY_DISCOVERY_DISPATCHER)
@@ -10,7 +10,6 @@ from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.storage import Store
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import bind_hass
from . import views
from .const import (
@@ -64,7 +63,6 @@ class OnboardingStorage(Store[OnboardingStoreData]):
return old_data
@bind_hass
@callback
def async_is_onboarded(hass: HomeAssistant) -> bool:
"""Return if Home Assistant has been onboarded."""
@@ -72,7 +70,6 @@ def async_is_onboarded(hass: HomeAssistant) -> bool:
return data is None or data.onboarded is True
@bind_hass
@callback
def async_is_user_onboarded(hass: HomeAssistant) -> bool:
"""Return if a user has been created as part of onboarding."""
@@ -10,7 +10,6 @@ from homeassistant.components import frontend
from homeassistant.core import HomeAssistant
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import bind_hass
_LOGGER = logging.getLogger(__name__)
@@ -71,7 +70,6 @@ CONFIG_SCHEMA = vol.Schema(
)
@bind_hass
async def async_register_panel(
hass: HomeAssistant,
# The url to serve the panel
@@ -19,7 +19,6 @@ from homeassistant.helpers.dispatcher import (
async_dispatcher_send,
)
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import bind_hass
from homeassistant.util import dt as dt_util
from homeassistant.util.signal_type import SignalType
from homeassistant.util.uuid import random_uuid_hex
@@ -75,7 +74,6 @@ def async_register_callback(
)
@bind_hass
def create(
hass: HomeAssistant,
message: str,
@@ -86,14 +84,12 @@ def create(
hass.add_job(async_create, hass, message, title, notification_id)
@bind_hass
def dismiss(hass: HomeAssistant, notification_id: str) -> None:
"""Remove a notification."""
hass.add_job(async_dismiss, hass, notification_id)
@callback
@bind_hass
def async_create(
hass: HomeAssistant,
message: str,
@@ -127,7 +123,6 @@ def _async_get_or_create_notifications(hass: HomeAssistant) -> dict[str, Notific
@callback
@bind_hass
def async_dismiss(hass: HomeAssistant, notification_id: str) -> None:
"""Remove a notification."""
notifications = _async_get_or_create_notifications(hass)
@@ -52,7 +52,6 @@ from homeassistant.helpers.event import async_track_state_change_event
from homeassistant.helpers.restore_state import RestoreEntity
from homeassistant.helpers.storage import Store
from homeassistant.helpers.typing import ConfigType, VolDictType
from homeassistant.loader import bind_hass
from .const import DOMAIN
@@ -93,7 +92,6 @@ CONFIG_SCHEMA = vol.Schema(
)
@bind_hass
async def async_create_person(
hass: HomeAssistant,
name: str,
@@ -111,7 +109,6 @@ async def async_create_person(
)
@bind_hass
async def async_add_user_device_tracker(
hass: HomeAssistant, user_id: str, device_tracker_entity_id: str
) -> None:
@@ -35,7 +35,6 @@ from homeassistant.core import (
from homeassistant.exceptions import HomeAssistantError, ServiceValidationError
from homeassistant.helpers.service import async_set_service_schema
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import bind_hass
from homeassistant.util import dt as dt_util, raise_if_invalid_filename
from homeassistant.util.yaml.loader import load_yaml_dict
@@ -195,7 +194,6 @@ def guarded_inplacevar(op: str, target: Any, operand: Any) -> Any:
return op_fun(target, operand)
@bind_hass
def execute_script(
hass: HomeAssistant,
name: str,
@@ -210,7 +208,6 @@ def execute_script(
return execute(hass, filename, source, data, return_response=return_response)
@bind_hass
def execute(
hass: HomeAssistant,
filename: str,
@@ -25,7 +25,6 @@ from homeassistant.helpers.integration_platform import (
)
from homeassistant.helpers.recorder import DATA_INSTANCE
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import bind_hass
from homeassistant.util.event_type import EventType
# Pre-import backup to avoid it being imported
@@ -128,7 +127,6 @@ CONFIG_SCHEMA = vol.Schema(
)
@bind_hass
def is_entity_recorded(hass: HomeAssistant, entity_id: str) -> bool:
"""Check if an entity is being recorded.
@@ -25,7 +25,6 @@ from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.entity import ToggleEntity, ToggleEntityDescription
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import bind_hass
from homeassistant.util.hass_dict import HassKey
_LOGGER = logging.getLogger(__name__)
@@ -73,7 +72,6 @@ REMOTE_SERVICE_ACTIVITY_SCHEMA = cv.make_entity_service_schema(
)
@bind_hass
def is_on(hass: HomeAssistant, entity_id: str) -> bool:
"""Return if the remote is on based on the statemachine."""
return hass.states.is_state(entity_id, STATE_ON)
@@ -65,7 +65,6 @@ from homeassistant.helpers.script import (
from homeassistant.helpers.service import async_set_service_schema
from homeassistant.helpers.trace import trace_get, trace_path
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import bind_hass
from homeassistant.util.async_ import create_eager_task
from homeassistant.util.dt import parse_datetime
@@ -91,7 +90,6 @@ SCRIPT_TURN_ONOFF_SCHEMA = make_entity_service_schema(
RELOAD_SERVICE_SCHEMA = vol.Schema({})
@bind_hass
def is_on(hass: HomeAssistant, entity_id: str) -> bool:
"""Return if the script is on based on the statemachine."""
return hass.states.is_state(entity_id, STATE_ON)
+1 -5
View File
@@ -10,7 +10,7 @@ from homeassistant.core import HassJob, HomeAssistant
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.service_info.ssdp import SsdpServiceInfo as _SsdpServiceInfo
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import async_get_ssdp, bind_hass
from homeassistant.loader import async_get_ssdp
from homeassistant.util.logging import catch_log_exception
from . import websocket_api
@@ -45,7 +45,6 @@ def _format_err(name: str, *args: Any) -> str:
return f"Exception in SSDP callback {name}: {args}"
@bind_hass
async def async_register_callback(
hass: HomeAssistant,
callback: Callable[
@@ -68,7 +67,6 @@ async def async_register_callback(
return await scanner.async_register_callback(job, match_dict)
@bind_hass
async def async_get_discovery_info_by_udn_st(
hass: HomeAssistant, udn: str, st: str
) -> _SsdpServiceInfo | None:
@@ -77,7 +75,6 @@ async def async_get_discovery_info_by_udn_st(
return await scanner.async_get_discovery_info_by_udn_st(udn, st)
@bind_hass
async def async_get_discovery_info_by_st(
hass: HomeAssistant, st: str
) -> list[_SsdpServiceInfo]:
@@ -86,7 +83,6 @@ async def async_get_discovery_info_by_st(
return await scanner.async_get_discovery_info_by_st(st)
@bind_hass
async def async_get_discovery_info_by_udn(
hass: HomeAssistant, udn: str
) -> list[_SsdpServiceInfo]:
@@ -21,7 +21,6 @@ from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.entity import ToggleEntity, ToggleEntityDescription
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import bind_hass
from homeassistant.util.hass_dict import HassKey
from .const import DOMAIN
@@ -51,7 +50,6 @@ DEVICE_CLASSES = [cls.value for cls in SwitchDeviceClass]
# mypy: disallow-any-generics
@bind_hass
def is_on(hass: HomeAssistant, entity_id: str) -> bool:
"""Return if the switch is on based on the statemachine.
@@ -20,7 +20,6 @@ from homeassistant.helpers import (
integration_platform,
)
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import bind_hass
_LOGGER = logging.getLogger(__name__)
@@ -40,7 +39,6 @@ class SystemHealthProtocol(Protocol):
"""Register system health callbacks."""
@bind_hass
@callback
def async_register_info(
hass: HomeAssistant,
@@ -31,7 +31,6 @@ from homeassistant.helpers.entity_platform import EntityPlatform
from homeassistant.helpers.frame import ReportBehavior, report_usage
from homeassistant.helpers.icon import icon_for_battery_level
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import bind_hass
from .const import DATA_COMPONENT, DOMAIN, VacuumActivity, VacuumEntityFeature
from .websocket import async_register_websocket_handlers
@@ -71,7 +70,6 @@ _BATTERY_DEPRECATION_IGNORED_PLATFORMS = ("template",)
# mypy: disallow-any-generics
@bind_hass
def is_on(hass: HomeAssistant, entity_id: str) -> bool:
"""Return if the vacuum is on based on the statemachine."""
return hass.states.is_state(entity_id, STATE_ON)
@@ -20,7 +20,6 @@ from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.network import get_url, is_cloud_connection
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import bind_hass
from homeassistant.util import network as network_util
from homeassistant.util.aiohttp import MockRequest, MockStreamReader, serialize_response
@@ -36,7 +35,6 @@ CONFIG_SCHEMA = cv.empty_config_schema(DOMAIN)
@callback
@bind_hass
def async_register(
hass: HomeAssistant,
domain: str,
@@ -72,7 +70,6 @@ def async_register(
@callback
@bind_hass
def async_unregister(hass: HomeAssistant, webhook_id: str) -> None:
"""Remove a webhook."""
handlers = hass.data.setdefault(DOMAIN, {})
@@ -86,7 +83,6 @@ def async_generate_id() -> str:
@callback
@bind_hass
def async_generate_url(
hass: HomeAssistant,
webhook_id: str,
@@ -117,7 +113,6 @@ def async_generate_path(webhook_id: str) -> str:
return URL_WEBHOOK_PATH.format(webhook_id=webhook_id)
@bind_hass
async def async_handle_webhook(
hass: HomeAssistant, webhook_id: str, request: Request | MockRequest
) -> Response:
@@ -7,7 +7,6 @@ from typing import Final, cast
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.typing import ConfigType, VolSchemaType
from homeassistant.loader import bind_hass
from . import commands, connection, const, decorators, http, messages # noqa: F401
from .connection import ActiveConnection, current_connection # noqa: F401
@@ -47,7 +46,6 @@ DEPENDENCIES: Final[tuple[str]] = ("http",)
CONFIG_SCHEMA = cv.empty_config_schema(DOMAIN)
@bind_hass
@callback
def async_register_command(
hass: HomeAssistant,
@@ -22,7 +22,7 @@ from homeassistant.core import Event, HomeAssistant, callback
from homeassistant.helpers import config_validation as cv, instance_id
from homeassistant.helpers.network import NoURLAvailableError, get_url
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import async_get_homekit, async_get_zeroconf, bind_hass
from homeassistant.loader import async_get_homekit, async_get_zeroconf
from homeassistant.setup import async_when_setup_or_start
from . import websocket_api
@@ -68,13 +68,11 @@ CONFIG_SCHEMA = vol.Schema(
)
@bind_hass
async def async_get_instance(hass: HomeAssistant) -> HaZeroconf:
"""Get or create the shared HaZeroconf instance."""
return cast(HaZeroconf, (_async_get_instance(hass)).zeroconf)
@bind_hass
async def async_get_async_instance(hass: HomeAssistant) -> HaAsyncZeroconf:
"""Get or create the shared HaAsyncZeroconf instance."""
return _async_get_instance(hass)
@@ -46,7 +46,6 @@ from homeassistant.helpers import (
storage,
)
from homeassistant.helpers.typing import ConfigType, VolDictType
from homeassistant.loader import bind_hass
from homeassistant.util.hass_dict import HassKey
from homeassistant.util.location import distance
@@ -183,7 +182,6 @@ def async_in_zones(
return (closest, [itm[0] for itm in zones])
@bind_hass
def async_active_zone(
hass: HomeAssistant, latitude: float, longitude: float, radius: float = 0
) -> State | None:
-5
View File
@@ -24,7 +24,6 @@ from homeassistant import config_entries
from homeassistant.components import zeroconf
from homeassistant.const import APPLICATION_NAME, EVENT_HOMEASSISTANT_CLOSE, __version__
from homeassistant.core import Event, HomeAssistant, callback
from homeassistant.loader import bind_hass
from homeassistant.util import ssl as ssl_util
from homeassistant.util.hass_dict import HassKey
from homeassistant.util.json import json_loads
@@ -214,7 +213,6 @@ class ChunkAsyncStreamIterator:
@callback
@bind_hass
def async_get_clientsession(
hass: HomeAssistant,
verify_ssl: bool = True,
@@ -244,7 +242,6 @@ def async_get_clientsession(
@callback
@bind_hass
def async_create_clientsession(
hass: HomeAssistant,
verify_ssl: bool = True,
@@ -318,7 +315,6 @@ def _async_create_clientsession(
return clientsession
@bind_hass
async def async_aiohttp_proxy_web(
hass: HomeAssistant,
request: web.BaseRequest,
@@ -351,7 +347,6 @@ async def async_aiohttp_proxy_web(
req.close()
@bind_hass
async def async_aiohttp_proxy_stream(
hass: HomeAssistant,
request: web.BaseRequest,
-7
View File
@@ -13,7 +13,6 @@ from typing import Any, TypedDict
from homeassistant import core, setup
from homeassistant.const import Platform
from homeassistant.loader import bind_hass
from homeassistant.util.signal_type import SignalTypeFormat
from .dispatcher import async_dispatcher_connect, async_dispatcher_send_internal
@@ -36,7 +35,6 @@ class DiscoveryDict(TypedDict):
@core.callback
@bind_hass
def async_listen(
hass: core.HomeAssistant,
service: str,
@@ -62,7 +60,6 @@ def async_listen(
)
@bind_hass
def discover(
hass: core.HomeAssistant,
service: str,
@@ -77,7 +74,6 @@ def discover(
)
@bind_hass
async def async_discover(
hass: core.HomeAssistant,
service: str,
@@ -100,7 +96,6 @@ async def async_discover(
)
@bind_hass
def async_listen_platform(
hass: core.HomeAssistant,
component: str,
@@ -127,7 +122,6 @@ def async_listen_platform(
)
@bind_hass
def load_platform(
hass: core.HomeAssistant,
component: Platform | str,
@@ -142,7 +136,6 @@ def load_platform(
)
@bind_hass
async def async_load_platform(
hass: core.HomeAssistant,
component: Platform | str,
-2
View File
@@ -8,7 +8,6 @@ from typing import TYPE_CHECKING, Any, NamedTuple, Self
from homeassistant.const import EVENT_HOMEASSISTANT_STARTED
from homeassistant.core import CoreState, Event, HomeAssistant, callback
from homeassistant.loader import bind_hass
from homeassistant.util.async_ import gather_with_limited_concurrency
from homeassistant.util.hass_dict import HassKey
@@ -37,7 +36,6 @@ class DiscoveryKey:
return cls(domain=json_dict["domain"], key=key, version=json_dict["version"])
@bind_hass
@callback
def async_create_flow(
hass: HomeAssistant,
+2 -16
View File
@@ -15,7 +15,6 @@ from homeassistant.core import (
callback,
get_hassjob_callable_job_type,
)
from homeassistant.loader import bind_hass
from homeassistant.util.async_ import run_callback_threadsafe
from homeassistant.util.logging import catch_log_exception, log_exception
@@ -36,21 +35,18 @@ type _DispatcherDataType[*_Ts] = dict[
@overload
@bind_hass
def dispatcher_connect[*_Ts](
hass: HomeAssistant, signal: SignalType[*_Ts], target: Callable[[*_Ts], None]
) -> Callable[[], None]: ...
@overload
@bind_hass
def dispatcher_connect(
hass: HomeAssistant, signal: str, target: Callable[..., None]
) -> Callable[[], None]: ...
@bind_hass # type: ignore[misc] # workaround; exclude typing of 2 overload in func def
def dispatcher_connect[*_Ts](
def dispatcher_connect[*_Ts]( # type: ignore[misc]
hass: HomeAssistant,
signal: SignalType[*_Ts],
target: Callable[[*_Ts], None],
@@ -89,7 +85,6 @@ def _async_remove_dispatcher[*_Ts](
@overload
@callback
@bind_hass
def async_dispatcher_connect[*_Ts](
hass: HomeAssistant, signal: SignalType[*_Ts], target: Callable[[*_Ts], Any]
) -> Callable[[], None]: ...
@@ -97,14 +92,12 @@ def async_dispatcher_connect[*_Ts](
@overload
@callback
@bind_hass
def async_dispatcher_connect(
hass: HomeAssistant, signal: str, target: Callable[..., Any]
) -> Callable[[], None]: ...
@callback
@bind_hass
def async_dispatcher_connect[*_Ts](
hass: HomeAssistant,
signal: SignalType[*_Ts] | str,
@@ -126,19 +119,16 @@ def async_dispatcher_connect[*_Ts](
@overload
@bind_hass
def dispatcher_send[*_Ts](
hass: HomeAssistant, signal: SignalType[*_Ts], *args: *_Ts
) -> None: ...
@overload
@bind_hass
def dispatcher_send(hass: HomeAssistant, signal: str, *args: Any) -> None: ...
@bind_hass # type: ignore[misc] # workaround; exclude typing of 2 overload in func def
def dispatcher_send[*_Ts](
def dispatcher_send[*_Ts]( # type: ignore[misc]
hass: HomeAssistant, signal: SignalType[*_Ts], *args: *_Ts
) -> None:
"""Send signal and data."""
@@ -181,7 +171,6 @@ def _generate_job[*_Ts](
@overload
@callback
@bind_hass
def async_dispatcher_send[*_Ts](
hass: HomeAssistant, signal: SignalType[*_Ts], *args: *_Ts
) -> None: ...
@@ -189,12 +178,10 @@ def async_dispatcher_send[*_Ts](
@overload
@callback
@bind_hass
def async_dispatcher_send(hass: HomeAssistant, signal: str, *args: Any) -> None: ...
@callback
@bind_hass
def async_dispatcher_send[*_Ts](
hass: HomeAssistant, signal: SignalType[*_Ts] | str, *args: *_Ts
) -> None:
@@ -216,7 +203,6 @@ def async_dispatcher_send[*_Ts](
@callback
@bind_hass
def async_dispatcher_send_internal[*_Ts](
hass: HomeAssistant, signal: SignalType[*_Ts] | str, *args: *_Ts
) -> None:
+1 -2
View File
@@ -50,7 +50,7 @@ from homeassistant.core import (
)
from homeassistant.core_config import DATA_CUSTOMIZE
from homeassistant.exceptions import HomeAssistantError, NoEntitySpecifiedError
from homeassistant.loader import async_suggest_report_issue, bind_hass
from homeassistant.loader import async_suggest_report_issue
from homeassistant.util import ensure_unique_string, slugify
from homeassistant.util.frozen_dataclass_compat import FrozenOrThawed
@@ -91,7 +91,6 @@ def async_setup(hass: HomeAssistant) -> None:
@callback
@bind_hass
@singleton(DATA_ENTITY_SOURCE)
def entity_sources(hass: HomeAssistant) -> dict[str, EntityInfo]:
"""Get the entity sources.
+1 -2
View File
@@ -29,7 +29,7 @@ from homeassistant.exceptions import (
HomeAssistantError,
ServiceValidationError,
)
from homeassistant.loader import async_get_integration, bind_hass
from homeassistant.loader import async_get_integration
from homeassistant.setup import async_prepare_setup_platform
from homeassistant.util.hass_dict import HassKey
@@ -41,7 +41,6 @@ DEFAULT_SCAN_INTERVAL = timedelta(seconds=15)
DATA_INSTANCES: HassKey[dict[str, EntityComponent]] = HassKey("entity_components")
@bind_hass
async def async_update_entity(hass: HomeAssistant, entity_id: str) -> None:
"""Trigger an update for an entity."""
domain = entity_id.partition(".")[0]
-21
View File
@@ -37,7 +37,6 @@ from homeassistant.core import (
split_entity_id,
)
from homeassistant.exceptions import HomeAssistantError, TemplateError
from homeassistant.loader import bind_hass
from homeassistant.util import dt as dt_util
from homeassistant.util.async_ import run_callback_threadsafe
from homeassistant.util.event_type import EventType
@@ -199,7 +198,6 @@ def threaded_listener_factory[**_P](
@callback
@bind_hass
def async_track_state_change(
hass: HomeAssistant,
entity_ids: str | Iterable[str],
@@ -305,7 +303,6 @@ def async_track_state_change(
track_state_change = threaded_listener_factory(async_track_state_change)
@bind_hass
def async_track_state_change_event(
hass: HomeAssistant,
entity_ids: str | Iterable[str],
@@ -384,7 +381,6 @@ _KEYED_TRACK_STATE_CHANGE = _KeyedEventTracker(
)
@bind_hass
def _async_track_state_change_event(
hass: HomeAssistant,
entity_ids: str | Iterable[str],
@@ -537,7 +533,6 @@ _KEYED_TRACK_ENTITY_REGISTRY_UPDATED = _KeyedEventTracker(
)
@bind_hass
@callback
def async_track_entity_registry_updated_event(
hass: HomeAssistant,
@@ -649,7 +644,6 @@ def _async_domain_added_filter(
)
@bind_hass
def async_track_state_added_domain(
hass: HomeAssistant,
domains: str | Iterable[str],
@@ -670,7 +664,6 @@ _KEYED_TRACK_STATE_ADDED_DOMAIN = _KeyedEventTracker(
)
@bind_hass
def _async_track_state_added_domain(
hass: HomeAssistant,
domains: str | Iterable[str],
@@ -707,7 +700,6 @@ _KEYED_TRACK_STATE_REMOVED_DOMAIN = _KeyedEventTracker(
)
@bind_hass
def async_track_state_removed_domain(
hass: HomeAssistant,
domains: str | Iterable[str],
@@ -863,7 +855,6 @@ class _TrackStateChangeFiltered:
@callback
@bind_hass
def async_track_state_change_filtered(
hass: HomeAssistant,
track_states: TrackStates,
@@ -894,7 +885,6 @@ def async_track_state_change_filtered(
@callback
@bind_hass
def async_track_template(
hass: HomeAssistant,
template: Template,
@@ -1339,7 +1329,6 @@ type TrackTemplateResultListener = Callable[
@callback
@bind_hass
def async_track_template_result(
hass: HomeAssistant,
track_templates: Sequence[TrackTemplate],
@@ -1392,7 +1381,6 @@ def async_track_template_result(
@callback
@bind_hass
def async_track_same_state(
hass: HomeAssistant,
period: timedelta,
@@ -1460,7 +1448,6 @@ track_same_state = threaded_listener_factory(async_track_same_state)
@callback
@bind_hass
def async_track_point_in_time(
hass: HomeAssistant,
action: HassJob[[datetime], Coroutine[Any, Any, None] | None]
@@ -1540,7 +1527,6 @@ class _TrackPointUTCTime:
@callback
@bind_hass
def async_track_point_in_utc_time(
hass: HomeAssistant,
action: HassJob[[datetime], Coroutine[Any, Any, None] | None]
@@ -1575,7 +1561,6 @@ def _run_async_call_action(
@callback
@bind_hass
def async_call_at(
hass: HomeAssistant,
action: HassJob[[datetime], Coroutine[Any, Any, None] | None]
@@ -1595,7 +1580,6 @@ def async_call_at(
@callback
@bind_hass
def async_call_later(
hass: HomeAssistant,
delay: float | timedelta,
@@ -1675,7 +1659,6 @@ class _TrackTimeInterval:
@callback
@bind_hass
def async_track_time_interval(
hass: HomeAssistant,
action: Callable[[datetime], Coroutine[Any, Any, None] | None],
@@ -1761,7 +1744,6 @@ class SunListener:
@callback
@bind_hass
def async_track_sunrise(
hass: HomeAssistant, action: Callable[[], None], offset: timedelta | None = None
) -> CALLBACK_TYPE:
@@ -1777,7 +1759,6 @@ track_sunrise = threaded_listener_factory(async_track_sunrise)
@callback
@bind_hass
def async_track_sunset(
hass: HomeAssistant, action: Callable[[], None], offset: timedelta | None = None
) -> CALLBACK_TYPE:
@@ -1853,7 +1834,6 @@ class _TrackUTCTimeChange:
@callback
@bind_hass
def async_track_utc_time_change(
hass: HomeAssistant,
action: Callable[[datetime], Coroutine[Any, Any, None] | None],
@@ -1901,7 +1881,6 @@ track_utc_time_change = threaded_listener_factory(async_track_utc_time_change)
@callback
@bind_hass
def async_track_time_change(
hass: HomeAssistant,
action: Callable[[datetime], Coroutine[Any, Any, None] | None],
-2
View File
@@ -14,7 +14,6 @@ import httpx
from homeassistant.const import APPLICATION_NAME, EVENT_HOMEASSISTANT_CLOSE, __version__
from homeassistant.core import Event, HomeAssistant, callback
from homeassistant.loader import bind_hass
from homeassistant.util.hass_dict import HassKey
from homeassistant.util.ssl import (
SSL_ALPN_HTTP11,
@@ -44,7 +43,6 @@ USER_AGENT = "User-Agent"
@callback
@bind_hass
def get_async_client(
hass: HomeAssistant,
verify_ssl: bool = True,
@@ -17,7 +17,6 @@ from homeassistant.loader import (
async_get_integrations,
async_get_loaded_integration,
async_register_preload_platform,
bind_hass,
)
from homeassistant.setup import ATTR_COMPONENT, EventComponentLoaded
from homeassistant.util.hass_dict import HassKey
@@ -153,7 +152,6 @@ def _format_err(name: str, platform_name: str, *args: Any) -> str:
return f"Exception in {name} when processing platform '{platform_name}': {args}"
@bind_hass
async def async_process_integration_platforms(
hass: HomeAssistant,
platform_name: str,
-5
View File
@@ -23,7 +23,6 @@ from homeassistant.const import (
)
from homeassistant.core import Context, HomeAssistant, State, callback
from homeassistant.exceptions import HomeAssistantError
from homeassistant.loader import bind_hass
from homeassistant.util.hass_dict import HassKey
from . import (
@@ -72,7 +71,6 @@ SPEECH_TYPE_SSML = "ssml"
@callback
@bind_hass
def async_register(hass: HomeAssistant, handler: IntentHandler) -> None:
"""Register an intent with Home Assistant."""
if (intents := hass.data.get(DATA_KEY)) is None:
@@ -90,7 +88,6 @@ def async_register(hass: HomeAssistant, handler: IntentHandler) -> None:
@callback
@bind_hass
def async_remove(hass: HomeAssistant, intent_type: str) -> None:
"""Remove an intent from Home Assistant."""
if (intents := hass.data.get(DATA_KEY)) is None:
@@ -105,7 +102,6 @@ def async_get(hass: HomeAssistant) -> Iterable[IntentHandler]:
return hass.data.get(DATA_KEY, {}).values()
@bind_hass
async def async_handle(
hass: HomeAssistant,
platform: str,
@@ -774,7 +770,6 @@ def async_match_targets( # noqa: C901
@callback
@bind_hass
def async_match_states(
hass: HomeAssistant,
name: str | None = None,
-7
View File
@@ -12,7 +12,6 @@ import yarl
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
from homeassistant.loader import bind_hass
from homeassistant.util.network import is_ip_address, is_loopback, normalize_url
from . import http
@@ -27,7 +26,6 @@ class NoURLAvailableError(HomeAssistantError):
"""An URL to the Home Assistant instance is not available."""
@bind_hass
def is_internal_request(hass: HomeAssistant) -> bool:
"""Test if the current request is internal."""
try:
@@ -39,7 +37,6 @@ def is_internal_request(hass: HomeAssistant) -> bool:
return True
@bind_hass
def get_supervisor_network_url(
hass: HomeAssistant, *, allow_ssl: bool = False
) -> str | None:
@@ -114,7 +111,6 @@ def is_hass_url(hass: HomeAssistant, url: str) -> bool:
return False
@bind_hass
def get_url(
hass: HomeAssistant,
*,
@@ -229,7 +225,6 @@ def _get_request_host() -> str | None:
return host
@bind_hass
def _get_internal_url(
hass: HomeAssistant,
*,
@@ -267,7 +262,6 @@ def _get_internal_url(
raise NoURLAvailableError
@bind_hass
def _get_external_url(
hass: HomeAssistant,
*,
@@ -312,7 +306,6 @@ def _get_external_url(
raise NoURLAvailableError
@bind_hass
def _get_cloud_url(hass: HomeAssistant, require_current_request: bool = False) -> str:
"""Get external Home Assistant Cloud URL of this instance."""
if "cloud" in hass.config.components:
+1 -9
View File
@@ -48,7 +48,7 @@ from homeassistant.exceptions import (
Unauthorized,
UnknownUser,
)
from homeassistant.loader import Integration, async_get_integrations, bind_hass
from homeassistant.loader import Integration, async_get_integrations
from homeassistant.util.async_ import create_eager_task
from homeassistant.util.hass_dict import HassKey
from homeassistant.util.yaml import load_yaml_dict
@@ -252,7 +252,6 @@ class SelectedEntities(target_helpers.SelectedEntities):
super().log_missing(missing_entities, logger or _LOGGER)
@bind_hass
def call_from_config(
hass: HomeAssistant,
config: ConfigType,
@@ -267,7 +266,6 @@ def call_from_config(
).result()
@bind_hass
async def async_call_from_config(
hass: HomeAssistant,
config: ConfigType,
@@ -290,7 +288,6 @@ async def async_call_from_config(
@callback
@bind_hass
def async_prepare_call_from_config(
hass: HomeAssistant,
config: ConfigType,
@@ -452,7 +449,6 @@ async def async_extract_entity_ids(
"homeassistant.helpers.target.async_extract_referenced_entity_ids",
breaks_in_ha_version="2026.8",
)
@bind_hass
def async_extract_referenced_entity_ids(
hass: HomeAssistant, service_call: ServiceCall, expand_group: bool = True
) -> SelectedEntities:
@@ -532,7 +528,6 @@ def async_get_cached_service_description(
return hass.data.get(SERVICE_DESCRIPTION_CACHE, {}).get((domain, service))
@bind_hass
async def async_get_all_descriptions(
hass: HomeAssistant,
) -> dict[str, dict[str, Any]]:
@@ -647,7 +642,6 @@ def remove_entity_service_fields(call: ServiceCall) -> dict[Any, Any]:
@callback
@bind_hass
def async_set_service_schema(
hass: HomeAssistant, domain: str, service: str, schema: dict[str, Any]
) -> None:
@@ -724,7 +718,6 @@ def _get_permissible_entity_candidates(
return [entities[entity_id] for entity_id in all_referenced.intersection(entities)]
@bind_hass
async def entity_service_call(
hass: HomeAssistant,
registered_entities: dict[str, Entity] | Callable[[], dict[str, Entity]],
@@ -944,7 +937,6 @@ async def _async_admin_handler(
return None
@bind_hass
@callback
def async_register_admin_service(
hass: HomeAssistant,
-2
View File
@@ -6,7 +6,6 @@ import signal
from homeassistant.const import RESTART_EXIT_CODE
from homeassistant.core import HomeAssistant, callback
from homeassistant.loader import bind_hass
from homeassistant.util.hass_dict import HassKey
_LOGGER = logging.getLogger(__name__)
@@ -15,7 +14,6 @@ KEY_HA_STOP: HassKey[asyncio.Task[None]] = HassKey("homeassistant_stop")
@callback
@bind_hass
def async_register_signal_handling(hass: HomeAssistant) -> None:
"""Register system signal handler for core."""
-3
View File
@@ -9,7 +9,6 @@ import inspect
from typing import Any, Literal, assert_type, cast, overload
from homeassistant.core import HomeAssistant
from homeassistant.loader import bind_hass
from homeassistant.util.hass_dict import HassKey
type _FuncType[_T] = Callable[[HomeAssistant], _T]
@@ -51,7 +50,6 @@ def singleton[_S, _T, _U](
if not inspect.iscoroutinefunction(func):
@functools.lru_cache(maxsize=1)
@bind_hass
@functools.wraps(func)
def wrapped(hass: HomeAssistant) -> _U:
if data_key not in hass.data:
@@ -60,7 +58,6 @@ def singleton[_S, _T, _U](
return wrapped
@bind_hass
@functools.wraps(func)
async def async_wrapped(hass: HomeAssistant) -> _T:
if data_key not in hass.data:
+1 -2
View File
@@ -21,12 +21,11 @@ from homeassistant.const import (
STATE_UNKNOWN,
)
from homeassistant.core import Context, HomeAssistant, State
from homeassistant.loader import IntegrationNotFound, async_get_integration, bind_hass
from homeassistant.loader import IntegrationNotFound, async_get_integration
_LOGGER = logging.getLogger(__name__)
@bind_hass
async def async_reproduce_state(
hass: HomeAssistant,
states: State | Iterable[State],
-3
View File
@@ -29,7 +29,6 @@ from homeassistant.core import (
callback,
)
from homeassistant.exceptions import HomeAssistantError, UnsupportedStorageVersionError
from homeassistant.loader import bind_hass
from homeassistant.util import dt as dt_util, json as json_util
from homeassistant.util.file import WriteError, write_utf8_file, write_utf8_file_atomic
from homeassistant.util.hass_dict import HassKey
@@ -49,7 +48,6 @@ STORAGE_MANAGER: HassKey[_StoreManager] = HassKey("storage_manager")
MANAGER_CLEANUP_DELAY = 60
@bind_hass
async def async_migrator[_T: Mapping[str, Any] | Sequence[Any]](
hass: HomeAssistant,
old_path: str,
@@ -226,7 +224,6 @@ class _StoreManager:
self._files = set(os.listdir(self._storage_path))
@bind_hass
class Store[_T: Mapping[str, Any] | Sequence[Any]]:
"""Class to help storing data."""
-5
View File
@@ -8,7 +8,6 @@ from typing import TYPE_CHECKING, Any, cast
from homeassistant.const import SUN_EVENT_SUNRISE, SUN_EVENT_SUNSET
from homeassistant.core import HomeAssistant, callback
from homeassistant.loader import bind_hass
from homeassistant.util import dt as dt_util
from homeassistant.util.hass_dict import HassKey
@@ -26,7 +25,6 @@ type _AstralSunEventCallable = Callable[..., datetime.datetime]
@callback
@bind_hass
def get_astral_location(
hass: HomeAssistant,
) -> tuple[astral.location.Location, astral.Elevation]:
@@ -51,7 +49,6 @@ def get_astral_location(
@callback
@bind_hass
def get_astral_event_next(
hass: HomeAssistant,
event: str,
@@ -109,7 +106,6 @@ def get_location_astral_event_next(
@callback
@bind_hass
def get_astral_event_date(
hass: HomeAssistant,
event: str,
@@ -136,7 +132,6 @@ def get_astral_event_date(
@callback
@bind_hass
def is_up(
hass: HomeAssistant, utc_point_in_time: datetime.datetime | None = None
) -> bool:
-2
View File
@@ -10,7 +10,6 @@ from typing import Any
from homeassistant.const import __version__ as current_version
from homeassistant.core import HomeAssistant
from homeassistant.loader import bind_hass
from homeassistant.util.package import is_docker_env, is_virtual_env
from homeassistant.util.system_info import is_official_image
@@ -50,7 +49,6 @@ async def async_get_container_arch(hass: HomeAssistant) -> str:
cached_get_user = cache(getuser)
@bind_hass
async def async_get_system_info(hass: HomeAssistant) -> dict[str, Any]:
"""Return info about the system."""
is_hassio_ = is_hassio(hass)
-2
View File
@@ -21,7 +21,6 @@ from homeassistant.loader import (
Integration,
async_get_config_flows,
async_get_integrations,
bind_hass,
)
from homeassistant.util.json import load_json
@@ -332,7 +331,6 @@ class _TranslationCache:
component_cache.update(flat)
@bind_hass
async def async_get_translations(
hass: HomeAssistant,
language: str,
-7
View File
@@ -32,7 +32,6 @@ from homeassistant.const import (
SERVICE_TURN_ON,
)
from homeassistant.core import HomeAssistant
from homeassistant.loader import bind_hass
async def async_set_preset_mode(
@@ -47,7 +46,6 @@ async def async_set_preset_mode(
await hass.services.async_call(DOMAIN, SERVICE_SET_PRESET_MODE, data, blocking=True)
@bind_hass
def set_preset_mode(
hass: HomeAssistant, preset_mode: str, entity_id: str = ENTITY_MATCH_ALL
) -> None:
@@ -86,7 +84,6 @@ async def async_set_temperature(
)
@bind_hass
def set_temperature(
hass: HomeAssistant,
temperature: float | None = None,
@@ -123,7 +120,6 @@ async def async_set_humidity(
await hass.services.async_call(DOMAIN, SERVICE_SET_HUMIDITY, data, blocking=True)
@bind_hass
def set_humidity(
hass: HomeAssistant, humidity: int, entity_id: str = ENTITY_MATCH_ALL
) -> None:
@@ -148,7 +144,6 @@ async def async_set_fan_mode(
await hass.services.async_call(DOMAIN, SERVICE_SET_FAN_MODE, data, blocking=True)
@bind_hass
def set_fan_mode(
hass: HomeAssistant, fan: str, entity_id: str = ENTITY_MATCH_ALL
) -> None:
@@ -173,7 +168,6 @@ async def async_set_hvac_mode(
await hass.services.async_call(DOMAIN, SERVICE_SET_HVAC_MODE, data, blocking=True)
@bind_hass
def set_operation_mode(
hass: HomeAssistant, hvac_mode: HVACMode, entity_id: str = ENTITY_MATCH_ALL
) -> None:
@@ -212,7 +206,6 @@ async def async_set_swing_mode(
await hass.services.async_call(DOMAIN, SERVICE_SET_SWING_MODE, data, blocking=True)
@bind_hass
def set_swing_mode(
hass: HomeAssistant, swing_mode: str, entity_id: str = ENTITY_MATCH_ALL
) -> None:
-4
View File
@@ -12,11 +12,9 @@ from homeassistant.components.counter import (
)
from homeassistant.const import ATTR_ENTITY_ID
from homeassistant.core import HomeAssistant, callback
from homeassistant.loader import bind_hass
@callback
@bind_hass
def async_increment(hass: HomeAssistant, entity_id: str) -> None:
"""Increment a counter."""
hass.async_create_task(
@@ -25,7 +23,6 @@ def async_increment(hass: HomeAssistant, entity_id: str) -> None:
@callback
@bind_hass
def async_decrement(hass: HomeAssistant, entity_id: str) -> None:
"""Decrement a counter."""
hass.async_create_task(
@@ -34,7 +31,6 @@ def async_decrement(hass: HomeAssistant, entity_id: str) -> None:
@callback
@bind_hass
def async_reset(hass: HomeAssistant, entity_id: str) -> None:
"""Reset a counter."""
hass.async_create_task(
@@ -21,13 +21,11 @@ from homeassistant.components.device_tracker import (
from homeassistant.const import ATTR_GPS_ACCURACY
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.typing import ConfigType, GPSType
from homeassistant.loader import bind_hass
from tests.common import MockPlatform, mock_platform
@callback
@bind_hass
def async_see(
hass: HomeAssistant,
mac: str | None = None,
-6
View File
@@ -14,23 +14,19 @@ from homeassistant.components.group import (
)
from homeassistant.const import ATTR_ICON, ATTR_NAME, SERVICE_RELOAD
from homeassistant.core import HomeAssistant, callback
from homeassistant.loader import bind_hass
@bind_hass
def reload(hass: HomeAssistant) -> None:
"""Reload the automation from config."""
hass.add_job(async_reload, hass)
@callback
@bind_hass
def async_reload(hass: HomeAssistant) -> None:
"""Reload the automation from config."""
hass.async_create_task(hass.services.async_call(DOMAIN, SERVICE_RELOAD))
@bind_hass
def set_group(
hass: HomeAssistant,
object_id: str,
@@ -52,7 +48,6 @@ def set_group(
@callback
@bind_hass
def async_set_group(
hass: HomeAssistant,
object_id: str,
@@ -78,7 +73,6 @@ def async_set_group(
@callback
@bind_hass
def async_remove(hass: HomeAssistant, object_id: str) -> None:
"""Remove a user group."""
data = {ATTR_OBJECT_ID: object_id}
@@ -7,17 +7,14 @@ components. Instead call the service directly.
from homeassistant.components.image_processing import DOMAIN, SERVICE_SCAN
from homeassistant.const import ATTR_ENTITY_ID, ENTITY_MATCH_ALL
from homeassistant.core import HomeAssistant, callback
from homeassistant.loader import bind_hass
@bind_hass
def scan(hass: HomeAssistant, entity_id: str = ENTITY_MATCH_ALL) -> None:
"""Force process of all cameras or given entity."""
hass.add_job(async_scan, hass, entity_id)
@callback
@bind_hass
def async_scan(hass: HomeAssistant, entity_id: str = ENTITY_MATCH_ALL) -> None:
"""Force process of all cameras or given entity."""
data = {ATTR_ENTITY_ID: entity_id} if entity_id else None
-18
View File
@@ -37,7 +37,6 @@ from homeassistant.const import (
SERVICE_VOLUME_UP,
)
from homeassistant.core import HomeAssistant
from homeassistant.loader import bind_hass
async def async_turn_on(hass: HomeAssistant, entity_id: str = ENTITY_MATCH_ALL) -> None:
@@ -46,7 +45,6 @@ async def async_turn_on(hass: HomeAssistant, entity_id: str = ENTITY_MATCH_ALL)
await hass.services.async_call(DOMAIN, SERVICE_TURN_ON, data, blocking=True)
@bind_hass
def turn_on(hass: HomeAssistant, entity_id: str = ENTITY_MATCH_ALL) -> None:
"""Turn on specified media player or all."""
hass.add_job(async_turn_on, hass, entity_id)
@@ -60,7 +58,6 @@ async def async_turn_off(
await hass.services.async_call(DOMAIN, SERVICE_TURN_OFF, data, blocking=True)
@bind_hass
def turn_off(hass: HomeAssistant, entity_id: str = ENTITY_MATCH_ALL) -> None:
"""Turn off specified media player or all."""
hass.add_job(async_turn_off, hass, entity_id)
@@ -72,7 +69,6 @@ async def async_toggle(hass: HomeAssistant, entity_id: str = ENTITY_MATCH_ALL) -
await hass.services.async_call(DOMAIN, SERVICE_TOGGLE, data, blocking=True)
@bind_hass
def toggle(hass: HomeAssistant, entity_id: str = ENTITY_MATCH_ALL) -> None:
"""Toggle specified media player or all."""
hass.add_job(async_toggle, hass, entity_id)
@@ -86,7 +82,6 @@ async def async_volume_up(
await hass.services.async_call(DOMAIN, SERVICE_VOLUME_UP, data, blocking=True)
@bind_hass
def volume_up(hass: HomeAssistant, entity_id: str = ENTITY_MATCH_ALL) -> None:
"""Send the media player the command for volume up."""
hass.add_job(async_volume_up, hass, entity_id)
@@ -100,7 +95,6 @@ async def async_volume_down(
await hass.services.async_call(DOMAIN, SERVICE_VOLUME_DOWN, data, blocking=True)
@bind_hass
def volume_down(hass: HomeAssistant, entity_id: str = ENTITY_MATCH_ALL) -> None:
"""Send the media player the command for volume down."""
hass.add_job(async_volume_down, hass, entity_id)
@@ -118,7 +112,6 @@ async def async_mute_volume(
await hass.services.async_call(DOMAIN, SERVICE_VOLUME_MUTE, data, blocking=True)
@bind_hass
def mute_volume(
hass: HomeAssistant, mute: bool, entity_id: str = ENTITY_MATCH_ALL
) -> None:
@@ -138,7 +131,6 @@ async def async_set_volume_level(
await hass.services.async_call(DOMAIN, SERVICE_VOLUME_SET, data, blocking=True)
@bind_hass
def set_volume_level(
hass: HomeAssistant, volume: float, entity_id: str = ENTITY_MATCH_ALL
) -> None:
@@ -156,7 +148,6 @@ async def async_media_play_pause(
)
@bind_hass
def media_play_pause(hass: HomeAssistant, entity_id: str = ENTITY_MATCH_ALL) -> None:
"""Send the media player the command for play/pause."""
hass.add_job(async_media_play_pause, hass, entity_id)
@@ -170,7 +161,6 @@ async def async_media_play(
await hass.services.async_call(DOMAIN, SERVICE_MEDIA_PLAY, data, blocking=True)
@bind_hass
def media_play(hass: HomeAssistant, entity_id: str = ENTITY_MATCH_ALL) -> None:
"""Send the media player the command for play/pause."""
hass.add_job(async_media_play, hass, entity_id)
@@ -184,7 +174,6 @@ async def async_media_pause(
await hass.services.async_call(DOMAIN, SERVICE_MEDIA_PAUSE, data, blocking=True)
@bind_hass
def media_pause(hass: HomeAssistant, entity_id: str = ENTITY_MATCH_ALL) -> None:
"""Send the media player the command for pause."""
hass.add_job(async_media_pause, hass, entity_id)
@@ -198,7 +187,6 @@ async def async_media_stop(
await hass.services.async_call(DOMAIN, SERVICE_MEDIA_STOP, data, blocking=True)
@bind_hass
def media_stop(hass: HomeAssistant, entity_id: str = ENTITY_MATCH_ALL) -> None:
"""Send the media player the command for stop."""
hass.add_job(async_media_stop, hass, entity_id)
@@ -214,7 +202,6 @@ async def async_media_next_track(
)
@bind_hass
def media_next_track(hass: HomeAssistant, entity_id: str = ENTITY_MATCH_ALL) -> None:
"""Send the media player the command for next track."""
hass.add_job(async_media_next_track, hass, entity_id)
@@ -230,7 +217,6 @@ async def async_media_previous_track(
)
@bind_hass
def media_previous_track(
hass: HomeAssistant, entity_id: str = ENTITY_MATCH_ALL
) -> None:
@@ -247,7 +233,6 @@ async def async_media_seek(
await hass.services.async_call(DOMAIN, SERVICE_MEDIA_SEEK, data, blocking=True)
@bind_hass
def media_seek(
hass: HomeAssistant, position: float, entity_id: str = ENTITY_MATCH_ALL
) -> None:
@@ -274,7 +259,6 @@ async def async_play_media(
await hass.services.async_call(DOMAIN, SERVICE_PLAY_MEDIA, data, blocking=True)
@bind_hass
def play_media(
hass: HomeAssistant,
media_type: str,
@@ -298,7 +282,6 @@ async def async_select_source(
await hass.services.async_call(DOMAIN, SERVICE_SELECT_SOURCE, data, blocking=True)
@bind_hass
def select_source(
hass: HomeAssistant, source: str, entity_id: str = ENTITY_MATCH_ALL
) -> None:
@@ -314,7 +297,6 @@ async def async_clear_playlist(
await hass.services.async_call(DOMAIN, SERVICE_CLEAR_PLAYLIST, data, blocking=True)
@bind_hass
def clear_playlist(hass: HomeAssistant, entity_id: str = ENTITY_MATCH_ALL) -> None:
"""Send the media player the command for clear playlist."""
hass.add_job(async_clear_playlist, hass, entity_id)
-2
View File
@@ -14,10 +14,8 @@ from homeassistant.components.notify import (
SERVICE_NOTIFY,
)
from homeassistant.core import HomeAssistant
from homeassistant.loader import bind_hass
@bind_hass
def send_message(
hass: HomeAssistant, message: str, title: str | None = None, data: Any = None
) -> None:
-2
View File
@@ -7,10 +7,8 @@ components. Instead call the service directly.
from homeassistant.components.scene import DOMAIN
from homeassistant.const import ATTR_ENTITY_ID, ENTITY_MATCH_ALL, SERVICE_TURN_ON
from homeassistant.core import HomeAssistant
from homeassistant.loader import bind_hass
@bind_hass
def activate(hass: HomeAssistant, entity_id: str = ENTITY_MATCH_ALL) -> None:
"""Activate a scene."""
data = {}
-3
View File
@@ -16,10 +16,8 @@ from homeassistant.const import (
STATE_ON,
)
from homeassistant.core import HomeAssistant
from homeassistant.loader import bind_hass
@bind_hass
def turn_on(hass: HomeAssistant, entity_id: str = ENTITY_MATCH_ALL) -> None:
"""Turn all or specified switch on."""
hass.add_job(async_turn_on, hass, entity_id)
@@ -31,7 +29,6 @@ async def async_turn_on(hass: HomeAssistant, entity_id: str = ENTITY_MATCH_ALL)
await hass.services.async_call(DOMAIN, SERVICE_TURN_ON, data, blocking=True)
@bind_hass
def turn_off(hass: HomeAssistant, entity_id: str = ENTITY_MATCH_ALL) -> None:
"""Turn all or specified switch off."""
hass.add_job(async_turn_off, hass, entity_id)