How to change the color of a plain circle icon depending on the state of an autodisovered sensor?

I believe that what I want to achieve is not difficult, having seen bits and pieces of the solution in other answers. The problem is that I do not know how to pull them together in my configuration


I am writing an extension to simplemonitor so that monitoring events are sent to MQTT.

I format these events to follow HA MQTT Disovery scheme so I am free to put there whatever is best, HA-wise. Currently this is (for one monitoring element, there are more - this one is called failing-name)

  • homeassistant/binary_sensor/simplemonitor_failing-name/config with a payload of {"name": "failing-name"}
  • homeassistant/binary_sensor/simplemonitor_failing-name/state with a payload of 0, 1 or 2 (see below for the context)

(again - I am open to chnag any of these to whatever is best)

The test monitor is auto-discovered and I see it in a Glance Card:



  1. How should I approach the coloring of the circle ? It should be a green circle when the payload is 0 (or another payload if more practical), a gray circle when the payload is 2 and a plain red when it is 1 - to clearly differentiate between the states

  2. My entities are auto-discovered: how can I apply the setting above for all of them? I guess that this will go though customize_glob, right? In that case, the entity names will be matched, right? If this is the case I will have to prefix the entity names with simplemonitor_ to make sure it works.