Parse Hayward block metadata from lead XML#44
Conversation
There was a problem hiding this comment.
Codex Review: Here are some suggestions.
Reply with @codex fix comments to fix any unresolved comments.
About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".
| private static int parseIntParameter(String xml, String name) { | ||
| String search = "<Parameter name=\"" + name + "\">"; | ||
| int start = xml.indexOf(search); | ||
| if (start == -1) { | ||
| return 0; | ||
| } | ||
| start += search.length(); | ||
| int end = xml.indexOf("</Parameter>", start); | ||
| if (end == -1) { | ||
| return 0; | ||
| } | ||
| try { | ||
| return Integer.parseInt(xml.substring(start, end)); | ||
| } catch (NumberFormatException e) { |
There was a problem hiding this comment.
[P1] Parse lead parameters without assuming attribute order
The new parseIntParameter helper searches for parameters using the literal substring <Parameter name="…">. XML attribute order is not guaranteed, and the OmniLogic examples in API.md include additional attributes (e.g. dataType="int" name="MsgBlockCount"). When the lead message contains any other attributes or a different ordering, this method returns 0, leaving expectedBlocks at 0 and compressed false so the loop will wait until it times out instead of assembling the received blocks. Please parse the XML element without depending on attribute ordering or additional attributes.
Useful? React with 👍 / 👎.
Summary
Testing
mvn -q -pl bundles/org.openhab.binding.haywardomnilogiclocal test(fails: Non-resolvable parent POM org.openhab:openhab-super-pom)https://chatgpt.com/codex/tasks/task_e_68c15605392c83238c3de5d0960a283b