From 03a1ffc59b466f4d36cf829af16341e04e6ed971 Mon Sep 17 00:00:00 2001 From: Robert Resch Date: Thu, 30 Oct 2025 12:42:25 +0100 Subject: [PATCH] Remove keyboard integration (#155456) --- homeassistant/components/keyboard/__init__.py | 87 ------------------- homeassistant/components/keyboard/icons.json | 22 ----- .../components/keyboard/manifest.json | 10 --- .../components/keyboard/services.yaml | 6 -- .../components/keyboard/strings.json | 28 ------ homeassistant/generated/integrations.json | 6 -- requirements_all.txt | 3 - requirements_test_all.txt | 3 - script/gen_requirements_all.py | 2 - tests/components/keyboard/__init__.py | 1 - tests/components/keyboard/test_init.py | 27 ------ 11 files changed, 195 deletions(-) delete mode 100644 homeassistant/components/keyboard/__init__.py delete mode 100644 homeassistant/components/keyboard/icons.json delete mode 100644 homeassistant/components/keyboard/manifest.json delete mode 100644 homeassistant/components/keyboard/services.yaml delete mode 100644 homeassistant/components/keyboard/strings.json delete mode 100644 tests/components/keyboard/__init__.py delete mode 100644 tests/components/keyboard/test_init.py diff --git a/homeassistant/components/keyboard/__init__.py b/homeassistant/components/keyboard/__init__.py deleted file mode 100644 index 227472ff553..00000000000 --- a/homeassistant/components/keyboard/__init__.py +++ /dev/null @@ -1,87 +0,0 @@ -"""Support to emulate keyboard presses on host machine.""" - -from pykeyboard import PyKeyboard -import voluptuous as vol - -from homeassistant.const import ( - SERVICE_MEDIA_NEXT_TRACK, - SERVICE_MEDIA_PLAY_PAUSE, - SERVICE_MEDIA_PREVIOUS_TRACK, - SERVICE_VOLUME_DOWN, - SERVICE_VOLUME_MUTE, - SERVICE_VOLUME_UP, -) -from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant -from homeassistant.helpers import config_validation as cv -from homeassistant.helpers.issue_registry import IssueSeverity, create_issue -from homeassistant.helpers.typing import ConfigType - -DOMAIN = "keyboard" - -TAP_KEY_SCHEMA = vol.Schema({}) - -CONFIG_SCHEMA = cv.empty_config_schema(DOMAIN) - - -def setup(hass: HomeAssistant, config: ConfigType) -> bool: - """Listen for keyboard events.""" - create_issue( - hass, - HOMEASSISTANT_DOMAIN, - f"deprecated_system_packages_yaml_integration_{DOMAIN}", - breaks_in_ha_version="2025.12.0", - is_fixable=False, - issue_domain=DOMAIN, - severity=IssueSeverity.WARNING, - translation_key="deprecated_system_packages_yaml_integration", - translation_placeholders={ - "domain": DOMAIN, - "integration_title": "Keyboard", - }, - ) - - keyboard = PyKeyboard() - keyboard.special_key_assignment() - - hass.services.register( - DOMAIN, - SERVICE_VOLUME_UP, - lambda service: keyboard.tap_key(keyboard.volume_up_key), - schema=TAP_KEY_SCHEMA, - ) - - hass.services.register( - DOMAIN, - SERVICE_VOLUME_DOWN, - lambda service: keyboard.tap_key(keyboard.volume_down_key), - schema=TAP_KEY_SCHEMA, - ) - - hass.services.register( - DOMAIN, - SERVICE_VOLUME_MUTE, - lambda service: keyboard.tap_key(keyboard.volume_mute_key), - schema=TAP_KEY_SCHEMA, - ) - - hass.services.register( - DOMAIN, - SERVICE_MEDIA_PLAY_PAUSE, - lambda service: keyboard.tap_key(keyboard.media_play_pause_key), - schema=TAP_KEY_SCHEMA, - ) - - hass.services.register( - DOMAIN, - SERVICE_MEDIA_NEXT_TRACK, - lambda service: keyboard.tap_key(keyboard.media_next_track_key), - schema=TAP_KEY_SCHEMA, - ) - - hass.services.register( - DOMAIN, - SERVICE_MEDIA_PREVIOUS_TRACK, - lambda service: keyboard.tap_key(keyboard.media_prev_track_key), - schema=TAP_KEY_SCHEMA, - ) - return True diff --git a/homeassistant/components/keyboard/icons.json b/homeassistant/components/keyboard/icons.json deleted file mode 100644 index 632c0d6424b..00000000000 --- a/homeassistant/components/keyboard/icons.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "services": { - "media_next_track": { - "service": "mdi:skip-next" - }, - "media_play_pause": { - "service": "mdi:play-pause" - }, - "media_prev_track": { - "service": "mdi:skip-previous" - }, - "volume_down": { - "service": "mdi:volume-low" - }, - "volume_mute": { - "service": "mdi:volume-off" - }, - "volume_up": { - "service": "mdi:volume-high" - } - } -} diff --git a/homeassistant/components/keyboard/manifest.json b/homeassistant/components/keyboard/manifest.json deleted file mode 100644 index e4a6606fb80..00000000000 --- a/homeassistant/components/keyboard/manifest.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "domain": "keyboard", - "name": "Keyboard", - "codeowners": [], - "documentation": "https://www.home-assistant.io/integrations/keyboard", - "iot_class": "local_push", - "loggers": ["pykeyboard"], - "quality_scale": "legacy", - "requirements": ["pyuserinput==0.1.11"] -} diff --git a/homeassistant/components/keyboard/services.yaml b/homeassistant/components/keyboard/services.yaml deleted file mode 100644 index b236f8eb80e..00000000000 --- a/homeassistant/components/keyboard/services.yaml +++ /dev/null @@ -1,6 +0,0 @@ -volume_up: -volume_down: -volume_mute: -media_play_pause: -media_next_track: -media_prev_track: diff --git a/homeassistant/components/keyboard/strings.json b/homeassistant/components/keyboard/strings.json deleted file mode 100644 index 81bda5acac7..00000000000 --- a/homeassistant/components/keyboard/strings.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "services": { - "media_next_track": { - "description": "Simulates a key press of the \"Media Next Track\" button on Home Assistant's host machine.", - "name": "Media next track" - }, - "media_play_pause": { - "description": "Simulates a key press of the \"Media Play/Pause\" button on Home Assistant's host machine.", - "name": "Media play/pause" - }, - "media_prev_track": { - "description": "Simulates a key press of the \"Media Previous Track\" button on Home Assistant's host machine.", - "name": "Media previous track" - }, - "volume_down": { - "description": "Simulates a key press of the \"Volume Down\" button on Home Assistant's host machine.", - "name": "Volume down" - }, - "volume_mute": { - "description": "Simulates a key press of the \"Volume Mute\" button on Home Assistant's host machine.", - "name": "Volume mute" - }, - "volume_up": { - "description": "Simulates a key press of the \"Volume Up\" button on Home Assistant's host machine.", - "name": "Volume up" - } - } -} diff --git a/homeassistant/generated/integrations.json b/homeassistant/generated/integrations.json index 670fedb4821..a18f784426b 100644 --- a/homeassistant/generated/integrations.json +++ b/homeassistant/generated/integrations.json @@ -3261,12 +3261,6 @@ "integration_type": "virtual", "supported_by": "opower" }, - "keyboard": { - "name": "Keyboard", - "integration_type": "hub", - "config_flow": false, - "iot_class": "local_push" - }, "keyboard_remote": { "name": "Keyboard Remote", "integration_type": "hub", diff --git a/requirements_all.txt b/requirements_all.txt index 87a18231283..b78105995fa 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -2594,9 +2594,6 @@ pytrydan==0.8.0 # homeassistant.components.uptimerobot pyuptimerobot==22.2.0 -# homeassistant.components.keyboard -# pyuserinput==0.1.11 - # homeassistant.components.vera pyvera==0.3.16 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index e3be5bce2ca..293bf691389 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -2151,9 +2151,6 @@ pytrydan==0.8.0 # homeassistant.components.uptimerobot pyuptimerobot==22.2.0 -# homeassistant.components.keyboard -# pyuserinput==0.1.11 - # homeassistant.components.vera pyvera==0.3.16 diff --git a/script/gen_requirements_all.py b/script/gen_requirements_all.py index e0d64719119..e85198a6998 100755 --- a/script/gen_requirements_all.py +++ b/script/gen_requirements_all.py @@ -28,14 +28,12 @@ EXCLUDED_REQUIREMENTS_ALL = { "evdev", "pybluez", "python-lirc", - "pyuserinput", } # Requirements excluded by EXCLUDED_REQUIREMENTS_ALL which should be included when # building integration wheels for all architectures. INCLUDED_REQUIREMENTS_WHEELS = { "evdev", - "pyuserinput", } diff --git a/tests/components/keyboard/__init__.py b/tests/components/keyboard/__init__.py deleted file mode 100644 index 7bc8a91511f..00000000000 --- a/tests/components/keyboard/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""Keyboard tests.""" diff --git a/tests/components/keyboard/test_init.py b/tests/components/keyboard/test_init.py deleted file mode 100644 index 69355efd761..00000000000 --- a/tests/components/keyboard/test_init.py +++ /dev/null @@ -1,27 +0,0 @@ -"""Keyboard tests.""" - -from unittest.mock import Mock, patch - -from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant -from homeassistant.helpers import issue_registry as ir -from homeassistant.setup import async_setup_component - - -@patch.dict("sys.modules", pykeyboard=Mock()) -async def test_repair_issue_is_created( - hass: HomeAssistant, - issue_registry: ir.IssueRegistry, -) -> None: - """Test repair issue is created.""" - from homeassistant.components.keyboard import DOMAIN # noqa: PLC0415 - - assert await async_setup_component( - hass, - DOMAIN, - {DOMAIN: {}}, - ) - await hass.async_block_till_done() - assert ( - HOMEASSISTANT_DOMAIN, - f"deprecated_system_packages_yaml_integration_{DOMAIN}", - ) in issue_registry.issues