-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathpairingTest.js
37 lines (33 loc) · 1.14 KB
/
pairingTest.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
'use strict';
const axios = require('axios');
const xml2js = require('xml2js');
let endpoint = 'http://192.168.1.8:8080/MediaRenderer/desc.xml';
let device = {
id: '1',
name: 'Yamaha amplifier []',
data: {
driver: "receiver",
},
settings: {
ipAddress: '',
zone: 'Main_Zone'
},
};
axios.get(endpoint).then(data => {
xml2js.parseStringPromise(data.data)
.then(result => {
if (typeof result.root['yamaha:X_device'] !== "undefined") {
let yamahaDevice = result.root['yamaha:X_device'][0],
baseURI = yamahaDevice['yamaha:X_URLBase'][0],
serviceList = yamahaDevice['yamaha:X_serviceList'][0],
xmlDevices = result.root.device,
xmlDevice = xmlDevices[0],
friendlyName = xmlDevice.friendlyName[0],
modelName = xmlDevice.modelName[0];
device.name = friendlyName + ' - ' + modelName + ' [' + ']';
console.log(serviceList);
}
});
}).catch(error => {
console.error(error);
});