Battery automatic detection and refilling