Might be trying to fit a square peg in a round hole as there may be better ways to do this but thought I would ask.
With the help of @vzorglub I was able to calculate the run rate on my 300 gallon propane tank. I have been able to setup some really helpful graphing in Grafana as well that is now giving me my daily consumption but through Grafana I can get all the goodies, ie last 7 days, month, etc.
Now I would like to add in my total gallons in the tank and have it countdown the usage. ie, they will fill it today with something 297 gallons. Now I would like to know based on the daily usage how much is left in tank (or close enough) that i can track and alert as needed.
Again, not sure this lends itself to openhab or grafana or both or maybe some other solution. But it it works in openhab it would be great to be able to add that to my dashboard so it can be checked everyday. I would add in the option to change the tank value within the app so if it gets off a little or i have a refill i can change it. That way I dont have to go mess with code.
I have searched through the forum but really not finding this use case. Lot’s on calculating power etc and countdown timers for well, timers but not for a volume.
Happy to do the leg work but right now just looking for thoughts on this and ideas.
You need to start with a known volume. Like today. So declare a number item:
Number PropaneRemaining
And set it to 297
With the run rate rules, you know (roughly) the amount used daily, so at the end of the day, (cron rule), take away the amount used from the PropaneRemaining item.
I’ll let you do the coding and if it doesn’t work, we’ll make it work. It should be quite straightforward as you have all the data.
ok, here is a first pass. I’ll get to the greenhouse in a bit to test but i think i am probably missing some brackets or something. i created one item called PropaneRemaining.
// Rule to calculate remaining propane in tank
var propane_quantity_start PropaneRemaining = 297
rule "Propane Remaining"
when
Time cron 0 59 23 1/1 * ? *
then
PropaneRemaining = PropaneRemaining - Propane_DailyUsage
if(PropaneRemaining.state < 40) {
sendNotification (i'll fill this in)
}
how does it know to reset the starting amount each day? seems like every time it runs it would start at 297, ie on a reboot.
Thanks @rossko57. I like that setpoint. Will have to use that in some other places!
so i made a couple of changes. but looking at it, i think it will just use the 297 everyday to subtract. somehow PropaneRemaining has to be the number that is used to start each day.
// Rule to calculate remaining propane in tank
rule "Propane Remaining"
when
Time cron 0 59 23 1/1 * ? *
then
PropaneRemaining = propane_quantity_start - Propane_DailyUsage
if(PropaneRemaining.state < 40) {
sendNotification (i'll fill this in)
}
end
You are thinking of items state as variable. They behave quite differently and can be persisted.
// Rule to calculate remaining propane in tank
rule "Propane Remaining"
when
Time cron 0 59 23 1/1 * ? *
then
PropaneRemaining.postUpdate((PropaneRemaining.state as Number) - (Propane_DailyUsage.state as Number))
if(PropaneRemaining.state < 40) {
sendNotification (i'll fill this in)
}
end
In your other rules, the Propane_DailyUsage gets reset daily.
Tip: you can put the same Item into a sitemap multiple times. You might for instance, have a display-only version of “Propane remaining”. And bury a setpoint version for manual adjustment well out of the way. In fact, I think this would hide the controls until clicked
Text item=propane_remaining {
Setpoint item=propane_remaining minValue=0 maxValue=300 step=5
}
Not sure why you’re resisting having a “remaining” Item that just tallies up each day, or twice a day, or whatever. And let persistance take care of it for you long term.
When doing calculations of item states sometimes the rule interperter can get a bit confused with the type of object to add/substract…
So we tell it it’s a Number. Basically we “force” the type in nerd language.
I would also like to monitor my propane level, but did not like the idea of estimating the usage. I would rather have a direct reading of the gauge on the tank but there is no commercially available remote tank gauge that suites my needs. Every one I looked at requires uploading the data to a remote site, and requires a service fee or had a high price. Instead I am looking at creating my own sensor using the instructable from electronichamster located here:
as a guide and use an A1302 hall effect sensor. I’m still in the research and planning stage so I don’t have any more info, but will post something when I get moving on the project. This may be a better option for you also.
Out of curiosity, I just did a quick search and one of the topmost results was this monitor available from amazon.com. It’s not exactly cheap and it may not work for your tank, but it looks like it might do the job.
Thats very interesting. I have been doing some work with some cameras and AI for growing. Kinda along the same tracks. Problem is, my gauge is under a lid that doesn’t provide much light. Hey, I could have a light under that I trigger and then take the pic! Ok, not doing all that…
From the “more information” link in my original reply, locate the FAQ where it states that the device can be used with horizontal tanks up to 30 inches in diameter:
The TankCheck* sensor can be used on 20 lb tanks (like most grills use), 30 lb and 40 lb tanks (as used on many RV’s), and it works on horizontal tank up to 30″ diameter, too. Please see the instructions for exact mounting instructions for horizontal tanks because the placement is important for the most accurate readings.
ok, finally got to put this in. I am getting this error:
[ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule 'Propane Remaining': An error occurred during the script execution: Couldn't invoke 'assignValueTo' for feature JvmVoid: (eProxyURI: remainingpropane.rules#|::0.2.0.2.0.1.2.0.0::0::/1)
This is where my rule is:
// Rule to calculate remaining propane in tank
rule "Propane Remaining"
when
//Time cron 0 59 23 1/1 * ? *
Time cron "0 * * * * ?" //for debug
then
PropaneRemaining.postUpdate((PropaneRemaining.state as Number) - (Propane_DailyUsage.state as Number))
if(PropaneRemaining.state < 40) {
sendNotification("email@gmail.com", "Propane is Low")
sendMail("email@gmail.com", "Propane", "Propane is Low")
emailSent=false
}
else {
emailSent=true
}
end
i added a settings sitemap and put this in:
Text item=PropaneRemaining {
Setpoint item=PropaneRemaining minValue=0 maxValue=300 step=5
I set it for 200 gallons to test.
2018-11-29 13:06:44.054 [ome.event.ItemCommandEvent] - Item 'PropaneRemaining' received command 200
2018-11-29 13:06:44.093 [vent.ItemStateChangedEvent] - PropaneRemaining changed from NULL to 200