diff --git a/homeassistant/components/unifiprotect/select.py b/homeassistant/components/unifiprotect/select.py index be4984e35519..363f4d3c6add 100644 --- a/homeassistant/components/unifiprotect/select.py +++ b/homeassistant/components/unifiprotect/select.py @@ -192,15 +192,14 @@ async def _set_paired_camera(obj: Light | Sensor, camera_id: str) -> None: async def _set_doorbell_message(obj: Camera, message: str) -> None: if message.startswith(DoorbellMessageType.CUSTOM_MESSAGE.value): message = message.rsplit(":", maxsplit=1)[-1] + # reset_at=None keeps the message up until it is changed await obj.set_lcd_message_public( - DoorbellMessageType.CUSTOM_MESSAGE, text=message + DoorbellMessageType.CUSTOM_MESSAGE, text=message, reset_at=None ) elif message == TYPE_EMPTY_VALUE: - # Public API has no endpoint to clear the LCD message; fall back to - # the non-deprecated legacy helper. - await obj.set_lcd_text(None) + await obj.set_lcd_message_public(None) else: - await obj.set_lcd_message_public(DoorbellMessageType(message)) + await obj.set_lcd_message_public(DoorbellMessageType(message), reset_at=None) async def _set_liveview(obj: Viewer, liveview_id: str) -> None: diff --git a/homeassistant/components/unifiprotect/text.py b/homeassistant/components/unifiprotect/text.py index 1300dc0029a9..2ffde3182f0c 100644 --- a/homeassistant/components/unifiprotect/text.py +++ b/homeassistant/components/unifiprotect/text.py @@ -42,7 +42,10 @@ def _get_doorbell_current(obj: Camera) -> str | None: async def _set_doorbell_message(obj: Camera, message: str) -> None: - await obj.set_lcd_text(DoorbellMessageType.CUSTOM_MESSAGE, text=message) + # reset_at=None keeps the message up until it is changed + await obj.set_lcd_message_public( + DoorbellMessageType.CUSTOM_MESSAGE, text=message, reset_at=None + ) CAMERA: tuple[ProtectTextEntityDescription, ...] = ( diff --git a/tests/components/unifiprotect/test_select.py b/tests/components/unifiprotect/test_select.py index 8436315d6cee..535dd9b06e6f 100644 --- a/tests/components/unifiprotect/test_select.py +++ b/tests/components/unifiprotect/test_select.py @@ -649,8 +649,10 @@ async def test_select_set_option_camera_doorbell_custom( blocking=True, ) + # reset_at=None keeps the message up; omitting it lets the NVR + # clear it after its own timeout mock_method.assert_called_once_with( - DoorbellMessageType.CUSTOM_MESSAGE, text="Test" + DoorbellMessageType.CUSTOM_MESSAGE, text="Test", reset_at=None ) @@ -666,14 +668,9 @@ async def test_select_set_option_camera_doorbell_unifi( hass, Platform.SELECT, doorbell, CAMERA_SELECTS[2] ) - with ( - patch_ufp_method( - doorbell, "set_lcd_message_public", new_callable=AsyncMock - ) as mock_public, - patch_ufp_method( - doorbell, "set_lcd_text", new_callable=AsyncMock - ) as mock_legacy, - ): + with patch_ufp_method( + doorbell, "set_lcd_message_public", new_callable=AsyncMock + ) as mock_method: await hass.services.async_call( "select", "select_option", @@ -684,20 +681,10 @@ async def test_select_set_option_camera_doorbell_unifi( blocking=True, ) - mock_public.assert_called_once_with(DoorbellMessageType.LEAVE_PACKAGE_AT_DOOR) - - await hass.services.async_call( - "select", - "select_option", - { - ATTR_ENTITY_ID: entity_id, - ATTR_OPTION: "Default Message (Welcome)", - }, - blocking=True, + mock_method.assert_called_once_with( + DoorbellMessageType.LEAVE_PACKAGE_AT_DOOR, reset_at=None ) - mock_legacy.assert_called_once_with(None) - async def test_select_set_option_camera_doorbell_default( hass: HomeAssistant, ufp: MockUFPFixture, doorbell: Camera @@ -712,7 +699,7 @@ async def test_select_set_option_camera_doorbell_default( ) with patch_ufp_method( - doorbell, "set_lcd_text", new_callable=AsyncMock + doorbell, "set_lcd_message_public", new_callable=AsyncMock ) as mock_method: await hass.services.async_call( "select", diff --git a/tests/components/unifiprotect/test_text.py b/tests/components/unifiprotect/test_text.py index 4e3a2fc06ca0..b8a4d1de5b62 100644 --- a/tests/components/unifiprotect/test_text.py +++ b/tests/components/unifiprotect/test_text.py @@ -78,7 +78,7 @@ async def test_text_camera_set( ) with patch_ufp_method( - doorbell, "set_lcd_text", new_callable=AsyncMock + doorbell, "set_lcd_message_public", new_callable=AsyncMock ) as mock_method: await hass.services.async_call( "text", @@ -88,5 +88,5 @@ async def test_text_camera_set( ) mock_method.assert_called_once_with( - DoorbellMessageType.CUSTOM_MESSAGE, text="Test test" + DoorbellMessageType.CUSTOM_MESSAGE, text="Test test", reset_at=None )