In South Africa our water is billed on a sliding scale based on consumption.
0 - 10kl - $1 per kl
10kl - 20kl $2 per kl (plus the $1 per kl fr the first 10kl)
20kl - 30kl 4# per kl (plus the $110kl and 210kl)
And so on. I’m pretty sure there’s no mechanism in HA to support this calculation natively. What’s my best option to caclulate water costs? I figure I could write a script, using helper variables to contain the cost for each usage bucket, but not sure how to elegantly call the script and write a value back that can be used by the built in dashboards.
Pass your total water consumption sensor into a utility meter, configured with 3 tariffs, you can call them rate_1, rate_2, rate_3.
This will give you 3 water sensors, one per rate. Add each of these to the energy board, with a fixed price of $1, $2, $4 respectively.
The utility meter creates a select entity that picks the active rate. At the start of the billing cycle, set the select back to rate_1. When the rate_1 sensor exceeds 10kL, automate the select to switch to rate_2. When the rate_2 sensor exceeds 10kL, switch the select to rate_3.