Stop using make_command in LG Infrared (#170149)

This commit is contained in:
Abílio Costa
2026-05-09 00:24:51 +03:00
committed by GitHub
parent 74fabca890
commit 27969c34a5
2 changed files with 8 additions and 7 deletions
@@ -2,7 +2,7 @@
import logging
from infrared_protocols.codes.lg.tv import LGTVCode, make_command as make_lg_tv_command
from infrared_protocols.codes.lg.tv import LGTVCode
from homeassistant.components.infrared import async_send_command
from homeassistant.config_entries import ConfigEntry
@@ -71,6 +71,6 @@ class LgIrEntity(Entity):
await async_send_command(
self.hass,
self._infrared_entity_id,
make_lg_tv_command(code),
code.to_command(),
context=self._context,
)
+6 -5
View File
@@ -71,15 +71,16 @@ def platforms() -> list[Platform]:
@pytest.fixture
def mock_make_lg_tv_command() -> Generator[None]:
"""Patch make_command to return the LGTVCode directly.
def mock_lg_tv_code_to_command() -> Generator[None]:
"""Patch LGTVCode.to_command to return the LGTVCode directly.
This allows tests to assert on the high-level code enum value
rather than the raw NEC timings.
"""
with patch(
"homeassistant.components.lg_infrared.entity.make_lg_tv_command",
side_effect=lambda code, **kwargs: code,
"homeassistant.components.lg_infrared.entity.LGTVCode.to_command",
autospec=True,
side_effect=lambda self, **kwargs: self,
):
yield
@@ -89,7 +90,7 @@ async def init_integration(
hass: HomeAssistant,
mock_config_entry: MockConfigEntry,
mock_infrared_entity: MockInfraredEntity,
mock_make_lg_tv_command: None,
mock_lg_tv_code_to_command: None,
platforms: list[Platform],
) -> MockConfigEntry:
"""Set up the LG Infrared integration for testing."""