Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 105487

Calculating Oil Consumption

$
0
0

I am looking for direction on how to best implement the following;

I want to be able to calculate the consumption of oil I use for heating from a known value (my oil tank). I have a device that is turned “on” when my boiler runs and in another automation system I would take the daily runtime (in hours) of this device and multiple it by the burn rate of my burner which is .85 gallons an hour. I would then take this “gallon-used” value and subtract it from the “tank-gallons” value. This would then give me the remaining “new-tank-gallons” value which would be saved as the new value of “tank-gallons” to be subtracted from the new day.

So as an example, if starting from a full tanks, the logic would look like this.

275 “tank-gallons” - “gallons-used” which is (runtime of device y for the past 24 hours x .85)

this would be the new value for “new-tank-gallons”

“new-tank gallons” would be saved as the new value of “tank-gallons” until the next days usage.

When I get an oil delivery, I would set the value of “tank-gallons” back to 275.

Thanks in advance for any help in coming up with a solution for this.

I use the following vb script to perform this currently.

Sub Main(parm as object)

dim tank = 824 'device reference for virtual tank level
dim oilburned = 924 'device reference for Gallon Used Prio Day
dim heating = 735 'Device reference for thermostat operating state
dim rate = .832 'Gallons per hour burned original .85
dim zwave = 1 'Multiplier for fine tunning
dim runtimer = “Heating” 'name of hs timer
dim heatcycles = “Heat Cycles” 'name of hs counter tracking 3 minute MOT
dim gallonsold = hs.DeviceValueEx(tank) 'Read in current gallons

dim gallons
dim gallonsUsed
dim gallonsUsedToday
dim gallonsnew

gallonsUsed = (hs.TimerValue(runtimer).totalhours * zwave) * rate
gallonsUsedToday = math.round(gallonsUsed,2)

gallons = gallonsold - gallonsUsedToday
gallonsnew = math.round(gallons,2)

hs.WriteLog (“Info”, “Number of gallons used today " + gallonsUsedToday.ToString + " Gallons.”)
hs.WriteLog (“Info”, “Old Gallons Value " + gallonsold.ToString + " Gallons.")

hs.TimerReset(runtimer)
hs.CounterReset(heatcycles)
hs.TriggerEvent(“Stop heat timer”)

hs.SetDeviceValueByRef(tank, gallons, True)
hs.SetDeviceString(tank, gallons.ToString + " Gallons", True)

hs.SetDeviceValueByRef(oilburned, gallonsUsedToday, True)
hs.SetDeviceString(oilburned, gallonsUsedToday.ToString + " Gallons", True)

hs.WriteLog (“Info”, “Update heating oil to " + gallons.ToString + " Gallons.”)
End Sub

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 105487

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>