A really noddy question here but I’ve tried a few things and cannot figure it out.
I want to display how much electricity I have exported today in pounds/pence with 2 decimal places, but I cannot figure it out, the entity card typically only displays a single decimal place unless the value is something like 2.35, eg:
The above template works fine in the Developers Tool template tester but not on the dashboard. I thought defining device_class: monetary would help but it didn’t
You could create a template sensor for display only, forcing the state to a string by adding the units on the end. Bit ugly, but it’s the best you can do:
Logger: homeassistant.helpers.template_entity
Source: helpers/template_entity.py:408
First occurred: 15:40:30 (1 occurrences)
Last logged: 15:40:30
TemplateError('ValueError: Unknown format code 'f' for object of type 'str'') while processing template 'Template<template=({{ 'Testing ' ~ '{:.2f}'.format(states('sensor.exported_electricity_today')) ~ 'test' }}) renders=4>' for attribute '_attr_native_value' in entity 'sensor.testing_string'
I think that means it believes my sensor.exported_electricity_today is a string not an integer hence can’t run the format on it?