Unit of measurement issue - Dollar Sign placement

I have searched far and wide but I cannot find a solution to move the dollar sign before the value, not after. Eg. Home Assistant displays ‘100 $’ instead of ‘$100’. Small detail I know, but I am setting up a whole page of energy costs and it looks silly. Does anyone know a solution?

You could create template sensors:
https://www.home-assistant.io/components/sensor.template/
Just add a $ sign before each state. So {{’$’+states.input_number.your_entity.state}}. It would create a new sensor with the value formatted with a $ sign before the number.

Thanks! I’m trying to add it at the start of a long equation and I can’t get it working with any of these

{{’$’+(float(states.sensor.fridge_monthly_average.state)…
{{’$’(float(states.sensor.fridge_monthly_average.state)…
{{ $ (float(states.sensor.fridge_monthly_average.state)…
{{ ’$’ + (float(states.sensor.fridge_monthly_average.state)…

Any ideas?

Hi! Maybe this?

{{ '$%.1f'|format(states.sensor.fridge_monthly_average.state) }}

good luck!

Thank you!
{{ '$%.1f'|format (float(states.sensor.dishwasher_monthly_average.state) }}

Is what got it to work in the end. Unfortunately the Big Number Card in Lovelace no longer displays a bar graph. I wonder if there is a way to add the dollar sign in Lovelace?
It would be great if ‘unit of measurement:’ is a currency the symbol would automatically be placed before the value.

No idea about Lovelace yet. Maybe you could get more help opening a new thread in the Lovelace section or tagging this one (I don’t know if this is possible). Good luck!

EDIT: BTW, translating energy consumption into costs is something I have in my to-do list. Congrats for your wonderful setup!

I am having the same issue trying to get a $ in front of a value. Here is what I have now:

      power_cost_today_d:
        friendly_name: "Power Cost Today $" 
        value_template: '{{ (states.sensor.power_cost_today.state) | float / 100 }}'

Whenever I try to put any formatting in this, I get an error. for example:

        value_template: '{{  '$%.1f'|format (float(states.sensor.power_cost_today.state))  }}'

and any other variation I have tried always gives error. What is the proper format to add $ at front?

Why not just set the dollar at the start of the value_template string like this:

value_template: '${{ (states.sensor.power_cost_today.state) | float / 100 }}' 

At least that works for me

3 Likes

When using this method and creating another sensor to show the total cost like this:

value_template: '${{ ((states.sensor.power1_cost_today.state) | float)  + ((states.sensor.power2_cost_today.state) | float) }}' 

It always calculates the value to $0