How to toggle the visibility of an icon depending on its state?

I have about 70 entities dynamically created by a monitoring system (and their state updated periodically). They are not configured in Home Assistant configuration files.

Most of the states are ok (hopefully all of them), but when a state is ko I would like an icon for that state to appear (and disappear when the state is back to ko).

I am completely open to the way it is done (I would like to just avoid badges at the top of a tab, as I use that area to display statuses such as temperatures). I use both

  • an external program to monitor the availability of my home devices and Home Assistant as the state manager (the program does a POST to the API)
  • and Appdaemon to manage automations

so if there is a need to send something somewhere I am all for it. I just do not know how to approach the problem.

I saw that there was the possibility to set the visibility of whole groups (https://www.home-assistant.io/docs/configuration/group_visibility/) but I need to work on the level of an entity.