CF209 / vanomation

Home automation system for my van
http://van-automation.com/
1 stars 0 forks source link

propane_mqtt.py crashes when receiving BLE packet from Mopeka Pro sensor #1

Closed DrDeke closed 1 year ago

DrDeke commented 1 year ago

Greetings,

I found your propane_mqtt.py script tonight and attempted to run it to read one of my Mopeka Pro ultrasonic sensors. As soon as it receives a BLE packet from the sensor, it crashes with the following trace:

Traceback (most recent call last):
  File "/home/pi/./propane2.py", line 316, in <module>
    propane_pct, propane_qual, propane_bat, propane_temp = parse_data(x)
  File "/home/pi/./propane2.py", line 273, in parse_data
    s = e[r + o] + 256 * e[r + o + 1]
IndexError: list index out of range

I will take a look at what is going on, but I am not a very good programmer so I thought I would also check to see whether you happened to already be aware of this issue. If you are still using your code with the Mopeka sensors, I'd be curious to know whether you've run into this or not.

CF209 commented 1 year ago

Hi!

Glad to see someone making use of my project :)

I've only tested this script with the sensor that I own, not the pro model that you said you're using. This is the one I have:

AP Products 024-1001 Propane Tank Gas Level Indicator , Black https://a.co/d/6s9EuFk

It's very possible that the data sent from the pro model is different from this model, so that's probably leading to the error.

Are you trying to use this with home assistant? If so, check out this project: https://github.com/spbrogan/sensor.mopeka_pro_check

I think he worked directly with Mopeka to add support to home assistant, so it's a lot more legit than the reverse engineering that I did on their app to build my script.

Let me know if you have any other questions. Happy to help.

Thanks, Chris

On Sun, Jan 22, 2023, 7:25 PM DrDeke @.***> wrote:

Greetings,

I found your propane_mqtt.py script tonight and attempted to run it to read one of my Mopeka Pro ultrasonic sensors. As soon as it receives a BLE packet from the sensor, it crashes with the following trace:

Traceback (most recent call last): File "/home/pi/./propane2.py", line 316, in propane_pct, propane_qual, propane_bat, propane_temp = parse_data(x) File "/home/pi/./propane2.py", line 273, in parse_data s = e[r + o] + 256 * e[r + o + 1] IndexError: list index out of range

I will take a look at what is going on, but I am not a very good programmer so I thought I would also check to see whether you happened to already be aware of this issue. If you are still using your code with the Mopeka sensors, I'd be curious to know whether you've run into this or not.

— Reply to this email directly, view it on GitHub https://github.com/CF209/vanomation/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFOASFTWVUGFGC5DME7SGN3WTXFXZANCNFSM6AAAAAAUDI2JPI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

DrDeke commented 1 year ago

Ohhh! I do indeed have a different sensor than you do; I bet that's the problem.

My eventual goal is to import the tank level data into home assistant, but the computer I have running home assistant is not within Bluetooth range of the sensors. Still though, I should be able to look at that spbrogan code and send the recovered values to home assistant via MQTT like your system does.

Thanks so much for pointing out my sensor model mistake, and also thanks for the reverse engineering efforts and code you contributed!

Finally, I think you can probably close this "issue" under, I dunno, "submitter should read more carefully" :).

DrDeke commented 1 year ago

[Note: I didn't realize I could close the issue; I thought the repo owner had to. Never mind!]