Automation based on tablet battery level

I have a Fire HD tablet (on LieneageOS :)) which I am going to wall mount to use with HA
I have it hardwired to power with a wifi switch in between the mains and the tablet that I can toggle on and off so that the tablet is not constantly charging.

How can I go about getting the tablet battery level in HA?

I should then be ok to create an automation that says if battery is < 20% turn on the wifi switch and then turn it back off when the battery is at > 90%

There’s a couple of ways of doing this. The simplest is probably to use a device tracker app such as GPS Logger or OwnTracks. Those will create an entity, one attribute of which will be the battery level.

You could also use Tasker to push the battery level at intervals, but that would require more work on your part.