Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95919

Sensors - how to change number display style/precision "on the fly"?

$
0
0

@pejotigrek wrote:

in case of my topic wasn’t too clear, here’s the explaination of my question:
I’ve got a sensor that reads from the water meter. let’s call it sensor.water_read. it is numeric and looks like this: 123456, with the liter as display unit.
when the invoice guy comes to ask for readouts, he needs cubic meters, so in case of sensor.water_read it’s just 123.
I want to display the sensor.water_read in a nice form, but also keep the original numbers for other calculations [like daily/monthly stats, sprinkler useage etc.]. so until now I used sensor.water_read for calculations and I had an additional template sensor, let’s call it sensor.water_display, with below config - just for making it nice in lovelace.

- platform: template
    sensors:
      water_display:
        value_template: "{{ '{0:,}'.format(states('sensor.water_read')|int/1000)|replace(',',' ')|replace('.',',') }}"
        unit: "m³"

and it gave me a nice 123,456 m3 as output in the dashboard.

but that solution isn’t perfect - because it duplicates the sensor just for sake of displaying it another way - so I wonder, if there’s a way to set some options to display the sensor in way I want [with comma and different unit etc.] but within the very same entity? without duplicating it with template sensor? like reformatting it on-the-fly?

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 95919

Trending Articles