Issue debugging and mods to decoder_test.py #261
Replies: 2 comments
-
Hi @NateEaton
have a look at other decoders and their model conditions with how "&" and "|" are implemented
same for property conditions for evaluation data at a certain index. Hope this helps |
Beta Was this translation helpful? Give feedback.
-
@DigiH , thanks. Guess I should work on this stuff during the day instead of the middle of the night... corrected code works:
Although I get that the typo was having a bare OR operator instead of having it quoted, I had only added that when I was not getting results with "8500" and yet it works fine like this. At least it does once I made two other edits, adding reference to the new device in decoder.h and besides the "include" in devices.h, I was missing the reference to the json structure names. Once I have finished the finer details on decoding the SensorBug light level and motion attributes, I'll get everything committed to my repo and plan to also add some suggested documentation updates on the specific steps to add a new device (based on my experience) with an eye towards submitting that as a PR.
One other thing I ran into that was biting me: afraid I was leaning a bit too hard on the LightBlue Android app for scanning devices and using the results as reference for my development. In it, hex values are in all upper-case. It turns out that the hex strings in python have lower-case letters so the condition I used to confirm the battery value exists in the mfrdata , comparing for "3C", was failing even when everything else in the new SBUG decoder was working. Changing it to "3c" was the needed fix. I figured I would include that here for benefit of anyone else who is struggling to get a new decoder working. Appreciate you pointing me in the right direction. |
Beta Was this translation helpful? Give feedback.
-
Having forked and cloned the latest dev repo, I have built decoder and gateway from source and the gateway (running on a rpi Zero W) is successfully sending data for Inkbird IBT 4X (iBBQ) and Maestro Blue Tempo Disc to my Home Assistance instance (on an rpi 4B).
I am now trying my hand at creating a new device decoder for a SensorBug (mentioned in another thread). I'm including the json header file below.
Although I have through trial and error made a few mods to IBT and BM (e.g., the IBT now sends a separate message for each temperature probe indicating if a probe is plugged into the base unit), I find I am butting my head against SBUG. At this point, I have even tried simplifying the device definition such that it just has the mfrdata condition and then emits a static value (i.e., no conditions set for defining a property) but even that didn't work. It seems pretty simple: if mfrdata starts with '8500' in index 0, then it's a SensorBug but nothing I've tried has returned any data.
In addition, while testing, I kept getting an error out of decoder_test.py whenever the decoder returned None:
To address that, I made a mod to test whether z is None and only proceed if not (see code below).
Note that in my test, I have three conditions:
I've included the result of test run, too.
Anything obvious about what is going on? Have a just misunderstood the input being sent to decoder? Something else, e.g., a noob snafu?
Thanks,
Nate
SBUG_json.h (which I did ensure is referenced in devices.h)
Revised decoder_test.py
Output from decoder_test.py
Beta Was this translation helpful? Give feedback.
All reactions