Water cost calcuation incorrect

Summary
Energy dashboard does not calculate costs for water correctly. The unit conversion for the quantity of water correct, but the unit conversion for cost seems to be incorrect.

System: Home Assistant 2023.5.4, Supervisor 2023.04.1, Operating System 10.2, Frontend 20230503.3 - latest

Details
My water meter is implemented with a template sensor measured in (the ridiculous unit of) hundred cubic feet, CCF.

Water costs US$17.61/CCF and this is what I’ve entered on the dashboard configuration card:

In liters this is a unit rate of $0.006219/liter.

On the energy dashboard we can see the rate being used is ($8.23 / 467.2L ) = $0.01761/liter
image

Question
Is this a bug or am I just being dense?

It looks like the conversion is simply dividing by 1000, mistakenly converting from cubic meters to liters? There are about 2831.7 liters per CCF.

This only seems to affect the water tracking on the energy dashboard. My gas utility is also measured in CCF and the costs are in $/CCF just like water. However, the quantity and cost conversions are correct for gas.

It’s not a bug. The math is your current momentary value multiplied by the current momentary price and then summed together. You are most likely missing a price for the bulk of your water values. I’m assuming you added the price much later. Anyways, just wait and the values will be in line with what you expect.

Five days later and nothing has changed. Water cost calculation is still using the incorrect rate of $6.93 / 393.7 liter = $0.0176/liter.

image

I noticed that the recorder statistic has units of cubic meters, even though the sensor is explicitly in units of CCF:

I’ve tried deleting the sensor and it’s cost tracker, rebooting, and re-creating them, but it still creates this statistic with units of m3, not CCF as it should.

My natural gas sensors have similar sensors and statistics, but their units are correct:

It looks like there’s a unit problem somewhere and I’m unsure of how to fix this or where to look to troubleshoot it.

(I would track water costs in liters if I could, but I can’t enter a unit cost less than $0.01)

Any ideas?

You still need the price in the database. I have a sensor that just simply outputs the price per liter and I have it recording in the database. That way, when it rolls up the liters * price, it has a value to multiply against instead of multiplying against zero.