Yes, I think so. I’ve since written a python script to interface with VLC remotely. But since this is a more general purpose tool, I’ll walk you through it.
Syntax is complex but it works a charm.
'/usr/bin/curl --user {{ user }}:{{ password }} "{{ XML URL }}" 2>&1 | grep -oPm1 "(?<=<{{ Opening bracket }}>)[^<]+"'
Where:
User / password: the HTTP authentication
XML URL: location of the XML file.
Opening bracket: tag title of the opening bracket e.g. <body>
First part of the command, curl, pulls the XML response and pipes the response into the second part… Grep. Grep searches for the contents of the XML tag you’re after.
For anyone else looking to do a similar thing, my application was extracting a variable value from my ISY-994i. I couldn’t think of any other way for HA to read the temperature from my Insteon thermostat, so I wrote an ISY program to assign an integer value to a variable based on the temperature. The command above then allows me to extract that integer variable via the ISY REST api.
I’m now realizing that I could bypass the whole variable thing altogether if I could modify the code to extract directly from the Insteon thermostat node. Any idea how I could grab the highlighted value below? Preferably without the two decimal places.
Thank you for this! I have been struggling and struggling to get all my components tied in and this awesome, simple little trick really did the trick.
I wanted to share my exact configuration in case it helped anyone else. I’ve got a couple Raspberry Pis running python scripts to gather data points and store them in my ISY variables that are then used for managing some programs. (Ex: I’ve got a sensor collecting pool temp and then programs running on the ISY to determine if I need to run the heat pump longer.)
The specific IP/port is my ISY and of course the rest url specific to my variable type and ID.
@James_Malvi It appears that this just converts XML to JSON. I’m not sure how this would help people with extracting data from an XML directly to a Home Assistant sensor. Can you elaborate?