I have the Tank Utility integration working, and it is great.
I would like to use the data from that integration to add it into my Energy Use, as Propane is a gas, and it is something we consume.
The Tank Utility only updates every 24 hours, so I could only update on that schedule.
However, I am at a loss as to how to write a function to track the energy usage with this gauge:
I have a 500 gallon tank
Tank Utility gives me a pressure reading every 24 hrs, like 45.6%
I can measure the change in a period, probably get square meters from that
Periodically, the tank is refilled, meaning the reading will suddenly shoot up
I don’t want the tank filling to count as energy “coming back” into the system
I have spent a lot of time googling this, but I can’t seem to find a similar situation or use case. If I could figure it out it would be nice to have Tank Utility track energy usage.
Same situation here! Have been struggling to figure out how to include propane energy usage. Also tank utility integration doesn’t show up in long term statistics. That would be nice too!
I am waiting for my next fill up to find out how much gas was added. From that, I should be able to get a rough calculation of how much the meter percentage calculates for the amount of gas used.
What I don’t know how to do is to handle when gas is added back into the system, as that will be seen as “Giving back to the grid”
Will probably be something like:
- platform: template
sensors:
propane_use:
value_template: >-
{% set some rules here%}
friendly_name: Propane Use
unit_of_measurement: m3
So, I have a bit more info that I can probably start to figure out some calculations with:
499.0 Gallons Total tank volume
251.3 Gallons delivered
88.0% after fill up
37.2% before fill
50.8% fill for 251.3 gallons is 4.9468 Gallons per percentage point
Thus, I should be able to use that figure as a calculation to judge gallons used, though it will be an estimate.
$2.71/Gallon is the estimated spot price per gallon (there are other charges)
So I think this can be worked with. I don’t know how to handle when the volume suddenly goes up though.
Then, a sensor (I have my sensors in their own sensor.yaml file)
- sensor:
- name: 'Daily Propane'
device_class: energy
unit_of_measurement: m3
state: >. # jinja2 logic here
I am trying to figure out the jinja2 logic.
The Tank Utility integration reads propane in US gallons. 1 US gallon is 0.00379 cubic meters So, this is our conversion rate that we need in the template.
The next bit of logic I need in the jinja2 template is, something like “If value today is higher than value yesterday, then today’s consumption is zero.” Reason being, if the propane is filled up, we can’t actually calculate how much was used as we have to wait a full 24 cycle for valid results.
I believe that this is possible with jinja2, but I need to get better with it.
Can you post your sensor yaml calculation for me to look at. I have a sensor that tells me the gallons present in the tank. I want to use your formula to create a new sensor that tells me daily gallon usage and the calculate energy usage. Similar to you my tank will get filled and the value will be greater for that do so no usage…
I am still trying to hash this out myself, so far all my changes keep breaking my regular energy usage - I am not yet skilled enough with Jinja2 to be able to get this sorted… yet.
Are you getting the percent as a sensor or does it report total every day?
template:
- trigger:
- platform: time
at: '00:00:00' <-- set to the time you get your reading
- platform: event
event_type: event_template_reloaded
- platform: homeassistant
event: start
sensor:
- name: "Gas kwh"
state: >-
{% set todaygas = (states('sensor.percent_today")) | float(0) %}
{{ todaygas * 453577 * 0.00029307107017 }}
Your daily gas will be in a sensor named sensor.gas_kwh and it will be calculated at midnight each day. You can multiply the two constants together and only have it do one multiplication.
If you get total tank volume then you will need a trigger template to save yesterdays reading and then you can subtract.
I have the following configuration.yaml and customize.yaml but still cannot get things to show up in the Energy panel. tank_percentage is obtained by multiscrape from a website. Any help as to what I am doing wrong?
This is great - it seems to be correct. How does this handle refills? That is, when the propane truck comes by and fills up? Not sure if this will come back as a negative value?
Sensor.tank_percentage is not the daily amount used. It is the percent in the tank remaining. I guess I misunderstood utility meter function. I thought that it calculated the daily usage from the sensor valve. I also think I need to set net consumption to true in the utility meter section so I can have negative values from day to day.
Sorry for the noob question but sincesensor.tank_percentage is the percentage in the tank is there a function that easily calculates the daily usage such that
sensor.daily_propane_used = function of (sensor.tank_percentage)?
I am sure that this logic is incorrect. But hopefully I have the right idea - unless the way the float is calculated already above handles negative values.