Add support for Tuya WSD024-W-433#3477
Add support for Tuya WSD024-W-433#3477DennisKehrig wants to merge 6 commits intomerbanan:masterfrom
Conversation
|
Companion PR: merbanan/rtl_433_tests/pull/489 |
|
Why not using the bitbuffer_find_repeated_row() function ? like that you can analyse MIC only the repeated row and it's much more simple, no ? |
|
Few advice to simplify your code, lines 83 to 137 can be replaced by these few lines: bitpos is probably = 0, this is the first bit position. You can directly replace bitpos by 0. Then proceed with the dewhitening code. |
I disagree. This fails to meet the stated goal of reporting every unique valid row with plausible data. Your version rules out such rows if they occur less than four times, mine does not. Your version would also ignore valid data from another sensor contained in the same bitbuffer, mine does not. I have some recordings with five valid rows from one sensor and five valid rows from a second sensor, all in the same recording. And many where they occur less than five times, in several cases only one valid row per sensor made it into the recording. Example scenario with overlapping transmissions from two sensors: Only the first row from sensor 1 and the last row from sensor 2 make it through clearly, the rest will likely cause many shorter rows. Less severe scenario: I'd want to report the data from sensor 1 with count 3 and the data from sensor 2 with count 3, in the same decoder invocation. If you feel like I can make this more clear in my comments, please point out how. |
4fb382e to
fe39018
Compare
src/devices/tuya_wsd024w433.c
Outdated
| #define MAX_CANDIDATES 4 | ||
|
|
||
| /** | ||
| # Tuya WSD024-W-433 Temperature & Humidity Sensor. |
There was a problem hiding this comment.
Needs to be a plain first sentence without a H1 heading.
There was a problem hiding this comment.
Should I submit the same change for the WallarGe CLTX001 as separate PR or sneak it into this one? I also want to move the comment block there to directly above the decoder function so it doesn't show as documentation for the first #define statement, I missed that in the last one.
|
@ProfBoc75's advice is how we generally handle robustness in decoders. We expect that transmission collisions are rare and not fully recoverable. It's is good that you thoroughly explained the special circumstances (high transmission rate, many senders) in the comments. Generally your code comments are on point and very nice to have! It sounds like you've done the testing with good results and improved robustness. (Your work on the checksum is especially impressive, AI or not.) We just need to emphasize that the usual decoder should look at lot simpler ;) We need to maintain ~300 after all! The I'm not sure about the |
|
Do you have search keywords to find these sets? I could not locate any "Tuya WSD024 433", are they mostly the same as the ubiquitous Tuya Zigbee Thermometer Hygrometer sets? |
You can find more info in the README.md of the companion PR: merbanan/rtl_433_tests#489 |
I appreciate that and agree in general. I consider this one a special case (albeit based on limited knowledge of the market) because someone might easily have ten of these sensors, and because they don't transmit regularly unless they see a change in the measurements, so missing a transmission is more consequential than with my WallarGe sensors, which transmit every 31-35 seconds no matter what. And especially if we require a large number of identical rows, chances are you'll ignore valid transmissions from two sensors at the same time. I'd like to empower users to make that choice for themselves, but I recognize that this is a design decision that could be useful more generally and might be odd to have such isolated support for. During my testing, with the MIC algorithm still being a mystery, I only considered cases where I've seen five identical rows, and frequently I saw the sensor's LED blink, and nothing showed up, which was frustrating. Now as a user I'm glad I can simply display everything with a valid MIC, and highlight when I saw a row only once.
I agree, that would be nice. Especially if it enabled flex decoders with a config like "bits=72, repeats>=2, unique" to produce data for all unique 72-bit rows that occur at least twice, not just the first one. The way I approach it here is already fairly general, turning a list of rows into a list of unique rows and how often they occur. I'm limiting it to four candidates which works well in this case where the worst case I've seen is valid data from two sensors and one row having a bad checksum (thus producing a unique third candidate), but that could be adjustable. The nice thing about bitbuffer_find_repeated_row is that it doesn't need to store a lot of data and can stop early, while my approach has to consider every single row. In specific cases there could be optimizations, like "if the last row is the same as the first, chances are low there'll be valid data from a different sensor inbetween those rows", but a generic solution can't make those assumptions. One way to make it easier to reuse is with a struct to hold the row index and the number of times the row occurs, then the caller could allocate an array with however many candidates they expect to need at most and pass a pointer to that array to the function. A second variant of the function could omit the count information and just provide indexes of unique rows that are repeated enough times (closer to bitbuffer_find_repeated_row). If the number of candidates is limited, we could choose to replace the oldest existing candidate that has only been seen once so far since duplicates tend to be consecutive, at the risk of missing that the just replaced candidate occurs a second time later, now looking like a new candidate (I hope that makes sense). One question to ponder is how often anyone will see transmissions from more than two devices in the same batch of rows. If only two are expected, we could do the regular bitbuffer_find_repeated_row to find candidate A, then move backwards from the last row until it we either see A again or find a different row the required number of times. So in a case like this: We could find 1+2 from sensor 1, then 5+4 from sensor 2 and stop, skipping all the rows in the middle.
Yeah, there's a lot of options for that part. I considered calling it "repeats", but don't like the ambiguity that technically something that is sent once is not repeated at all and therefore should have "repeats: 0", but people tend to think of something transmitted five times as "repeats: 5", not "repeats: 4". |
…he previous approach included an elaborate way of swapping b[0] and b[7]
… the most recently added candidate first as a minor optimization
My bad. That's actually the preferred way to present the info. General protocol details here and specific device details with the tests. There'll be some integration of the different types of info soon. |
No description provided.