I don’t know the answer to your question, but I’d suggest that you accomplish your counting in OH, not in habpanel. Doing it there ties it to that interface, and reduces your flexibility in the future. If and when you upgrade to OH3, you might find that you prefer MainUI.
There’s a current discussion about counting group members. Obviously the UI stuff won’t work since that’s specific to OH3, but there are some methods for text-based configuration mentioned. I don’t know what will or will not work in your very old OH2.2 system, though.