After some more experimenting it doesn't seem to be related to the battery level.
I've noticed that the smart cover function doesn't work after charging or after having the iPad on top of the microwave oven.
It looks like if the screen is on for a while, like watching a video, then the functionality returns. Maybe having the screen off for a long time is the problem?
My understanding is that the glass and the screen are separate in the iPad mini 2. Is the cover sensor built into the glass or the screen?