Skip to content

Commit

Permalink
Added uuid, serial and mac fields to /system/info and /system/first-a…
Browse files Browse the repository at this point in the history
…ccess API calls
  • Loading branch information
PoltoS committed Feb 10, 2022
1 parent 5be06df commit cc62fa2
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ZAutomationAPIProvider.js
Expand Up @@ -3351,6 +3351,9 @@ _.extend(ZAutomationAPIWebRequest.prototype, {
} else {
reply.data.firstaccess = false;
}
reply.data.uuid = this.controller.getUUID();
reply.data.serial = this.controller.getSerial();
reply.data.mac = this.controller.getMACAddress();
reply.data.remote_id = this.controller.getRemoteId();
reply.data.ip_address = this.controller.getIPAddress();
reply.code = 200;
Expand Down Expand Up @@ -3380,6 +3383,9 @@ _.extend(ZAutomationAPIWebRequest.prototype, {
current_firmware: version,
current_firmware_majurity: majurity,
remote_id: this.controller.getRemoteId(),
uuid: this.controller.getUUID(),
serial: this.controller.getSerial(),
mac: this.controller.getMACAddress(),
firstaccess: this.controller.config.hasOwnProperty('firstaccess') ? this.controller.config.firstaccess : true
};

Expand Down
23 changes: 23 additions & 0 deletions classes/AutomationController.js
Expand Up @@ -2077,6 +2077,29 @@ AutomationController.prototype.getIPAddress = function() {
return ip;
}

AutomationController.prototype.getMACAddress = function() {
var ip = "";
try {
if (checkBoxtype('zme_hub')) {
mac = system("cat /sys/class/net/eth0/address")[1].replace(/[\s\n]/g, '');
} else {
mac = system("cat /sys/class/net/eth0/address")[1].replace(/[\s\n]/g, '');
}
} catch (e) {
console.log(e);
}

return mac;
}

AutomationController.prototype.getUUID = function() {
return this.config.uuid;
}

AutomationController.prototype.getSerial = function() {
return this.config.serial;
}

AutomationController.prototype.getQRCodeData = function(profile, password) {
var data = {
id: "",
Expand Down
4 changes: 4 additions & 0 deletions main.js
Expand Up @@ -163,6 +163,10 @@ if (!config && config === null) {
config.controller.first_start_up = !config.controller.first_start_up? now : config.controller.first_start_up;
// count server restarts
config.controller.count_of_reconnects = config.controller.count_of_reconnects? parseInt(config.controller.count_of_reconnects, 10) + 1 : 1;

// generate the uuid
if (!config.controller.uuid) config.controller.uuid = crypto.guid();
if (!config.controller.serial) config.controller.serial = config.controller.uuid;
});

controller.on('core.start', function () {
Expand Down

0 comments on commit cc62fa2

Please sign in to comment.