Replies: 2 comments 6 replies
-
Hi @DigiH,yes those should work the same. The OR cases would be checked first and if any matched the code will loop through the conditions to check for an AND case, then check that if found. At least that's the way it's intended to work. The key is that the AND case should be the last case to avoid the nesting requirement. |
Beta Was this translation helpful? Give feedback.
-
Yes you're correct, they are not equal, but it depends on context. At the time the nesting was added the documentation was correct in the context we were working with. So it really depends on what you're trying to do 😄
True, it should be the first condition checked then OR [nested condition] for efficiency. If you need It's confusing for sure and the docs should have more detail about the subject. |
Beta Was this translation helpful? Give feedback.
-
Hi @h2zero, having gone through the pseudo-nesting implementation together for the Xiaomi scales a while back you have since also implemented proper nesting for model conditions, but in the docs added a note
Nesting is discouraged …
with the example
"condition": ["servicedata", "index", 30, "abcd", "|", "servicedata", "index", 0, "1234", "&" "servicedata", "index", 5, "5678"]
stating that this works the same as a properly nested
"condition": [["servicedata", "index", 0, "1234", "&" "servicedata", "index", 5, "5678"], "|", "servicedata", "index", 30, "abcd"]
Having just confirmed a similar case with my open b-parasite PR and even linking to an old Xiaomi scale implementation I am a bit confused now ;) as
"condition": ["servicedata", "index", 30, "abcd", "|", "servicedata", "index", 0, "1234", "&" "servicedata", "index", 5, "5678"]
should work the same as
"condition": [["servicedata", "index", 30, "abcd", "|", "servicedata", "index", 0, "1234"], "&" "servicedata", "index", 5, "5678"]
but not as the above stated nested example in the docs.
Just to be sure I have made a few quick tests with how the pseudo-nesting still works.
Can you confirm my findings and that the docs should be amended?
Isn't it the case that the properly nested example cannot actually be accomplished without nesting, hence you implemented the proper nesting, but my above example allows for pseudo-nesting in such cases, where proper nesting can be avoided.
Thanks
Suggested changes:
https://github.com/DigiH/decoder/commits/docs-nesting-changes
Beta Was this translation helpful? Give feedback.
All reactions