spbrogan / sensor.mopeka_pro_check

Home Assistant custom component to support Mopeka Pro Check Tank Level Sensors
Other
21 stars 4 forks source link

Discrepancy in levels between Mopeka app and this integration #1

Closed phurth closed 2 years ago

phurth commented 3 years ago

I've set up this integration (thanks!) and have data coming from my two sensors. The tank levels reported by the integration in HA are off by about 10 percentage points from what is reported in the official Mopeka app. I have the tanks set up in my config as 20lb_v, which they are. Any idea what might be happening? image image

spbrogan commented 3 years ago

Good report. I have noticed this on the 30lb tank too (which is what i have).
Currently the percentage is determined based on distance. So currently it is distance 0 to Max Height but I don't think this is completely correct.

See max heights declared here: https://github.com/spbrogan/sensor.mopeka_pro_check/blob/main/custom_components/mopeka_pro_check/const.py#L30

This is where the percentage is calculated. https://github.com/spbrogan/sensor.mopeka_pro_check/blob/main/custom_components/mopeka_pro_check/sensor.py#L186

So to make this better can you help?
In HA can you look at the sensor and see the "TankLevelInMM". Then can you report the height in MM and the percentage reported in the Mopeka app. Lets build a table of tank type, height in mm, mopeka percentage. Once we have that data we can make a better algorithm. My guess is 100% is fuzzy and not max height and 0% is probably not 0 distance. Otherwise it should be linear...so we just need to get a good min/max. Do you have an empty tank?

Thanks Sean

phurth commented 3 years ago

I don't have an empty tank at the moment, but otherwise am happy to help and will get you any data I can. I'll get more details ASAP, but in the meantime, I suspect that temperature plays a role in how Mopeka calculates the level - or at least it's a variable they compensate for. The tanks with sensors I posted above have not been used, but here are this morning's measurements. The only difference is ambient temperature which is about 20 degrees F cooler. image image image

phurth commented 3 years ago

Here's the data from the Mopeka app: image image

phurth commented 3 years ago

And here's what the Mopeka app is calculating as percentages. Basically the same as yesterday with a higher ambient temp. image

spbrogan commented 3 years ago

Yes. The depth does change based on temp and the sensor reading is adjusted for that. See code here: https://github.com/spbrogan/mopeka_pro_check/blob/main/mopeka_pro_check/advertisement.py#L189 I use the same algorithm as Mopeka and you can see HA has the exact same "depth" as the mopeka app. So I still think it is just a min/max difference. Also there is nothing saying Mopeka's percentage is correct but I assume they have done more validation and data collection than I did. :)

So what we have now.

20lb tank

Depth Mopeka % HA %
267mm 100% 90.5%
208mm 79% 67.8%

So if we change it to something like 267mm = 100% 10mm = 0% and it is linear between them then (267-10)/100. Then % should be (Y-10) / 2.57.
This would have made HA100% and 77% respectively. So that is closer.

Anyway I think we need more data. We need to get more tanks that are filled at a station by someone who knows how to fill tanks (those exchange tanks are supposed to be less than 100% full). We need to run tanks out and see what the reading is. I can try to do that over the summer months. If you know anyone else with these sensors really all we need is for them to use the mopeka app to get height and percentage. I could also try asking Mopeka if they would share their algorithm or data. Open to other ideas.

phurth commented 3 years ago

Cool - thanks. I will update this issue with additional readings over time. I'm thinking of picking up another sensor for a 20lb grill tank that's not on the trailer as well. Some additional context for the two RV tanks - the "port" tank is original to the trailer (a 2019, so it should be fairly new) and if I recall correctly, was refilled at a campground and never exchanged. The "starboard" tank is an exchange which hasn't been used since being exchanged - so in theory, both tanks should be "full".

Given the eye-opening difference in propane in the refill vs the exchange, I doubt I'll be exchanging again. 😀

phurth commented 3 years ago

Not sure if this will help, but here's an update: I have two tanks/sensors set up and have noticed something odd. One of the tanks has been run completely empty, but the Mopeka sensor is still reporting 6.6 cm of propane. The other tank is nearly full at 26.6 cm. I did try swapping the sensors in case there was some issue with the one. Same measurements. The integration in Home Assistant is showing the correct measurement of propane, but the percentage is off compared to the Mopeka app.

Tank 1: 6.6 cm in App and HA App = 13% HA = 21.8%

Tank 2: 26.6 cm in App and HA App = 100% HA = 87.8%

spbrogan commented 3 years ago

Here are some measurements for the 30v tank

Depth Mopeka % HA % Temp F
396mm 100% 96.6% 53.6 F
99mm 18% 24.1% 51.8F

I'll try to get more as i use up some propane

mrcrowley111 commented 2 years ago

I just got this running on my HA setup and am having the same discrepancy between Mopeka app and HA. I have two 30lb tanks currently showing:

Depth | Mopeka % | HA % | Temp F -- | -- | -- | -- 358mm | 93% | 88.5% | 61 F 343mm | 89% | 82.9% | 50F
spbrogan commented 2 years ago

thanks for the reminder that i need to commit some tuning. Here are some additional 30lb tank measurements i saved over the summer.

