diff --git a/homeassistant/components/cloud/http_api.py b/homeassistant/components/cloud/http_api.py index 90b8bad108f..01b6cd17508 100644 --- a/homeassistant/components/cloud/http_api.py +++ b/homeassistant/components/cloud/http_api.py @@ -689,7 +689,11 @@ async def thingtalk_convert( @websocket_api.websocket_command({"type": "cloud/tts/info"}) -def tts_info(hass, connection, msg): +def tts_info( + hass: HomeAssistant, + connection: websocket_api.ActiveConnection, + msg: dict[str, Any], +) -> None: """Fetch available tts info.""" connection.send_result( msg["id"], {"languages": [(lang, gender.value) for lang, gender in MAP_VOICE]} diff --git a/homeassistant/components/config/area_registry.py b/homeassistant/components/config/area_registry.py index 3a2c55b3f5d..bf63a516b58 100644 --- a/homeassistant/components/config/area_registry.py +++ b/homeassistant/components/config/area_registry.py @@ -1,8 +1,10 @@ """HTTP views to interact with the area registry.""" +from typing import Any + import voluptuous as vol from homeassistant.components import websocket_api -from homeassistant.core import callback +from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.area_registry import async_get @@ -17,7 +19,11 @@ async def async_setup(hass): @websocket_api.websocket_command({vol.Required("type"): "config/area_registry/list"}) @callback -def websocket_list_areas(hass, connection, msg): +def websocket_list_areas( + hass: HomeAssistant, + connection: websocket_api.ActiveConnection, + msg: dict[str, Any], +) -> None: """Handle list areas command.""" registry = async_get(hass) connection.send_result( @@ -35,7 +41,11 @@ def websocket_list_areas(hass, connection, msg): ) @websocket_api.require_admin @callback -def websocket_create_area(hass, connection, msg): +def websocket_create_area( + hass: HomeAssistant, + connection: websocket_api.ActiveConnection, + msg: dict[str, Any], +) -> None: """Create area command.""" registry = async_get(hass) @@ -59,7 +69,11 @@ def websocket_create_area(hass, connection, msg): ) @websocket_api.require_admin @callback -def websocket_delete_area(hass, connection, msg): +def websocket_delete_area( + hass: HomeAssistant, + connection: websocket_api.ActiveConnection, + msg: dict[str, Any], +) -> None: """Delete area command.""" registry = async_get(hass) @@ -81,7 +95,11 @@ def websocket_delete_area(hass, connection, msg): ) @websocket_api.require_admin @callback -def websocket_update_area(hass, connection, msg): +def websocket_update_area( + hass: HomeAssistant, + connection: websocket_api.ActiveConnection, + msg: dict[str, Any], +) -> None: """Handle update area websocket command.""" registry = async_get(hass) diff --git a/homeassistant/components/config/config_entries.py b/homeassistant/components/config/config_entries.py index 50bcad45db7..39c5bce25cb 100644 --- a/homeassistant/components/config/config_entries.py +++ b/homeassistant/components/config/config_entries.py @@ -243,7 +243,11 @@ class OptionManagerFlowResourceView(FlowManagerResourceView): @websocket_api.require_admin @websocket_api.websocket_command({"type": "config_entries/flow/progress"}) -def config_entries_progress(hass, connection, msg): +def config_entries_progress( + hass: HomeAssistant, + connection: websocket_api.ActiveConnection, + msg: dict[str, Any], +) -> None: """List flows that are in progress but not started by a user. Example of a non-user initiated flow is a discovered Hue hub that diff --git a/homeassistant/components/energy/websocket_api.py b/homeassistant/components/energy/websocket_api.py index f1b75c8ea9e..8fa35e607b2 100644 --- a/homeassistant/components/energy/websocket_api.py +++ b/homeassistant/components/energy/websocket_api.py @@ -185,7 +185,7 @@ async def ws_validate( async def ws_solar_forecast( hass: HomeAssistant, connection: websocket_api.ActiveConnection, - msg: dict, + msg: dict[str, Any], manager: EnergyManager, ) -> None: """Handle solar forecast command.""" diff --git a/homeassistant/components/frontend/__init__.py b/homeassistant/components/frontend/__init__.py index c49af972e38..f5fe37c1819 100644 --- a/homeassistant/components/frontend/__init__.py +++ b/homeassistant/components/frontend/__init__.py @@ -614,7 +614,7 @@ class ManifestJSONView(HomeAssistantView): @callback @websocket_api.websocket_command({"type": "get_panels"}) def websocket_get_panels( - hass: HomeAssistant, connection: ActiveConnection, msg: dict + hass: HomeAssistant, connection: ActiveConnection, msg: dict[str, Any] ) -> None: """Handle get panels command.""" user_is_admin = connection.user.is_admin @@ -630,7 +630,7 @@ def websocket_get_panels( @callback @websocket_api.websocket_command({"type": "frontend/get_themes"}) def websocket_get_themes( - hass: HomeAssistant, connection: ActiveConnection, msg: dict + hass: HomeAssistant, connection: ActiveConnection, msg: dict[str, Any] ) -> None: """Handle get themes command.""" if hass.config.safe_mode: diff --git a/homeassistant/components/mobile_app/websocket_api.py b/homeassistant/components/mobile_app/websocket_api.py index 5225100662c..c900aa8f93b 100644 --- a/homeassistant/components/mobile_app/websocket_api.py +++ b/homeassistant/components/mobile_app/websocket_api.py @@ -57,7 +57,11 @@ def _ensure_webhook_access(func): vol.Required("confirm_id"): str, } ) -def handle_push_notification_confirm(hass, connection, msg): +def handle_push_notification_confirm( + hass: HomeAssistant, + connection: websocket_api.ActiveConnection, + msg: dict[str, Any], +) -> None: """Confirm receipt of a push notification.""" channel: PushChannel | None = hass.data[DOMAIN][DATA_PUSH_CHANNEL].get( msg["webhook_id"] diff --git a/homeassistant/components/mqtt/__init__.py b/homeassistant/components/mqtt/__init__.py index a63b6137fea..ba1af354071 100644 --- a/homeassistant/components/mqtt/__init__.py +++ b/homeassistant/components/mqtt/__init__.py @@ -496,7 +496,11 @@ async def async_reload_manual_mqtt_items(hass: HomeAssistant) -> None: {vol.Required("type"): "mqtt/device/debug_info", vol.Required("device_id"): str} ) @callback -def websocket_mqtt_info(hass, connection, msg): +def websocket_mqtt_info( + hass: HomeAssistant, + connection: websocket_api.ActiveConnection, + msg: dict[str, Any], +) -> None: """Get MQTT debug info for device.""" device_id = msg["device_id"] mqtt_info = debug_info.info_for_device(hass, device_id) diff --git a/homeassistant/components/person/__init__.py b/homeassistant/components/person/__init__.py index 86a132027d8..a469a459ace 100644 --- a/homeassistant/components/person/__init__.py +++ b/homeassistant/components/person/__init__.py @@ -2,6 +2,7 @@ from __future__ import annotations import logging +from typing import Any import voluptuous as vol @@ -546,8 +547,10 @@ class Person(collection.CollectionEntity, RestoreEntity): @websocket_api.websocket_command({vol.Required(CONF_TYPE): "person/list"}) def ws_list_person( - hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg -): + hass: HomeAssistant, + connection: websocket_api.ActiveConnection, + msg: dict[str, Any], +) -> None: """List persons.""" yaml, storage, _ = hass.data[DOMAIN] connection.send_result( diff --git a/homeassistant/components/recorder/websocket_api.py b/homeassistant/components/recorder/websocket_api.py index d7fbce60767..37d117c910e 100644 --- a/homeassistant/components/recorder/websocket_api.py +++ b/homeassistant/components/recorder/websocket_api.py @@ -207,7 +207,7 @@ async def ws_validate_statistics( ) @callback def ws_clear_statistics( - hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict + hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict[str, Any] ) -> None: """Clear statistics for a list of statistic_ids. @@ -246,7 +246,7 @@ async def ws_get_statistics_metadata( ) @callback def ws_update_statistics_metadata( - hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict + hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict[str, Any] ) -> None: """Update statistics metadata for a statistic_id. @@ -269,7 +269,7 @@ def ws_update_statistics_metadata( ) @callback def ws_change_statistics_unit( - hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict + hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict[str, Any] ) -> None: """Change the unit_of_measurement for a statistic_id. @@ -371,7 +371,7 @@ async def ws_adjust_sum_statistics( ) @callback def ws_import_statistics( - hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict + hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict[str, Any] ) -> None: """Import statistics.""" metadata = msg["metadata"] @@ -391,7 +391,7 @@ def ws_import_statistics( ) @callback def ws_info( - hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict + hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict[str, Any] ) -> None: """Return status of the recorder.""" instance = get_instance(hass) diff --git a/homeassistant/components/repairs/websocket_api.py b/homeassistant/components/repairs/websocket_api.py index b4ccca7c894..c5408054318 100644 --- a/homeassistant/components/repairs/websocket_api.py +++ b/homeassistant/components/repairs/websocket_api.py @@ -46,7 +46,7 @@ def async_setup(hass: HomeAssistant) -> None: } ) def ws_ignore_issue( - hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict + hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict[str, Any] ) -> None: """Fix an issue.""" async_ignore_issue(hass, msg["domain"], msg["issue_id"], msg["ignore"]) @@ -61,7 +61,7 @@ def ws_ignore_issue( ) @callback def ws_list_issues( - hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict + hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict[str, Any] ) -> None: """Return a list of issues.""" diff --git a/homeassistant/components/rtsp_to_webrtc/__init__.py b/homeassistant/components/rtsp_to_webrtc/__init__.py index f0e013fc02f..f5f114bce9c 100644 --- a/homeassistant/components/rtsp_to_webrtc/__init__.py +++ b/homeassistant/components/rtsp_to_webrtc/__init__.py @@ -19,6 +19,7 @@ Other integrations may use this integration with these steps: from __future__ import annotations import logging +from typing import Any import async_timeout from rtsp_to_webrtc.client import get_adaptive_client @@ -109,7 +110,7 @@ async def async_reload_entry(hass: HomeAssistant, entry: ConfigEntry) -> None: ) @callback def ws_get_settings( - hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict + hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict[str, Any] ) -> None: """Handle the websocket command.""" connection.send_result( diff --git a/homeassistant/components/search/__init__.py b/homeassistant/components/search/__init__.py index e7df1de860e..70702f351f6 100644 --- a/homeassistant/components/search/__init__.py +++ b/homeassistant/components/search/__init__.py @@ -3,6 +3,7 @@ from __future__ import annotations from collections import defaultdict, deque import logging +from typing import Any import voluptuous as vol @@ -44,7 +45,11 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: } ) @callback -def websocket_search_related(hass, connection, msg): +def websocket_search_related( + hass: HomeAssistant, + connection: websocket_api.ActiveConnection, + msg: dict[str, Any], +) -> None: """Handle search.""" searcher = Searcher( hass, diff --git a/homeassistant/components/shopping_list/__init__.py b/homeassistant/components/shopping_list/__init__.py index 577786fca99..0f7afe3240e 100644 --- a/homeassistant/components/shopping_list/__init__.py +++ b/homeassistant/components/shopping_list/__init__.py @@ -360,8 +360,8 @@ class ClearCompletedItemsView(http.HomeAssistantView): @callback def websocket_handle_items( hass: HomeAssistant, - connection: websocket_api.connection.ActiveConnection, - msg: dict, + connection: websocket_api.ActiveConnection, + msg: dict[str, Any], ) -> None: """Handle get shopping_list items.""" connection.send_message( @@ -372,7 +372,7 @@ def websocket_handle_items( @websocket_api.async_response async def websocket_handle_add( hass: HomeAssistant, - connection: websocket_api.connection.ActiveConnection, + connection: websocket_api.ActiveConnection, msg: dict[str, Any], ) -> None: """Handle add item to shopping_list.""" @@ -383,7 +383,7 @@ async def websocket_handle_add( @websocket_api.async_response async def websocket_handle_update( hass: HomeAssistant, - connection: websocket_api.connection.ActiveConnection, + connection: websocket_api.ActiveConnection, msg: dict[str, Any], ) -> None: """Handle update shopping_list item.""" @@ -406,7 +406,7 @@ async def websocket_handle_update( @websocket_api.async_response async def websocket_handle_clear( hass: HomeAssistant, - connection: websocket_api.connection.ActiveConnection, + connection: websocket_api.ActiveConnection, msg: dict[str, Any], ) -> None: """Handle clearing shopping_list items.""" @@ -422,8 +422,8 @@ async def websocket_handle_clear( ) def websocket_handle_reorder( hass: HomeAssistant, - connection: websocket_api.connection.ActiveConnection, - msg: dict, + connection: websocket_api.ActiveConnection, + msg: dict[str, Any], ) -> None: """Handle reordering shopping_list items.""" msg_id = msg.pop("id") diff --git a/homeassistant/components/system_log/__init__.py b/homeassistant/components/system_log/__init__.py index b0d538a4ff8..fae8598407e 100644 --- a/homeassistant/components/system_log/__init__.py +++ b/homeassistant/components/system_log/__init__.py @@ -3,6 +3,7 @@ from collections import OrderedDict, deque import logging import re import traceback +from typing import Any import voluptuous as vol @@ -240,8 +241,8 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: @websocket_api.websocket_command({vol.Required("type"): "system_log/list"}) @callback def list_errors( - hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict -): + hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict[str, Any] +) -> None: """List all possible diagnostic handlers.""" connection.send_result( msg["id"], diff --git a/homeassistant/components/trace/websocket_api.py b/homeassistant/components/trace/websocket_api.py index ba79ae68968..bf5ebfc1031 100644 --- a/homeassistant/components/trace/websocket_api.py +++ b/homeassistant/components/trace/websocket_api.py @@ -135,7 +135,11 @@ async def websocket_trace_contexts( vol.Optional("run_id"): str, } ) -def websocket_breakpoint_set(hass, connection, msg): +def websocket_breakpoint_set( + hass: HomeAssistant, + connection: websocket_api.ActiveConnection, + msg: dict[str, Any], +) -> None: """Set breakpoint.""" key = f"{msg['domain']}.{msg['item_id']}" node = msg["node"] @@ -162,7 +166,11 @@ def websocket_breakpoint_set(hass, connection, msg): vol.Optional("run_id"): str, } ) -def websocket_breakpoint_clear(hass, connection, msg): +def websocket_breakpoint_clear( + hass: HomeAssistant, + connection: websocket_api.ActiveConnection, + msg: dict[str, Any], +) -> None: """Clear breakpoint.""" key = f"{msg['domain']}.{msg['item_id']}" node = msg["node"] @@ -176,7 +184,11 @@ def websocket_breakpoint_clear(hass, connection, msg): @callback @websocket_api.require_admin @websocket_api.websocket_command({vol.Required("type"): "trace/debug/breakpoint/list"}) -def websocket_breakpoint_list(hass, connection, msg): +def websocket_breakpoint_list( + hass: HomeAssistant, + connection: websocket_api.ActiveConnection, + msg: dict[str, Any], +) -> None: """List breakpoints.""" breakpoints = breakpoint_list(hass) for _breakpoint in breakpoints: @@ -191,7 +203,11 @@ def websocket_breakpoint_list(hass, connection, msg): @websocket_api.websocket_command( {vol.Required("type"): "trace/debug/breakpoint/subscribe"} ) -def websocket_subscribe_breakpoint_events(hass, connection, msg): +def websocket_subscribe_breakpoint_events( + hass: HomeAssistant, + connection: websocket_api.ActiveConnection, + msg: dict[str, Any], +) -> None: """Subscribe to breakpoint events.""" @callback @@ -240,7 +256,11 @@ def websocket_subscribe_breakpoint_events(hass, connection, msg): vol.Required("run_id"): str, } ) -def websocket_debug_continue(hass, connection, msg): +def websocket_debug_continue( + hass: HomeAssistant, + connection: websocket_api.ActiveConnection, + msg: dict[str, Any], +) -> None: """Resume execution of halted script or automation.""" key = f"{msg['domain']}.{msg['item_id']}" run_id = msg["run_id"] @@ -260,7 +280,11 @@ def websocket_debug_continue(hass, connection, msg): vol.Required("run_id"): str, } ) -def websocket_debug_step(hass, connection, msg): +def websocket_debug_step( + hass: HomeAssistant, + connection: websocket_api.ActiveConnection, + msg: dict[str, Any], +) -> None: """Single step a halted script or automation.""" key = f"{msg['domain']}.{msg['item_id']}" run_id = msg["run_id"] @@ -280,7 +304,11 @@ def websocket_debug_step(hass, connection, msg): vol.Required("run_id"): str, } ) -def websocket_debug_stop(hass, connection, msg): +def websocket_debug_stop( + hass: HomeAssistant, + connection: websocket_api.ActiveConnection, + msg: dict[str, Any], +) -> None: """Stop a halted script or automation.""" key = f"{msg['domain']}.{msg['item_id']}" run_id = msg["run_id"] diff --git a/homeassistant/components/webhook/__init__.py b/homeassistant/components/webhook/__init__.py index f78d9059ee9..bd80f38b832 100644 --- a/homeassistant/components/webhook/__init__.py +++ b/homeassistant/components/webhook/__init__.py @@ -168,7 +168,11 @@ class WebhookView(HomeAssistantView): } ) @callback -def websocket_list(hass, connection, msg): +def websocket_list( + hass: HomeAssistant, + connection: websocket_api.ActiveConnection, + msg: dict[str, Any], +) -> None: """Return a list of webhooks.""" handlers = hass.data.setdefault(DOMAIN, {}) result = [