reynos
February 28, 2018, 7:46pm
1
Hey all, I’ve got a sensor value such as:
10283.0
and i want it to appear as
10,283
(i.e. no decimals and “thousands” commas added). Can anyone suggest a value template that will do this - at least just dropping the “.0” but commas would be lovely too!
Thanks in advance.
covrig
(Covrig)
February 28, 2018, 7:57pm
2
{{"{:,}".format(states('sensor.test')|int)}}
Here you go
{{ "${:,.0f}".format(10283.0) }}
reynos
March 1, 2018, 3:58am
4
many thanks both!
here’s the yaml that worked for me:
- platform: template
sensors:
template_x5_xdrive30d_mileage:
friendly_name: "Odometer"
unit_of_measurement: "kms"
value_template: >
{{"{:,}".format(states('sensor.x5_xdrive30d_mileage')|int)}}
robermf
(Roberto)
November 12, 2019, 7:15am
5
Hello.
I need something similar. I have tried to figure out how to make work for me your solution without success.
I need change values like 4852 to 48,52. Someone can help me?
Thank you in advance.
BrianM
(Brian)
October 29, 2020, 5:24pm
6
How would I apply this to a card? Specifically the entities card. I tried this, but get an error every time:
type: entities
entities:
- entity: sensor.us_coronavirus_confirmed
value_template: >
{{"{:,}".format(states('sensor.us_coronavirus_confirmed')|int)}}
- entity: sensor.us_coronavirus_current
- entity: sensor.us_coronavirus_deaths
- entity: sensor.us_coronavirus_recovered
title: Corona Virus Stats
state_color: true
show_header_toggle: false