Not sure if applies to the Pi 2 B, but there’s a bunch of information about GPIO on a Pi 3 and 4 here:
and here:
Summary: HA doesn’t do GPIO pins well.