Repository: home-assistant/core
File: tests/components/intent/test_timers.py (Python)

Code before:
    hass: HomeAssistant, init_components
) -> None:
    """Test starting a timer with a conversation command skips validation for non-default agents."""
    device_id = "test_device"
    timer_name = "test timer"
    invalid_command = "invalid command that does not exist"
    agent_id = "conversation.test_llm_agent"

    # This should NOT raise an error because validation is skipped for all non-default agents
    result = await intent.async_handle(
        hass,
        "test",
        intent.INTENT_START_TIMER,
        {
            "name": {"value": timer_name},
            "seconds": {"value": 5},
            "conversation_command": {"value": invalid_command},
        },
        device_id=device_id,
        conversation_agent_id=agent_id,
    )

    assert result.response_type == intent.IntentResponseType.ACTION_DONE

    # Verify timer was created successfully despite invalid command
    timer_manager = hass.data["intent.timer"]
    assert len(timer_manager.timers) == 1


async def test_pause_unpause_timer_disambiguate(
    hass: HomeAssistant, init_components
) -> None:
    """Test disamgibuating timers by their paused state."""
    device_id = "test_device"
    started_timer_ids: list[str] = []
    paused_timer_ids: list[str] = []
    unpaused_timer_ids: list[str] = []

    started_event = asyncio.Event()
    updated_event = asyncio.Event()

    @callback
    def handle_timer(event_type: TimerEventType, timer: TimerInfo) -> None:
        if event_type == TimerEventType.STARTED:
            started_event.set()
            started_timer_ids.append(timer.id)
        elif event_type == TimerEventType.UPDATED:
            updated_event.set()
            if timer.is_active:
                unpaused_timer_ids.append(timer.id)
            else:

Review comment (suggestion):
```suggestion
    timer_manager = hass.data[TIMER_DATA]
```

Code after:
        {
            "name": {"value": timer_name},
            "seconds": {"value": 5},
            "conversation_command": {"value": invalid_command},
        },
        device_id=device_id,
        conversation_agent_id=agent_id,
    )

    assert result.response_type == intent.IntentResponseType.ACTION_DONE

    # Verify timer was created successfully despite invalid command
    timer_manager = hass.data[TIMER_DATA]
    assert len(timer_manager.timers) == 1


async def test_pause_unpause_timer_disambiguate(
    hass: HomeAssistant, init_components
) -> None:
    """Test disamgibuating timers by their paused state."""
    device_id = "test_device"
    started_timer_ids: list[str] = []
    paused_timer_ids: list[str] = []
    unpaused_timer_ids: list[str] = []

    started_event = asyncio.Event()
    updated_event = asyncio.Event()

    @callback
    def handle_timer(event_type: TimerEventType, timer: TimerInfo) -> None:
        if event_type == TimerEventType.STARTED:
            started_event.set()
            started_timer_ids.append(timer.id)
        elif event_type == TimerEventType.UPDATED:
            updated_event.set()
            if timer.is_active:
                unpaused_timer_ids.append(timer.id)
            else:
                paused_timer_ids.append(timer.id)

    async_register_timer_handler(hass, device_id, handle_timer)

    result = await intent.async_handle(
        hass,
        "test",
        intent.INTENT_START_TIMER,
        {"minutes": {"value": 5}},
        device_id=device_id,
    )
    assert result.response_type == intent.IntentResponseType.ACTION_DONE