I have created this prototype to explain how the task can be solved.
Let us say, that the MQTT feed comprises of below models.
Also, assume that the feed supports below interface.
I have designed a Statistics module to Count the Smart Badges by Area.
This module queries the feed and computes the count.
The Unit Test project tests this module.