I’m trying to extract the value of “mode” from my camera using RESTful but it’s returning no data into the sensor. This is what I’ve come up with so far but I have to admit I’m flying blind regarding curl / rest ::
rest:
- authentication: digest
username: "username"
password: "password"
scan_interval: 60
method: GET
resource: "http://192.168.10.201:80/ISAPI/Image/channels/1/mountingScenario"
headers:
Content-Type: "application/xml"
payload: '<?xml version="1.0" encoding="UTF-8"?><MountingScenario><mode>normal</mode></MountingScenario>'
sensor:
- name: "CameraMountingMode"
value_template: "{{ value | regex_findall('<mode>(.*?)</mode>') | first }}"
This is the response I get when I use curl ::
curl -k -H "Content-Type:application/xml" -X GET -d '<?xml version="1.0 encoding="UTF-8"?><MountingScenario><mode></mode></MountingScen
ario>' http://192.168.10.201:80/ISAPI/Image/channels/1/mountingScenario --digest -u username:password
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 178 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
<?xml version="1.0" encoding="UTF-8"?>
<MountingScenario version="2.0" xmlns="http://www.std-cgi.com/ver20/XMLSchema">
<mode>custom1</mode>
</MountingScenario>
100 251 100 164 100 87 5646 2995 --:--:-- --:--:-- --:--:-- 8641
It’s the value inside the mode key (custom1) that I’m trying to store.