From cee5f4e27560f1e74a261b1134a88de422ec3145 Mon Sep 17 00:00:00 2001 From: Robert Resch Date: Thu, 30 Oct 2025 12:57:12 +0100 Subject: [PATCH] Remove lirc integration (#155457) --- homeassistant/components/lirc/__init__.py | 94 --------------------- homeassistant/components/lirc/manifest.json | 10 --- homeassistant/generated/integrations.json | 6 -- requirements_all.txt | 3 - requirements_test_all.txt | 3 - script/gen_requirements_all.py | 1 - script/hassfest/quality_scale.py | 2 - tests/components/lirc/__init__.py | 1 - tests/components/lirc/test_init.py | 29 ------- 9 files changed, 149 deletions(-) delete mode 100644 homeassistant/components/lirc/__init__.py delete mode 100644 homeassistant/components/lirc/manifest.json delete mode 100644 tests/components/lirc/__init__.py delete mode 100644 tests/components/lirc/test_init.py diff --git a/homeassistant/components/lirc/__init__.py b/homeassistant/components/lirc/__init__.py deleted file mode 100644 index 6b8e0d08d52..00000000000 --- a/homeassistant/components/lirc/__init__.py +++ /dev/null @@ -1,94 +0,0 @@ -"""Support for LIRC devices.""" - -import logging -import threading -import time - -import lirc - -from homeassistant.const import EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP -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 - -_LOGGER = logging.getLogger(__name__) - -BUTTON_NAME = "button_name" - -DOMAIN = "lirc" - -EVENT_IR_COMMAND_RECEIVED = "ir_command_received" - -ICON = "mdi:remote" - -CONFIG_SCHEMA = cv.empty_config_schema(DOMAIN) - - -def setup(hass: HomeAssistant, config: ConfigType) -> bool: - """Set up the LIRC capability.""" - 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": "LIRC", - }, - ) - # blocking=True gives unexpected behavior (multiple responses for 1 press) - # also by not blocking, we allow hass to shut down the thread gracefully - # on exit. - lirc.init("home-assistant", blocking=False) - lirc_interface = LircInterface(hass) - - def _start_lirc(_event): - lirc_interface.start() - - def _stop_lirc(_event): - lirc_interface.stopped.set() - - hass.bus.listen_once(EVENT_HOMEASSISTANT_START, _start_lirc) - hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, _stop_lirc) - - return True - - -class LircInterface(threading.Thread): - """Interfaces with the lirc daemon to read IR commands. - - When using lirc in blocking mode, sometimes repeated commands get produced - in the next read of a command so we use a thread here to just wait - around until a non-empty response is obtained from lirc. - """ - - def __init__(self, hass): - """Construct a LIRC interface object.""" - threading.Thread.__init__(self) - self.daemon = True - self.stopped = threading.Event() - self.hass = hass - - def run(self): - """Run the loop of the LIRC interface thread.""" - _LOGGER.debug("LIRC interface thread started") - while not self.stopped.is_set(): - try: - code = lirc.nextcode() # list; empty if no buttons pressed - except lirc.NextCodeError: - _LOGGER.warning("Error reading next code from LIRC") - code = None - # interpret result from python-lirc - if code: - code = code[0] - _LOGGER.debug("Got new LIRC code %s", code) - self.hass.bus.fire(EVENT_IR_COMMAND_RECEIVED, {BUTTON_NAME: code}) - else: - time.sleep(0.2) - lirc.deinit() - _LOGGER.debug("LIRC interface thread stopped") diff --git a/homeassistant/components/lirc/manifest.json b/homeassistant/components/lirc/manifest.json deleted file mode 100644 index 64dbee06390..00000000000 --- a/homeassistant/components/lirc/manifest.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "domain": "lirc", - "name": "LIRC", - "codeowners": [], - "documentation": "https://www.home-assistant.io/integrations/lirc", - "iot_class": "local_push", - "loggers": ["lirc"], - "quality_scale": "legacy", - "requirements": ["python-lirc==1.2.3"] -} diff --git a/homeassistant/generated/integrations.json b/homeassistant/generated/integrations.json index a18f784426b..fade566bc4d 100644 --- a/homeassistant/generated/integrations.json +++ b/homeassistant/generated/integrations.json @@ -3575,12 +3575,6 @@ "integration_type": "virtual", "supported_by": "motion_blinds" }, - "lirc": { - "name": "LIRC", - "integration_type": "hub", - "config_flow": false, - "iot_class": "local_push" - }, "litejet": { "name": "LiteJet", "integration_type": "hub", diff --git a/requirements_all.txt b/requirements_all.txt index b78105995fa..5d37615f4ad 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -2487,9 +2487,6 @@ python-kasa[speedups]==0.10.2 # homeassistant.components.linkplay python-linkplay==0.2.12 -# homeassistant.components.lirc -# python-lirc==1.2.3 - # homeassistant.components.matter python-matter-server==8.1.0 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 293bf691389..609c987706f 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -2056,9 +2056,6 @@ python-kasa[speedups]==0.10.2 # homeassistant.components.linkplay python-linkplay==0.2.12 -# homeassistant.components.lirc -# python-lirc==1.2.3 - # homeassistant.components.matter python-matter-server==8.1.0 diff --git a/script/gen_requirements_all.py b/script/gen_requirements_all.py index e85198a6998..b2be1ea4dcb 100755 --- a/script/gen_requirements_all.py +++ b/script/gen_requirements_all.py @@ -27,7 +27,6 @@ EXCLUDED_REQUIREMENTS_ALL = { "bluepy", "evdev", "pybluez", - "python-lirc", } # Requirements excluded by EXCLUDED_REQUIREMENTS_ALL which should be included when diff --git a/script/hassfest/quality_scale.py b/script/hassfest/quality_scale.py index 5df80de4b5c..1b6bba0c9a3 100644 --- a/script/hassfest/quality_scale.py +++ b/script/hassfest/quality_scale.py @@ -571,7 +571,6 @@ INTEGRATIONS_WITHOUT_QUALITY_SCALE_FILE = [ "linksys_smart", "linode", "linux_battery", - "lirc", "litejet", "livisi", "llamalab_automate", @@ -1594,7 +1593,6 @@ INTEGRATIONS_WITHOUT_SCALE = [ "linksys_smart", "linode", "linux_battery", - "lirc", "litejet", "livisi", "llamalab_automate", diff --git a/tests/components/lirc/__init__.py b/tests/components/lirc/__init__.py deleted file mode 100644 index f8e11b194a6..00000000000 --- a/tests/components/lirc/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""LIRC tests.""" diff --git a/tests/components/lirc/test_init.py b/tests/components/lirc/test_init.py deleted file mode 100644 index 7cc430d8dd0..00000000000 --- a/tests/components/lirc/test_init.py +++ /dev/null @@ -1,29 +0,0 @@ -"""Tests for the LIRC.""" - -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", lirc=Mock()) -async def test_repair_issue_is_created( - hass: HomeAssistant, - issue_registry: ir.IssueRegistry, -) -> None: - """Test repair issue is created.""" - from homeassistant.components.lirc 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