Getting MAC-address or alike in JS

Discussions about RaZberry - Z-Wave board for Raspberry computer
Post Reply
injecteer
Posts: 13
Joined: 29 Sep 2016 16:28

Getting MAC-address or alike in JS

Post by injecteer »

How to get the MAC-address of Raspi in Javascript?
Another device-related unique identifier would also do...
pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

Re: Getting MAC-address or alike in JS

Post by pz1 »

Code: Select all

host = system("hostname -I");
This seems to work without the need to register this command in /opt/z-way-server/automation/.syscommands

see hostname --help for other options
injecteer
Posts: 13
Joined: 29 Sep 2016 16:28

Re: Getting MAC-address or alike in JS

Post by injecteer »

Thanks, you pointed me to the right direction!
I ended up using this:

Code: Select all

var mac = system( 'cat /sys/class/net/eth0/address' )[ 1 ].trim();
As soon as `cat` was not registered in `.syscommands`, I put it in and it worked like charm
Post Reply