MQTT - Lovelace Card Dynamic Creation

I would like to update one of my views based on an MQTT topic.

I’m creating a network of ESP32 sensors and want to add or remove a card type when a device is added or removed from the network. I was thinking of updating a topic over MQTT. Essentially I want to add or remove a histogram card when a sensor is added to a topic.

can anyone run me though how to accomplish this?