diff --git a/homeassistant/components/auth/__init__.py b/homeassistant/components/auth/__init__.py index 33aeb283f5a..974cd821286 100644 --- a/homeassistant/components/auth/__init__.py +++ b/homeassistant/components/auth/__init__.py @@ -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: diff --git a/homeassistant/components/automation/__init__.py b/homeassistant/components/automation/__init__.py index f667a878e01..dadac6b6602 100644 --- a/homeassistant/components/automation/__init__.py +++ b/homeassistant/components/automation/__init__.py @@ -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. diff --git a/homeassistant/components/camera/__init__.py b/homeassistant/components/camera/__init__.py index fb7de2d8ebd..5b7cc974271 100644 --- a/homeassistant/components/camera/__init__.py +++ b/homeassistant/components/camera/__init__.py @@ -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: diff --git a/homeassistant/components/cloud/__init__.py b/homeassistant/components/cloud/__init__.py index 17a1ad4800d..d1de4c55eeb 100644 --- a/homeassistant/components/cloud/__init__.py +++ b/homeassistant/components/cloud/__init__.py @@ -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.""" diff --git a/homeassistant/components/configurator/__init__.py b/homeassistant/components/configurator/__init__.py index d1ddcb6cd4b..ce383eec1c1 100644 --- a/homeassistant/components/configurator/__init__.py +++ b/homeassistant/components/configurator/__init__.py @@ -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( diff --git a/homeassistant/components/conversation/__init__.py b/homeassistant/components/conversation/__init__.py index b386121543c..69aab381bf2 100644 --- a/homeassistant/components/conversation/__init__.py +++ b/homeassistant/components/conversation/__init__.py @@ -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, diff --git a/homeassistant/components/cover/__init__.py b/homeassistant/components/cover/__init__.py index 7dc9bd26d03..6caf1d0a822 100644 --- a/homeassistant/components/cover/__init__.py +++ b/homeassistant/components/cover/__init__.py @@ -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) diff --git a/homeassistant/components/device_tracker/__init__.py b/homeassistant/components/device_tracker/__init__.py index 3ffb48596c7..bc87a6e073e 100644 --- a/homeassistant/components/device_tracker/__init__.py +++ b/homeassistant/components/device_tracker/__init__.py @@ -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) diff --git a/homeassistant/components/fan/__init__.py b/homeassistant/components/fan/__init__.py index b9e20e8dc91..cd94fe87538 100644 --- a/homeassistant/components/fan/__init__.py +++ b/homeassistant/components/fan/__init__.py @@ -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) diff --git a/homeassistant/components/ffmpeg/__init__.py b/homeassistant/components/ffmpeg/__init__.py index d4be04deae3..1c2de5f277f 100644 --- a/homeassistant/components/ffmpeg/__init__.py +++ b/homeassistant/components/ffmpeg/__init__.py @@ -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, diff --git a/homeassistant/components/frontend/__init__.py b/homeassistant/components/frontend/__init__.py index 6531f80ddaf..30c4fc547a2 100644 --- a/homeassistant/components/frontend/__init__.py +++ b/homeassistant/components/frontend/__init__.py @@ -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 diff --git a/homeassistant/components/group/__init__.py b/homeassistant/components/group/__init__.py index 5e199e5bcad..220ba3713f9 100644 --- a/homeassistant/components/group/__init__.py +++ b/homeassistant/components/group/__init__.py @@ -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. diff --git a/homeassistant/components/hassio/coordinator.py b/homeassistant/components/hassio/coordinator.py index 0b09058aa45..d0ab56a2d27 100644 --- a/homeassistant/components/hassio/coordinator.py +++ b/homeassistant/components/hassio/coordinator.py @@ -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. diff --git a/homeassistant/components/http/__init__.py b/homeassistant/components/http/__init__.py index a4db676ffe3..27078fe3f53 100644 --- a/homeassistant/components/http/__init__.py +++ b/homeassistant/components/http/__init__.py @@ -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) diff --git a/homeassistant/components/humidifier/__init__.py b/homeassistant/components/humidifier/__init__.py index 8ee4a1eaf78..10fc1733f43 100644 --- a/homeassistant/components/humidifier/__init__.py +++ b/homeassistant/components/humidifier/__init__.py @@ -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. diff --git a/homeassistant/components/input_boolean/__init__.py b/homeassistant/components/input_boolean/__init__.py index 5fd50084895..49ca197aec6 100644 --- a/homeassistant/components/input_boolean/__init__.py +++ b/homeassistant/components/input_boolean/__init__.py @@ -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) diff --git a/homeassistant/components/light/__init__.py b/homeassistant/components/light/__init__.py index de1f9841a50..b91c3d486bd 100644 --- a/homeassistant/components/light/__init__.py +++ b/homeassistant/components/light/__init__.py @@ -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) diff --git a/homeassistant/components/logbook/__init__.py b/homeassistant/components/logbook/__init__.py index de2ff570f0c..d73d64bb818 100644 --- a/homeassistant/components/logbook/__init__.py +++ b/homeassistant/components/logbook/__init__.py @@ -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, diff --git a/homeassistant/components/media_player/__init__.py b/homeassistant/components/media_player/__init__.py index ea9dd0adcfd..a8b843b09c5 100644 --- a/homeassistant/components/media_player/__init__.py +++ b/homeassistant/components/media_player/__init__.py @@ -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. diff --git a/homeassistant/components/media_source/helper.py b/homeassistant/components/media_source/helper.py index 940b67c33c6..b4e6218a872 100644 --- a/homeassistant/components/media_source/helper.py +++ b/homeassistant/components/media_source/helper.py @@ -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, diff --git a/homeassistant/components/mqtt/client.py b/homeassistant/components/mqtt/client.py index cbfaca71acf..e2f944384cf 100644 --- a/homeassistant/components/mqtt/client.py +++ b/homeassistant/components/mqtt/client.py @@ -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, diff --git a/homeassistant/components/network/__init__.py b/homeassistant/components/network/__init__.py index dd5344faa56..acfbcfe17bf 100644 --- a/homeassistant/components/network/__init__.py +++ b/homeassistant/components/network/__init__.py @@ -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)} diff --git a/homeassistant/components/notify/legacy.py b/homeassistant/components/notify/legacy.py index f5703022e12..7cfda555077 100644 --- a/homeassistant/components/notify/legacy.py +++ b/homeassistant/components/notify/legacy.py @@ -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) diff --git a/homeassistant/components/onboarding/__init__.py b/homeassistant/components/onboarding/__init__.py index 097cddd6603..eae3a4d530b 100644 --- a/homeassistant/components/onboarding/__init__.py +++ b/homeassistant/components/onboarding/__init__.py @@ -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.""" diff --git a/homeassistant/components/panel_custom/__init__.py b/homeassistant/components/panel_custom/__init__.py index db9c35a7608..ec6063d4fda 100644 --- a/homeassistant/components/panel_custom/__init__.py +++ b/homeassistant/components/panel_custom/__init__.py @@ -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 diff --git a/homeassistant/components/persistent_notification/__init__.py b/homeassistant/components/persistent_notification/__init__.py index 2871f4b575a..05eed017db8 100644 --- a/homeassistant/components/persistent_notification/__init__.py +++ b/homeassistant/components/persistent_notification/__init__.py @@ -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) diff --git a/homeassistant/components/person/__init__.py b/homeassistant/components/person/__init__.py index 2fc04785812..e7bbef67e32 100644 --- a/homeassistant/components/person/__init__.py +++ b/homeassistant/components/person/__init__.py @@ -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: diff --git a/homeassistant/components/python_script/__init__.py b/homeassistant/components/python_script/__init__.py index 0729d73a034..afed00363c9 100644 --- a/homeassistant/components/python_script/__init__.py +++ b/homeassistant/components/python_script/__init__.py @@ -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, diff --git a/homeassistant/components/recorder/__init__.py b/homeassistant/components/recorder/__init__.py index a350feac519..b7e2d3e3604 100644 --- a/homeassistant/components/recorder/__init__.py +++ b/homeassistant/components/recorder/__init__.py @@ -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. diff --git a/homeassistant/components/remote/__init__.py b/homeassistant/components/remote/__init__.py index f7d87fbf021..8fe98868b56 100644 --- a/homeassistant/components/remote/__init__.py +++ b/homeassistant/components/remote/__init__.py @@ -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) diff --git a/homeassistant/components/script/__init__.py b/homeassistant/components/script/__init__.py index 5542b7bf611..61f5255f8d2 100644 --- a/homeassistant/components/script/__init__.py +++ b/homeassistant/components/script/__init__.py @@ -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) diff --git a/homeassistant/components/ssdp/__init__.py b/homeassistant/components/ssdp/__init__.py index 97375cb600a..64f3062c90c 100644 --- a/homeassistant/components/ssdp/__init__.py +++ b/homeassistant/components/ssdp/__init__.py @@ -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]: diff --git a/homeassistant/components/switch/__init__.py b/homeassistant/components/switch/__init__.py index 3c173cf5b2a..b6ba6928abc 100644 --- a/homeassistant/components/switch/__init__.py +++ b/homeassistant/components/switch/__init__.py @@ -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. diff --git a/homeassistant/components/system_health/__init__.py b/homeassistant/components/system_health/__init__.py index 37e9ee3d929..4cf3d6b88c8 100644 --- a/homeassistant/components/system_health/__init__.py +++ b/homeassistant/components/system_health/__init__.py @@ -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, diff --git a/homeassistant/components/vacuum/__init__.py b/homeassistant/components/vacuum/__init__.py index 0347e401da8..8e98b61c838 100644 --- a/homeassistant/components/vacuum/__init__.py +++ b/homeassistant/components/vacuum/__init__.py @@ -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) diff --git a/homeassistant/components/webhook/__init__.py b/homeassistant/components/webhook/__init__.py index 92ef59db908..5778658b128 100644 --- a/homeassistant/components/webhook/__init__.py +++ b/homeassistant/components/webhook/__init__.py @@ -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: diff --git a/homeassistant/components/websocket_api/__init__.py b/homeassistant/components/websocket_api/__init__.py index f9bc4396e01..164c5b6f16d 100644 --- a/homeassistant/components/websocket_api/__init__.py +++ b/homeassistant/components/websocket_api/__init__.py @@ -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, diff --git a/homeassistant/components/zeroconf/__init__.py b/homeassistant/components/zeroconf/__init__.py index 82317d06205..1c04022b97d 100644 --- a/homeassistant/components/zeroconf/__init__.py +++ b/homeassistant/components/zeroconf/__init__.py @@ -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) diff --git a/homeassistant/components/zone/__init__.py b/homeassistant/components/zone/__init__.py index ca707c02f9a..410194695e8 100644 --- a/homeassistant/components/zone/__init__.py +++ b/homeassistant/components/zone/__init__.py @@ -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: diff --git a/homeassistant/helpers/aiohttp_client.py b/homeassistant/helpers/aiohttp_client.py index 0939c31eadc..6d311a589e6 100644 --- a/homeassistant/helpers/aiohttp_client.py +++ b/homeassistant/helpers/aiohttp_client.py @@ -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, diff --git a/homeassistant/helpers/discovery.py b/homeassistant/helpers/discovery.py index 7c1b5ac4a64..341c645a681 100644 --- a/homeassistant/helpers/discovery.py +++ b/homeassistant/helpers/discovery.py @@ -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, diff --git a/homeassistant/helpers/discovery_flow.py b/homeassistant/helpers/discovery_flow.py index fd41c7ffb44..ac5974c36e6 100644 --- a/homeassistant/helpers/discovery_flow.py +++ b/homeassistant/helpers/discovery_flow.py @@ -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, diff --git a/homeassistant/helpers/dispatcher.py b/homeassistant/helpers/dispatcher.py index 8eda564e7cb..91164d4b7a7 100644 --- a/homeassistant/helpers/dispatcher.py +++ b/homeassistant/helpers/dispatcher.py @@ -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: diff --git a/homeassistant/helpers/entity.py b/homeassistant/helpers/entity.py index 63e02627f71..8ada64d864e 100644 --- a/homeassistant/helpers/entity.py +++ b/homeassistant/helpers/entity.py @@ -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. diff --git a/homeassistant/helpers/entity_component.py b/homeassistant/helpers/entity_component.py index ca46be3d934..f2d8ee072a6 100644 --- a/homeassistant/helpers/entity_component.py +++ b/homeassistant/helpers/entity_component.py @@ -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] diff --git a/homeassistant/helpers/event.py b/homeassistant/helpers/event.py index 03c699168ef..9eef6395ff1 100644 --- a/homeassistant/helpers/event.py +++ b/homeassistant/helpers/event.py @@ -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], diff --git a/homeassistant/helpers/httpx_client.py b/homeassistant/helpers/httpx_client.py index d253c3377aa..469f1223bf0 100644 --- a/homeassistant/helpers/httpx_client.py +++ b/homeassistant/helpers/httpx_client.py @@ -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, diff --git a/homeassistant/helpers/integration_platform.py b/homeassistant/helpers/integration_platform.py index 4ded7444989..39c30cdca58 100644 --- a/homeassistant/helpers/integration_platform.py +++ b/homeassistant/helpers/integration_platform.py @@ -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, diff --git a/homeassistant/helpers/intent.py b/homeassistant/helpers/intent.py index 990fa490c76..d9a3e47c6e0 100644 --- a/homeassistant/helpers/intent.py +++ b/homeassistant/helpers/intent.py @@ -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, diff --git a/homeassistant/helpers/network.py b/homeassistant/helpers/network.py index 6f4aadaf786..51864d8b504 100644 --- a/homeassistant/helpers/network.py +++ b/homeassistant/helpers/network.py @@ -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: diff --git a/homeassistant/helpers/service.py b/homeassistant/helpers/service.py index d93c9d5a245..9740e8cf189 100644 --- a/homeassistant/helpers/service.py +++ b/homeassistant/helpers/service.py @@ -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, diff --git a/homeassistant/helpers/signal.py b/homeassistant/helpers/signal.py index 4a4b9bead47..6fd2a384c0e 100644 --- a/homeassistant/helpers/signal.py +++ b/homeassistant/helpers/signal.py @@ -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.""" diff --git a/homeassistant/helpers/singleton.py b/homeassistant/helpers/singleton.py index dac2e5832f6..e192f2b7087 100644 --- a/homeassistant/helpers/singleton.py +++ b/homeassistant/helpers/singleton.py @@ -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: diff --git a/homeassistant/helpers/state.py b/homeassistant/helpers/state.py index 70f64d5296a..de8f7c3ec83 100644 --- a/homeassistant/helpers/state.py +++ b/homeassistant/helpers/state.py @@ -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], diff --git a/homeassistant/helpers/storage.py b/homeassistant/helpers/storage.py index d651f6c36c4..5b251860d4a 100644 --- a/homeassistant/helpers/storage.py +++ b/homeassistant/helpers/storage.py @@ -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.""" diff --git a/homeassistant/helpers/sun.py b/homeassistant/helpers/sun.py index 1c35f45d713..85e64a75618 100644 --- a/homeassistant/helpers/sun.py +++ b/homeassistant/helpers/sun.py @@ -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: diff --git a/homeassistant/helpers/system_info.py b/homeassistant/helpers/system_info.py index 20da2ec6d65..9785d6eebc2 100644 --- a/homeassistant/helpers/system_info.py +++ b/homeassistant/helpers/system_info.py @@ -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) diff --git a/homeassistant/helpers/translation.py b/homeassistant/helpers/translation.py index ad00f164c4c..52ba8829e82 100644 --- a/homeassistant/helpers/translation.py +++ b/homeassistant/helpers/translation.py @@ -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, diff --git a/tests/components/climate/common.py b/tests/components/climate/common.py index ca214ec2d70..059d6689675 100644 --- a/tests/components/climate/common.py +++ b/tests/components/climate/common.py @@ -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: diff --git a/tests/components/counter/common.py b/tests/components/counter/common.py index e5d9316cd22..1217cf2a2b8 100644 --- a/tests/components/counter/common.py +++ b/tests/components/counter/common.py @@ -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( diff --git a/tests/components/device_tracker/common.py b/tests/components/device_tracker/common.py index 1c296732523..141625a77bd 100644 --- a/tests/components/device_tracker/common.py +++ b/tests/components/device_tracker/common.py @@ -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, diff --git a/tests/components/group/common.py b/tests/components/group/common.py index a9b6356418c..141d2bcab54 100644 --- a/tests/components/group/common.py +++ b/tests/components/group/common.py @@ -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} diff --git a/tests/components/image_processing/common.py b/tests/components/image_processing/common.py index 35b94f2c91c..59c46ce7c2c 100644 --- a/tests/components/image_processing/common.py +++ b/tests/components/image_processing/common.py @@ -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 diff --git a/tests/components/media_player/common.py b/tests/components/media_player/common.py index c0cdfbf26d7..64af0110535 100644 --- a/tests/components/media_player/common.py +++ b/tests/components/media_player/common.py @@ -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) diff --git a/tests/components/notify/common.py b/tests/components/notify/common.py index 1b5c0d6d6ba..c61cb962f2a 100644 --- a/tests/components/notify/common.py +++ b/tests/components/notify/common.py @@ -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: diff --git a/tests/components/scene/common.py b/tests/components/scene/common.py index 39f86818744..e6b8ad254de 100644 --- a/tests/components/scene/common.py +++ b/tests/components/scene/common.py @@ -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 = {} diff --git a/tests/components/switch/common.py b/tests/components/switch/common.py index 96c79fb7d55..33e36db7ecd 100644 --- a/tests/components/switch/common.py +++ b/tests/components/switch/common.py @@ -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)