Hi Folks,
I have an Audio Matrix switch which I can interrogate with a single GET request. Running the curl command gives me the following XML output.
<?xml version="1.0" encoding="UTF-8"?>50,50,50,50,50,50,50,99,50,50,50,50,50,50,50,5075,95,75,75,75,75,75,75,75,75,75,75,75,75,95,950,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,095,75,95,95,95,95,95,95,95,95,95,95,95,95,75,7520,60,21,0,0,40,0,1,20,0,0,10,20,20,60,60
I have managed to use the RESTful sensor to get the data, store the “Result” portion in a state attribute field. But I can’t get to just the single values out of that state_attribute.
Here is the state_attribute:
Result:
- ‘@Name’: Balance
‘#text’: ‘50,50,50,50,50,50,50,99,50,50,50,50,50,50,50,50’ - ‘@Name’: Bass
‘#text’: ‘75,95,75,75,75,75,75,75,75,75,75,75,75,75,95,95’ - ‘@Name’: LipSync
‘#text’: ‘0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0’ - ‘@Name’: Mute
‘#text’: >-
false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false - ‘@Name’: StereoConnections
‘#text’: ‘0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0’ - ‘@Name’: Treble
‘#text’: ‘95,75,95,95,95,95,95,95,95,95,95,95,95,95,75,75’ - ‘@Name’: Volume
‘#text’: ‘20,60,21,0,0,40,0,9,20,0,0,10,20,20,60,60’
Here is the value_template for one of the sensors, I can’t more out of this data, I would just want a single number, eg, 5 below.
{{states.sensor.audio_switch.attributes.Result[4]}}
yields:
{’@Name’: ‘StereoConnections’, ‘#text’: ‘0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0’}
Alternatively, if someone can suggest a better way to extract all of these individual values cleanly, I am all ears.
Thanks in advance.