Comments (5)
Hello @scInvest
To get the arp table, you can just do:
const Zeroconf = require('ewelink-api/classes/Zeroconf');
const arp = await Zeroconf.getArpTable('192.168.5.1');
To get devices data:
const connection = new ewelink({
email: 'user',
password: 'pass',
});
const devices = connection this.getDevices();
Then you can use arp
and devices
to connect.
from ewelink-api.
await connection.saveDevicesCache();
works, but:
const arp = await Zeroconf.getArpTable('192.168.1.1');
returns nothing...
Can you show example of the json structure saved in the file and I'll create my own while I figure out why its not working.
I'll create from the avahi-browse:
from ewelink-api.
There was a problem with the arp package who was fixed and merged today.
Here is the expected format:
[
{
"ip": "192.168.100.1",
"mac": "aa:bb:cc:dd:ee:ff"
},
{
"ip": "192.168.100.2",
"mac": "aa:bb:cc:dd:ee:ee"
}
]
from ewelink-api.
There was a problem with the arp package who was fixed and merged today.
I just removed the release 2 branch I'd installed and re-installed the master branch which is the 2.0.0 release (including fix I assume).
Still doesn't work (for me).
I'm using ubuntu 18.04 (will update to 20.04 when released).
from ewelink-api.
I haven't looked through the code just yet but I'm guessing the ArpTable is used to map the mac address to the ip.
What your really after is what is the ip address of the device id, I assume your looking for the mac address in the device cache then looking for the ip address in the ArpTable.
What you really want is a table mapping device id's to ip addresses.
The following linux command:
avahi-browse -arlcfp | grep -P '^=' | grep "eWeLink" \
| pcre2grep -o2 -o1 -i --om-separator='|' 'local;eWeLink_(1000[0-9a-f]{6}).local;(192.168.1\..+);8081;' \
| gawk -F '|' -e 'BEGIN{print "{";li="";}{printf li" \"%s\": \"%s\"",$2,$1;li=",\n";}END{print "\n}";}' \
> deviceip-table.json
creates the json file deviceip-table.json, which contains:
{
"1000xxxxxx": "192.168.1.233",
"1000xxxxxx": "192.168.1.220",
"1000xxxxxx": "192.168.1.238",
"1000xxxxxx": "192.168.1.237",
"1000xxxxxx": "192.168.1.202",
"1000xxxxxx": "192.168.1.249",
"1000xxxxxx": "192.168.1.227"
}
Therefore if the json is read into an array deviceIP all we need to do to resolve the ip address is use the device id, ie:
deviceIP[<deviceid>]
BTW: avahi-browse works best when the devices are disconnected from the WAN as the devices broadcast their availability more often. OR launch the eWeLink app on your phone and enter LAN mode which somehow probes the LAN.
To create the table as currently execute the following script:
TMP=`mktemp -d`
avahi-browse -arlcfp | grep -P '^=' | grep "eWeLink" \
| pcre2grep -o2 -i 'local;eWeLink_(1000[0-9a-f]{6}).local;(192.168.1\..+);8081;' \
| sort | tee $TMP/ewedev | gawk -F '|' -e '{print "ping -n -c 3 "$1}' | bash
/usr/sbin/arp -an | pcre2grep -o1 -o2 -i --om-separator='|' '\? \((.*)\) at (.*) \[ether\]' | sort > $TMP/ipmac
join -t '|' $TMP/ipmac $TMP/ewedev \
| gawk -F '|' -e 'BEGIN{print "[";li="";}{printf li" {\n \"ip\":\"%s\",\n \"mac\":\"%s\"\n }",$1,$2;li=",\n";}END{print "\n}";}' \
> arp-table.json
rm -rf $TMP
from ewelink-api.
Related Issues (20)
- { error: 500, msg: 'SyntaxError: Unexpected token < in JSON at position 0' } HOT 1
- New and Simple REST API with Ready Scripts
- Error 401: Wrong account or password HOT 21
- ewelink
- Unable to install on Raspberry Pi
- THR316 doesn't update
- Unable to use power consumption with sonoff POW Elite HOT 6
- Get Voltage and current on POWR2 device HOT 2
- CoolkIt: Announcement regarding the expiration of the APPID referenced in this project and the cessation of maintenance of the v1 interface, suggesting migration HOT 7
- Error 401: Wrong account or password -- again HOT 54
- Error: 406 { error: 406, msg: 'Authentication failed' } HOT 21
- Support for changing the network indicator led?
- Is There Any PHP Version HOT 1
- error: 401, msg: 'Wrong account or password'
- Sonoff Dual R3 - Power Consumption Issue HOT 1
- Retrieve Room Names
- Reading the list of shared devices
- Switch to manual or automatic mode
- websocket closes unexpectedly, causing Node Red to crash
- { error: 406, msg: 'Authentication failed' } I am using right email and password HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ewelink-api.