diff --git a/homeassistant/components/lg_infrared/entity.py b/homeassistant/components/lg_infrared/entity.py index 1d1a958b975f..fb67d6572ac0 100644 --- a/homeassistant/components/lg_infrared/entity.py +++ b/homeassistant/components/lg_infrared/entity.py @@ -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, ) diff --git a/tests/components/lg_infrared/conftest.py b/tests/components/lg_infrared/conftest.py index 92c10b710ae8..24e6399d8a9e 100644 --- a/tests/components/lg_infrared/conftest.py +++ b/tests/components/lg_infrared/conftest.py @@ -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."""