Smart battery