I think I’ve tried something similar. I’ve got a watermeter that is counting liters and I wanted HA to display it like on the watermeter itself; cubic meters in black the rest in red.
* `round(precision, "floor", default)` will always round down to `precision` decimals
* `round(precision, "ceil", default)` will always round up to `precision` decimals
* `round(1, "half", default)` will always round to the nearest .5 value. `precision` should be 1 for this mode
That’s due to a mistake I made. Template Sensors in modern format use state not value_template as was used in legacy format. I have corrected the example I posted above.
If you are creating new Template Sensors then I recommend you define them using modern format as opposed to legacy format. Legacy format wasn’t deprecated but it doesn’t have the additional features supported by modern format and won’t receive enhancements.