From 6c5ca58405bea0a723183f0fcc75959586261eab Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Thu, 14 Dec 2023 15:53:22 -0600 Subject: [PATCH] Set todo item status in intent (#105743) --- homeassistant/components/todo/intent.py | 6 ++++-- tests/components/todo/test_init.py | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/todo/intent.py b/homeassistant/components/todo/intent.py index ba3545d8dfd..4cf62c6391d 100644 --- a/homeassistant/components/todo/intent.py +++ b/homeassistant/components/todo/intent.py @@ -6,7 +6,7 @@ from homeassistant.helpers import intent import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity_component import EntityComponent -from . import DOMAIN, TodoItem, TodoListEntity +from . import DOMAIN, TodoItem, TodoItemStatus, TodoListEntity INTENT_LIST_ADD_ITEM = "HassListAddItem" @@ -47,7 +47,9 @@ class ListAddItemIntent(intent.IntentHandler): assert target_list is not None # Add to list - await target_list.async_create_todo_item(TodoItem(item)) + await target_list.async_create_todo_item( + TodoItem(summary=item, status=TodoItemStatus.NEEDS_ACTION) + ) response = intent_obj.create_response() response.response_type = intent.IntentResponseType.ACTION_DONE diff --git a/tests/components/todo/test_init.py b/tests/components/todo/test_init.py index 90b06858e00..0edca7a7ef6 100644 --- a/tests/components/todo/test_init.py +++ b/tests/components/todo/test_init.py @@ -1038,6 +1038,7 @@ async def test_add_item_intent( assert len(entity1.items) == 1 assert len(entity2.items) == 0 assert entity1.items[0].summary == "beer" + assert entity1.items[0].status == TodoItemStatus.NEEDS_ACTION entity1.items.clear() # Add to second list @@ -1052,6 +1053,7 @@ async def test_add_item_intent( assert len(entity1.items) == 0 assert len(entity2.items) == 1 assert entity2.items[0].summary == "cheese" + assert entity2.items[0].status == TodoItemStatus.NEEDS_ACTION # List name is case insensitive response = await intent.async_handle( @@ -1065,6 +1067,7 @@ async def test_add_item_intent( assert len(entity1.items) == 0 assert len(entity2.items) == 2 assert entity2.items[1].summary == "wine" + assert entity2.items[1].status == TodoItemStatus.NEEDS_ACTION # Missing list with pytest.raises(intent.IntentHandleError):