Color part of a number

First of Happy New Year and the best of wishes to you all.

Yesterday I’ve managed, after some trial and error, to hook up a LJ18A3-8-Z/BX-5V to a Sonoff Basic R2 (v1.3) and mount it on a Sensus 620 watermeter. The Sonoff I’ve flashed with Tasmota, I’ve set the counter to the value on the meter and it works like a charm.

But now the most interesting part. The Sensus 620 has several black digits and 3 red, how can I make it appear in Home Assistant the same way as on the watermeter?

If you wanted to make the last 3 numbers smaller, you could use a markdown card like this:

type: markdown
content: >-
  {% set value = states('sensor.whatever') | int %}

  {{ (value / 1000) | int }}<small>{{ value % 1000 }}</small>

However, it seems like you cannot use inline css to make the text red. You might want to take a look at card-mod to add custom css. I’m sure there’s probably a better way, but this seemed to me like the easiest solution.

1 Like