[SOLVED] Calculating Remaining Propane In a Tank

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…

That would be great for a smaller tank. Mine is 300 gallons and requires a bobcat to lift it.

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

I’m look at this product which I believe does allow local connections via their API, but it is not inexpensive: http://www.tankutility.com/residential-propane-tank-monitor/

Maybe it would be a good idea to get some kind of meter and measure consumption? See here - https://community.openhab.org/t/new-binding-wireless-m-bus-techem-heat-cost-allocators. We are currently working on it and we will be able to plug wireless devices (battery powered). An obvious side effect which is necessary first - is modification of installation. But if you have a pressure meter on the tank - then you could try to read pressure and calculate remaining capacity of gas (with very low but still some accuracy).

Cheers,
Lukasz

Did you declare the variable emailSent?

I did not. I added:

var Boolean emailSent = true

now i get this:

[ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule 'Propane Remaining': Could not cast NULL to java.lang.Number; line 9, column 34, length 32

Does that mean its seeing a NULL value? Because my propane counter reset of the day an has not run. So right now usage for today is zero.

Set it with the rest api
And try again

Thanks for the tip. I have looked at Tankutility and while it appears to be a good product that does what I need, the API they offer just reads from their server.
Because of my past experiences I prefer to retain local control. While Openhab developers were able to change the binding for MyQ after they broke the binding and Insteon reverted the changes they made, Revolve was completely abandoned. I don’t want to put myself in that position again.

oh man, now you set me on the path to figure out the rest api. i was able to create this:

curl -X PUT --header "Content-Type: application/json" --header "Accept: application/json" -d "{
  \"value\": \"string\",
  \"config\": {}
}" "http://xx.x.xx.xxx:8080/rest/items/Propane_DailyUsage/metadata/30"

i tried it in the command line on the openhab server. seemed to not choke at least. but it didn’t change the value. something else i should be doing with it?

Create a setpoint in the sitemap and set it to any value

You’re going to want a means like the setpoint anyway, to manually adjust your tank level e.g. after a tanker visit

Unfortunate that TankUtility seems to have removed their local API. I’m pretty sure they had it in the past, but I don’t see it in their current documentation. I’ll have to rethink this before I purchase one. It does look fairly easy to use though.

Things started working last night as it ran just little (really needed some relief from this cold for us, its been brutal). Problem is, its counting down way fast! I didn’t have any debug on it so not sure what its doing but this morning I have -495 gallons in the tank!

Here is what I have in the latest code. I am not persisting any of this yet so not sure if that is an issue or not.

var Boolean emailSent = true

// 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("mymail@gmail.com", "Propane is Low")
		sendMail("mymail@gmail.com", "Propane", "Propane is Low")
		emailSent=false
  }		
	else {
		emailSent=true
	}
end

Bumping this back up. Still not sure why its not calculating correctly.

The problem is with the daily usage. It must be too high
Add a log for the value before the calculation

Isn’t that running the daily rule on an hourly basis (for testing)?

1 Like

Well spotted young man!!
@boilermanc

The rule runs every hour and therefore you have taken out 24 times the amount
Change your cron string back

It is running every Minute with “0 * * * * ?”…

1 Like