Unless you think the curve isn't linear you can use the custom tank size and then set the 0 and 100% point. I believe that is really all that needs to be tuned. I am pretty sure that the sensor is supposed to handle depth adjustment based on temperature.

Depth Mopeka % Temp F
84 mm 13% 48 F
404mm 100% 54F
32 mm 0% 59f
43mm 1% 45f
378 mm 99% 54f
406 mm 100 % 64 f
354 mm 92% 48f
347 mm 90% 48f
90 mm 15% 54 f
313 mm 79% 35 f
phurth commented 2 years ago
Do you happen to have similar updated tuning for 20 lb tanks? Right now my tank is showing the following: Depth Mopeka% HA% Temp
72mm 16% 23.4% 34°

The variance between the Mopeka app and HA seems to get worse as the tank level decreases.

mrcrowley111 commented 2 years ago

Based on this info, it seems the temp algorithm needs to be tweaked. HA is showing higher than the Mopeka app which is different and at a fairly low temp.

spbrogan commented 2 years ago

you can look at it here: https://github.com/spbrogan/sensor.mopeka_pro_check/blob/main/custom_components/mopeka_pro_check/sensor.py#L186

I will see if i can make a few changes tonight to the standard tank heights.

There are two other things to change. Right now a height of 0 assumes empty and this isn't configurable (even for custom). So I'll make that custom.

The other thing i noticed when making an EspHome integration (wifi) was that when the tank gets near empty the confidence reading value goes down and then the distance gets inaccurate. So in that integration, once the confidence was down to 1 star I made the reading zero.

https://github.com/spbrogan/esphome/blob/spbrogan/add_mopeka_pro_check_v1/esphome/components/mopeka_pro_check/mopeka_pro_check.cpp#L115

spbrogan commented 2 years ago

@phurth and @mrcrowley111 - After doing more review of these number i think Mopeka is "fudging" a lot at the 100% mark. My guess is that full is very different and no one wants to fill a tank only to see their sensor show less than 100%. If it makes you feel better we can match Mopeka or I can look at my full readings and use the largest as "full".

mhaberler commented 2 years ago

has anyone ever had any contact with Mopeka?

Whom should I talk to specifically? How?

I have an industrial customer looking for a custom solution from Mopeka, and after 10 attempts to entice any reply from Mopeka through either web, email or phone he's getting impatient

I'm sorry for committing this hijacking but I am out of my depth trying to get any response from Mopeka

spbrogan commented 2 years ago

i emailed their support/info address 2 or 3 times. I only was successful at getting a reply for one set of communications. Otherwise just a black hole. Not sure their business model but many of these consumer smart sensor companies have terrible communication.

phurth commented 2 years ago

At the risk of further hijacking - I got an email from Lippert (LCI) this morning showing their propane sensor which is suspiciously close in appearance to the Mopeka pro sensor. I emailed Mopeka to ask if the LCI sensor is actually a Mopeka, and if so, what kind of compatibility exists (if any). If they aren't the same, I wonder how much more open - or not - LCI might be to community development?

phurth commented 2 years ago

Interesting response from Mopeka: "They are not compatible with each other. We do however do some manufacturing for some other companies with LCI being one of them."

spbrogan commented 2 years ago

why is this industry so whacky?

mhaberler commented 2 years ago

good point. I've given up on Mopeka and try my luck now with a german company, Truma

they say product is their development About twice the price of the mopeka sensors, but hopefully not as incommunicado

https://www.truma.com/int/en/products/truma-caravan-rv-gas-fittings/truma-levelcontrol https://www.truma.com/int/en/products/truma-caravan-rv-gas-fittings/truma-levelcheck https://www.truma.com/int/en/home

looks very similar from the software side

spbrogan commented 2 years ago

@phurth - I am going to merge in the changes in the referenced branch.

  1. Make the percentage align with mopeka app
  2. Allow the custom config to control the zero percentage
  3. Mark reading as 0% if the reading quality is low
sergeantbort commented 2 years ago

@phurth - I am going to merge in the changes in the referenced branch.

  1. Make the percentage align with mopeka app
  2. Allow the custom config to control the zero percentage
  3. Mark reading as 0% if the reading quality is low

Just want to make sure you have this information. had one half decent rep from Mopeka actually respond via email with useful information.

https://mopeka.com/wp-content/uploads/2021/03/ProCheck_Sensor_integrator_guide_v4.pdf

spbrogan commented 2 years ago

Thanks for the info. That is the same version I have. I have not wanted to share because the doc has confidential written all over it but I have an email from them saying that it is ok for me to use the doc and publish any code I author based on it.

Last time i looked the doc doesn't list their 100% and 0% and/or how to calc from distance to percent. So getting those to match required building a table and taking measurements and comparing. I am not convinced their values are "right" but still i might as well align mine to match. If a user wants something else they can always use "custom".

phurth commented 2 years ago

@sergeantbort - Thanks for the changes. One note: there's a typo on line 199 of sensor.py, ma.ReadingQaulityStars instead of ma.ReadingQualityStars.

spbrogan commented 2 years ago

fixed. Thanks. I should really write some unit tests.

tango2590 commented 2 years ago

Noticing the discrepancy today. When I first got the integration working yesterday, there was no difference. But now I'm seeing a 2% gap and an 8% gap. Still newer at this, but it doesn't look like the changes mentioned 10 days ago were published quite yet.