Skip to content

Commit 35bc37d

Browse files
rhegnerRobert Hegner
andauthored
Disable xpath escape (#406)
I had a second problem with my "Sunrise Internet Box". Attempting to read the value of the following xpath failed: ``` Device/IP/Interfaces/Interface[Alias='IP_DATA']/IPv4Addresses/IPv4Address[Alias='IP_DATA_ADDRESS']/IPAddress ``` Instead of the IP address I was looking for, `get_value_by_xpath` returned a JSON structure with lots of status information in it, but not the IP address I was looking for. Turns out that url quoting messed things up. So I added a new parameter to the `get_value_by_xpath` function: The following now returns the desired IP address as expected: ``` await client.get_value_by_xpath("Device/IP/Interfaces/Interface[Alias='IP_DATA']/IPv4Addresses/IPv4Address[Alias='IP_DATA_ADDRESS']/IPAddress", { "capability-flags": { "interface": True }}, False) ``` --------- Co-authored-by: Robert Hegner <[email protected]>
1 parent a483eac commit 35bc37d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

sagemcom_api/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ async def get_value_by_xpath(self, xpath: str, options: dict | None = None) -> d
414414
actions = {
415415
"id": 0,
416416
"method": "getValue",
417-
"xpath": urllib.parse.quote(xpath),
417+
"xpath": urllib.parse.quote(xpath, "/=[]'"),
418418
"options": options if options else {},
419419
}
420420

0 commit comments

Comments
 (0)