Skip to content

Fix escaping XPath characters & add set_values_by_xpaths#476

Merged
iMicknl merged 1 commit into
iMicknl:mainfrom
WASDi:fix-xpath-escape
May 6, 2026
Merged

Fix escaping XPath characters & add set_values_by_xpaths#476
iMicknl merged 1 commit into
iMicknl:mainfrom
WASDi:fix-xpath-escape

Conversation

@WASDi
Copy link
Copy Markdown
Contributor

@WASDi WASDi commented May 3, 2026

This fixes XPath expressions like get_value_by_xpath("Device/Hosts/Hosts/Host[@uid=\"8258\"]/UserFriendlyName").

Also added a method set_values_by_xpaths to set multiple values in one call, as was available to get multiple values.

Updated README.md to reflect actual python version needed according to pyproject.toml.

@WASDi WASDi requested a review from iMicknl as a code owner May 3, 2026 21:10
@iMicknl iMicknl requested a review from Copilot May 4, 2026 13:16
Copy link
Copy Markdown
Owner

@iMicknl iMicknl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @WASDi! Are you using the library directly or via the Home Assistant by any chance?

A few remarks:

Comment thread sagemcom_api/client.py
Comment thread sagemcom_api/client.py
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves XPath handling in the async Sagemcom router client by adjusting how XPath strings are encoded (to support attribute selectors containing @ and "), adds a new bulk setter API for setting multiple values in one request, and updates the README to match the project’s declared minimum Python version.

Changes:

  • Route get_value_by_xpath through get_values_by_xpaths and expand XPath quoting “safe” characters to include @ and ".
  • Add set_values_by_xpaths to set multiple XPath/value pairs in a single API call (and refactor set_value_by_xpath to use it).
  • Update README minimum Python version to 3.11+ (aligned with pyproject.toml).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
sagemcom_api/client.py Adjust XPath escaping and add a bulk setter API for multi-action setValue requests.
README.md Update stated minimum Python version to match project metadata.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread sagemcom_api/client.py
Comment thread sagemcom_api/client.py
Comment thread sagemcom_api/client.py
Comment thread sagemcom_api/client.py
@WASDi
Copy link
Copy Markdown
Contributor Author

WASDi commented May 4, 2026

I am using the library directly. Thanks for making it!

@WASDi WASDi requested a review from iMicknl May 6, 2026 16:48
Copy link
Copy Markdown
Owner

@iMicknl iMicknl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@iMicknl iMicknl merged commit d44f9b0 into iMicknl:main May 6, 2026
9 checks passed
@iMicknl iMicknl changed the title Fix escaping XPath characters Fix escaping XPath characters & add set_values_by_xpaths May 6, 2026
@WASDi WASDi deleted the fix-xpath-escape branch May 6, 2026 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants