pmiles156
(Pmiles156)
February 1, 2021, 8:33am
1
Could someone please shed some light on this for me. I want to move the £ to the front 0.09 (£ 0.09)
This is my template and I know I could put the £ sign in my template like this
{{ £ ((states('sensor.ftank_daily_energy_usage_peak') | float * 0.1863)
but this affects my mini graph and it just displays NaN.
- platform: template
sensors:
ftank_cost_daily:
friendly_name: "Fish Tank Energy Cost Today"
icon_template: mdi:currency-gdp
value_template: "{{ ((states('sensor.ftank_daily_energy_usage_peak') | float * 0.1863) + (states('sensor.ftank_daily_energy_usage_offpeak') | float) * 0.0936 ) | round(2) }}"
What are my options?
Also, this is supposed to display 0.10 but I’m seeing this.
Thank you in advance
petro
(Petro)
February 1, 2021, 11:47am
2
Your only option is to make a custom card. That already appears to be a custom button card, so you’ll need to adjust the css and move the units in front of the value for that particular card.
apmillen
(Andy)
February 1, 2021, 11:57am
3
You can also bake it into your template - although you won’t be able to graph it from that as it will become a text sensor:
platform: template
sensors:
house_power_cost:
friendly_name: House Power Cost
value_template: >
£{{ "%.2f" | format(((states('sensor.daily_house_power_monitor_energy') | float * 0.1560) | float + 0.2)) }}
1 Like
petro
(Petro)
February 1, 2021, 12:01pm
5
I feel like no one read this line from OP
Hence why his only option is to adjust the button itself.
apmillen
(Andy)
February 1, 2021, 12:04pm
6
You’re right. I did ignore that
pmiles156
(Pmiles156)
February 1, 2021, 12:32pm
7
thanks for all your help with this so far. So ignoring the mini graph issue how would I get my template to look like this £0.20
- platform: template
sensors:
ftank_cost_daily:
friendly_name: "Fish Tank Energy Cost Today"
icon_template: mdi:currency-gdp
value_template: "{{ ((states('sensor.ftank_daily_energy_usage_peak') | float * 0.1863) + (states('sensor.ftank_daily_energy_usage_offpeak') | float) * 0.0936 ) | round(2) }}"
- platform: template
sensors:
ftank_cost_daily:
friendly_name: "Fish Tank Energy Cost Today"
icon_template: mdi:currency-gdp
value_template: "£{{ ((states('sensor.ftank_daily_energy_usage_peak') | float * 0.1863) + (states('sensor.ftank_daily_energy_usage_offpeak') | float) * 0.0936 ) | round(2) }}"
pmiles156
(Pmiles156)
February 1, 2021, 1:52pm
9
ok, will that stop it from displaying £0.1 when it should be £0.10?
petro
(Petro)
February 1, 2021, 1:58pm
10
not necessarily.
This will, it’ll also add comma’s every thousand.
- platform: template
sensors:
ftank_cost_daily:
friendly_name: "Fish Tank Energy Cost Today"
icon_template: mdi:currency-gdp
value_template: >
{{ '£{:,.2f}'.format(((states('sensor.ftank_daily_energy_usage_peak') | float * 0.1863) + (states('sensor.ftank_daily_energy_usage_offpeak') | float) * 0.0936 ) | round(2)) }}
pmiles156
(Pmiles156)
February 1, 2021, 5:12pm
11
Ok, thank you all for your help today. So what I have done to get both the Mini graph and for it to display £ 0.00 is created 3 templates.
1 for Daily usage displaying £ 0.00
1 for Daily Usage (Mini Graph)
1 for Monthly Usage displaying £ 0.00
this is my code
########## Fish Tank Costs ##########
- platform: template
sensors:
ftank_cost_daily:
friendly_name: "Today's Total FishTank Cost"
icon_template: mdi:currency-gbp
value_template: "{{ '£ {:,.2f}'.format(((states('sensor.ftank_daily_energy_usage_peak') | float * 0.1863) + (states('sensor.ftank_daily_energy_usage_offpeak') | float) * 0.0936 ) | round(2)) }}"
########## Fish Tank Cost (Mini Graph) ##########
- platform: template
sensors:
ftankmg_cost_daily:
friendly_name: "Today's Total FishTank Cost"
unit_of_measurement: '£'
icon_template: mdi:currency-gbp
value_template: "{{ ((states('sensor.ftank_daily_energy_usage_peak') | float * 0.1863) + (states('sensor.ftank_daily_energy_usage_offpeak') | float) * 0.0936 ) | round(2) }}"
- platform: template
sensors:
ftank_cost_monthly:
friendly_name: "Monthly Total FishTank Cost"
icon_template: mdi:currency-gbp
value_template: "{{ '£ {:,.2f}'.format(((states('sensor.ftank_monthly_energy_usage_peak') | float * 0.1863) + (states('sensor.ftank_monthly_energy_usage_offpeak') | float) * 0.0936 ) | round(2)) }}"
and this is my output
Not sure what other options I have.
petro
(Petro)
February 1, 2021, 5:20pm
12
Is that the custom button card?
If so, post the configuration.
pmiles156
(Pmiles156)
February 1, 2021, 5:25pm
13
No this is an Entity Card that is being used within a grid card.
petro
(Petro)
February 1, 2021, 5:27pm
14
Ok, then your only option is what you did.
pmiles156
(Pmiles156)
February 1, 2021, 5:28pm
15
I’m assuming you was thinking this customized with some CSS?
I haven’t got that far yet, still learning the basics. Do you have any examples that would help me with the CSS?
petro
(Petro)
February 1, 2021, 5:30pm
16
Yes and no. The custom button card lets you layout anything in any order using yaml to adjust the css. The layout you have is a typical button card layout. You could make a custom:button-card template and then use the template whenever you want currency displayed. Without needing template sensors.
pmiles156
(Pmiles156)
February 1, 2021, 5:32pm
17
Whoosh straight over my head, I will have to do some more investigation once I get 5 mins. Thanks for all your help tho.
pmiles156
(Pmiles156)
February 2, 2021, 8:07am
18
Every Thousand? how much do think my Fishtank costs to run LOL
petro
(Petro)
February 2, 2021, 12:29pm
19
Lol, it’s partly for others who come to this page for the same thing. It won’t hurt you, but if you get that high, it’ll be formatted properly!
pmiles156
(Pmiles156)
February 2, 2021, 5:39pm
20
understood I was only joking thanks for all your help.
Regards
This is what I did to calculate my utilities:
- platform: template
sensors:
monthly_water:
friendly_name: "Monthly Water Usage"
value_template: "{{ '$ {:,.2f}'.format(states('sensor.flume_sensor_stylus_current_month') | float(0) * 0.008760086197216 | float(0) | round(2)) }}"