I’m trying to set a Fuel Tank Gauge so I can see (approximately) what my fuel tank level is at.
All I get via Modbus is the power usage of my fuel generator but I have created a binary sensor that determines if the generator is on or off (as that is more useful than the power which is always the same).
I have used the utility meter to calculate generator usage for daily, weekly and monthly which is useful. But now I want to calculate how much fuel is left based on knowing the capacity of the fuel tank is 13.3L and I also know the rate of fuel usage is 2.5L/hr.
If I create a sensor that calculates L used with hours of generator usage x rate of usage I get a daily rate. I need to reset the generator hours of usage to a sensor that I can trigger to indicate the fuel tank has been refilled. I can’t quite figure out how to do this.
I’ve wired a door sensor to a relay which is powered from the oil fired burner on my home heating system’s boiler. Basically I get an on/off state change every time the burner fires.
From that I can use a history_stats sensor to keep track of how long the boiler has been running so far today:
I’ve also defined one which indicates how long the burner ran yesterday:
- platform: history_stats
name: Burner on yesterday
entity_id: binary_sensor.visonic_mct_340_e_0b1243b6_1_1280
state: 'on'
type: time
end: '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
duration:
hours: 24
Like you, I can estimate fuel burn based on total hours run-time. The burner is calibrated to burn about 1 gallon per hour, but in practice it seems to be closer to 0.98 GPH. Each morning, I run an automation to append yesterday’s run time to a text file, as well as populate an input number. The automation is a little long, because I trigger it a few times in case HA wasn’t running the first time (probably overkill.)
Sorry for the delay, I was out of town. It seems like a lot to digest all at once, but take one piece at a time. If I could figure it out, anyone could.
I created an Entities card in Lovelace with the entity “input_number.oil_tank_remaining.”
I just over-type it when needed. Not only when there’s a fuel delivery, but ny sensor has been sticking “on” occasionally, so it thinks the burner ran for an hour or two, instead of just a few minutes. I’ve got a plan to fix that before the heating season starts, but meanwhile I just go in and add an extra gallon or two “remaining.”