For a totally accessible answer this article is hard to beat IMO: https://theprepared.com/blog/booby-trap-laws/
It gets to the core issue, which is that the laws as written are pretty vague, but the jurisprudence is overwhelmingly in favor of siding against booby traps. It's illegal at the federal level, and as far as I'm aware prohibited by all states as well, either explicitly or more usually through precedent in court. The reasoning of the courts seems to be more or less identical: it's a dangerous destructive device incapable of making the sort of prudent judgement required for a use of force. In short, it's an irresponsible and indiscriminate use of force.
Now you asked about Illinois in particular, so here's the relevant statute there: https://www.ilga.gov/legislation/ilcs/ilcs4.asp?DocName=0720...
If you had a robot dog instead, not so much.
Assault is not great, but the necessary response is a function of a low trust society. Better to be safe than experience loss to life and property.