What is the best way to do some math and show the result on a dashboard?

So I have a water tank that I added a sensor to that tells me the water level as a percentage. I have that on the Kiosk dashboard I have. What I would like to add next to it is the number of gallons left in the tank, which is simply ((Water Tank Leve)/100)*165. What is the best way to do that math and put it on my dashboard?

Right now for the current tank water level I’m displaying it with the “mini-graph-card”

I was thinking of using a helper and then an automation to set it but how to build the automation is not clear to me.

Any thoughts/help/pointers would be appreciated.

Drew

Create a template sensor

template:
  - sensor:
      - name: "Water Tank Volume"
        unit_of_measurement: "gal"
        state: >
          {{ (states('sensor.water_tank_level') | float(0) / 100) * 165 }}
1 Like

If you want to to use the result of that calculation throughout HA or see the history of your “Water Tank Volume” over time then you should do what Didgeridrew showed above.

If you just want to show the current result of that calculation in the one dashboard and have no plans to use it anywhere else then alternatively you can use a markdown card like this:

type: markdown
title: Water Tank Volume
content: "{{ (states('sensor.water_tank_level') | float(0) / 100) * 165 }} gal"
2 Likes

Oh boy, I cannot believe I did not think of that…

Thanks, I did @Didgeridrew solution and since implementing it I found I have a slow leak someplace… Now I get to find that.

I will keep the markdown card in mind.

Hi, the last two posts in this topic

Water Tank Level - Dynamic Icons