I recently had solar installed on my house, so of course I quickly integrated the EnPhase system into the HA Energy dashboard. That motivated me to finally attempt to integrate my TankUtility ( https://tankutility.com/) WiFi propane tank monitor into the Energy dashboard as well. I ran into a number of problems along the way, all based on my lack of understanding of how long-term statistics actually work within HA, and what kinds of sensors and statistics the Energy dashboard requires. Here’s the solution I came up with, written up here in the hope that it will help other folks in similar situations and also that people smarter than myself might help me improve the setup.
The first thing to do, of course, is to integrate the TankUtility monitor into HA. Here’s the entry in my configuration.yaml which does that, exactly the way the documentation for the HA TankUtility integration describes it:
sensor:
- platform: tank_utility
email: !secret tank_utility_username
password: !secret tank_utility_password
devices:
- xxxxxxxxxxxxxxxxxxxxxxxx
Where “xxxx…” is the identifier for my TankUtility monitor. In “Developer Options/States” now I can see this:
That value is the percentage that the tank is filled, in this case 63.6%. So that value will generally go down over time (though my reading tends to bounce around a little), except when the tank is filled,when it’ll go back up to 80-90% (they don’t fill my kind of large buried propane tank to 100% for safety reasons, or so I’m told).
You can’t add this sensor directly to the Energy dashboard ( Settings/Dashboards/Energy/Add Gas Source ), it won’t even be listed as an available gas source. This is because it’s not a “gas” source, it’s not in the correct units (cubic meters or cubic feet) and more importantly it doesn’t have long-term statistics associated with it yet.
The next thing I did was to create a template sensor which acts as if it is a propane “meter” measuring gas flow into the house:
template:
- sensor:
name: "Propane Level"
unique_id: propane_level
icon: mdi:fire
device_class: gas
state_class: total_increasing
unit_of_measurement: 'ft³'
state: "{{ ( states('sensor.tank_utility_xxxxxxxxxxxxxxxxxxxxxxxx') | float * -1.3368 ) + 133.68 }}"
This sensor ranges from zero to 133.68 (hypothetically), resetting to (near) zero when the tank is refilled. If you look at the math in the “state” line, I’m converting the fill value from the TankUtility sensor from percentage to cubic feet (I have a 1000 gallon tank, so I multiply the percentage by 10 to convert to gallons; there are 0.13368 cubic feet per gallon volumetrically, I think I reduced the equation properly?). I also multiplied by -1 to make the propane level continuously increase (flowing “into” the house, for the Energy dashboard)… at least until it drops enormously when the tank is filled. To make that value range above zero (rather than -133.68 cubic feet up to zero and down again) I added the total volume of the tank in cubic feet.
Also notice that “device_class” is set to “gas” (important for the Energy dashboard to recognize it). Also, through some trial and error, I found that I have to set the “state_class” to “total_increasing”. I tried to use the “measurement” state class but kept getting a warning in the Energy dashboard Add Gas Source section that the entity’s “last_reset” wasn’t set. “total_increasing” appears to allow this entity to not need a “last_reset”, and is also apparently a misnomer, in that the documentation says it IS expected to occasionally reset? I’m obviously unclear on this, but in true hobbyist fashion I’m going with “it seems to work!” We’ll see what happens the next time I fill my propane tank. Finally, notice that the unit_of_measurement needs that superscript “3” in there.
This sensor still won’t appear on the Energy dashboard’s Add Gas Source drop-down, because it needs statistics. We can use the utility_meter integration to do that. Here’s my entry in configuration.yaml:
utility_meter:
daily_propane:
source: sensor.propane_level
cycle: daily
monthly_propane:
source: sensor.propane_level
cycle: monthly
yearly_propane:
source: sensor.propane_level
cycle: yearly
NOW you should be able to go into Settings/Dashboards/Energy/Add Gas Source and choose “Propane Level” as your gas source.
After a day or two (TankUtility homeowner meters only update daily) you’ll start to see Gas consumption and statistics in your Energy dashboard:
I hope this helps someone! Comments and questions welcome.