Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
joshstrange committed May 10, 2019
1 parent 6212a32 commit efb850e
Show file tree
Hide file tree
Showing 8 changed files with 4,704 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,5 @@ typings/

# next.js build output
.next

dist
66 changes: 65 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,66 @@
# eufy-robovac
NodeJS library to control Eufy RoboVac
NodeJS library to control Eufy RoboVac. This library relies heavily on [TuyAPI](https://github.com/codetheweb/tuyapi) for communicating with the RoboVac and would not be possible without the [eufy_robovac](https://github.com/mitchellrj/eufy_robovac) repo by [mitchellrj](https://github.com/mitchellrj) as reference.


## Required Information

* RoboVac Device Id OR IP address of RoboVac
* RoboVac localKey

You can get both pieces of information by using logcat to "sniff" the data on an android phone OR emulator.


> More detailed steps on using logcat:
> 1. Close the app on your mobile device
> 2. Connect the device to your laptop and enable USB debugging
> 3. Run adb logcat -e 'tuya.m.my.group.device.list' (assumes you have already installed the Android debug tools)
> 4. Launch the Eufy Home app
> 5. The output lines contain JSON, you're looking for the values of localKey (16 character hex string) and devId (20 character hex string).
HUGE THANKS to [mitchellrj](https://github.com/mitchellrj) for [figuring this out](https://github.com/google/python-lakeside/issues/16#issuecomment-484792907)!

I had to use `adb shell -e 'tuya.m.my.group.device.list'` on my Mac running BlueStacks emulator to get it to work but your mileage may vary. You may also not need to run BlueStacks but it was the easiest method for me. I installed the [EufyHome](https://play.google.com/store/apps/details?id=com.eufylife.smarthome) into the emulator and logged in and was able to grab my id/key.


## Demo

To test out if this library can talk to your RoboVac follow the steps below:

```
git clone [email protected]:joshstrange/eufy-robovac.git
cd eufy-robovac
npm install
npm run demo <deviceId | ipAddress> <localKey> <command>
```

Where command is either "quickTest" or "status". The `quickTest` command will:

* Connect to your device
* Print out the current statuses
* Start cleaning
* Wait 10 seconds
* Pause cleaning
* Wait 1 second
* Send device home
* Wait 1 second
* Disconnect & exit

The `status` command will simply print out the current statues and exit.

**NOTE: There is a decent amount of console.logs scattered around for debugging purposes that I haven't cleaned up yet so it might be a little... louder than you want**

I'm open to pull requests and I hope to use this library to implement a HomeBridge plugin in the near future. If you have any questions open an issue and I'll try my best to help.

I have published this on npm:

```
npm install --save eufy-robovac
```

I will try to keep the npm package updated. Also the type definitions for TypeScript are included.


## Development

This library is written in TypeScript. You should just need to run `npm run build` after making changes in the `src/` directory.
57 changes: 57 additions & 0 deletions demo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
let lib = require('./dist/index');

const RoboVac = lib.RoboVac;

if(process.argv.length !== 5) {
console.error("You must pass at least 3 params:");
console.log("npm run demo <deviceId | ipAddress> <localKey> <command>");
console.log("");
console.log("Available Commands:");
console.log("status - Prints current statuses");
console.log("quickTest - Runs your vacuum for 10 seconds then returns to base");
process.exit(0);
}

(async () => {
let config = {
localKey: process.argv[3]
};

// Hacky ip check, if device id's ever have periods in them this could be an issue
if(process.argv[2].indexOf('.') !== -1) {
config.ip = process.argv[2];
} else {
config.deviceId = process.argv[2];
}

try {
let r = new RoboVac(config);
if(process.argv[4] === 'status') {
await r.getStatuses();
r.formatStatus();
await r.disconnect();
} else if(process.argv[4] === 'quickTest') {
await r.getStatuses();
r.formatStatus();
console.log("Demo: startCleaning");
await r.startCleaning();
await sleep(10000);
console.log("Demo: pause");
await r.pause();
await sleep(1000);
console.log("Demo: goHome");
await r.goHome();
await sleep(2000);
await r.disconnect();
} else {
console.error("Unknown command: " + process.argv[4]);
process.exit(0);
}
} catch (error) {
console.error("ERROR: " + JSON.stringify(error));
}
})();

function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
Loading

0 comments on commit efb850e

Please sign in to comment.