Comments (5)
@wormiedk have you any experience in javascript/node.js?
from eufy-node-client.
a little but normally I get by modifying examples. I found this on another forum but cannot get it to work
What I did:
sudo npm install -g typescript
git clone https://github.com/JanLoebel/eufy-node-client.git
cd eufy-node-client/src
nano test.ts
Contents of test.ts:
import { HttpService } from './http/http.service';
import { CommandTypes } from './p2p/command.model';
import { DeviceClientService } from './p2p/device-client.service';
import { LocalLookupService } from './p2p/local-lookup.service';
import { PushMessage } from './push/push.model';
import { PushService } from './push/push.service';
(async () => {
const httpService = new HttpService(USERNAME, PASSWORD);
const hubs = await httpService.listHubs();
if (hubs && hubs.length > 0) {
const hub = hubs[0];
const lookupService = new LocalLookupService();
const address = await lookupService.lookup(HOMEBASE_IP);
const service = new DeviceClientService(address, hub.p2p_did, hub.member.action_user_id);
const connected = await service.connect().catch((error) => {
console.log('error trying to connected:', error);
return false;
});
if (connected) {
console.log('p2p connected, start listening for push messages');
const pushService = new PushService();
const credentials = await pushService.createPushCredentials();
pushService.listen(credentials, async (msg: PushMessage) => {
const event = msg.data;
const payload = event.payload;
if (payload && payload.event_type === 3103 && payload.channel === 2 && payload.push_count === 1) {
console.log('doorbell pressed');
if (!streaming) {
service.sendCommandWithIntString(CommandTypes.CMD_NAS_TEST, 1, 2);
streaming = true;
setTimeout(() => {
if (streaming) {
service.sendCommandWithIntString(CommandTypes.CMD_NAS_TEST, 0, 2);
}
streaming = false;
}, 6000);
}
await got.get('url_to_a_webhook');
}
});
// Register generated token
const fcmToken = credentials.fcm.token;
await httpService.registerPushToken(fcmToken);
await httpService.pushTokenCheck();
}
} else {
console.warn('no hub found');
}
})();
However this results in an error when trying to compile using
tsc test.ts
test.ts:2:10 - error TS2724: Module '"./p2p/command.model"' has no exported member 'CommandTypes'. Did you mean 'CommandType'?
2 import { CommandTypes } from './p2p/command.model';
~~~~~~~~~~~~
p2p/command.model.ts:1:13
1 export enum CommandType {
~~~~~~~~~~~
'CommandType' is declared here.
test.ts:35:16 - error TS2304: Cannot find name 'streaming'.
35 if (!streaming) {
~~~~~~~~~
test.ts:37:13 - error TS2304: Cannot find name 'streaming'.
37 streaming = true;
~~~~~~~~~
test.ts:40:19 - error TS2304: Cannot find name 'streaming'.
40 if (streaming) {
~~~~~~~~~
test.ts:43:15 - error TS2304: Cannot find name 'streaming'.
43 streaming = false;
~~~~~~~~~
test.ts:46:17 - error TS2304: Cannot find name 'got'.
46 await got.get('url_to_a_webhook');
from eufy-node-client.
Try this:
- cd eufy-node-client/
- sudo npm i @types/node
- tsc -b
- cd build
- node index.js
Now tell me what to do next :-D I really want to be able to control the security mode with home assistant!
from eufy-node-client.
After @bropat and I will finish the push-rework, I will restructure the index.ts and write some more documentation how to get started. But this is and will stay a library for other developers not users.
from eufy-node-client.
I've created a new repository with a 'Getting started' guide. If you have any problems / questions for that, please create an issue there.
https://github.com/JanLoebel/eufy-node-client-examples
from eufy-node-client.
Related Issues (17)
- Very interested! HOT 1
- Environment Setup
- Doorbell without homebase HOT 1
- Feature: Disconnect from P2P-Device-Client
- LocalLookupService.lookup timeout but works with CloudLookupService.lookup HOT 18
- Doorbell working? HOT 17
- Experiencing issues in homebridge HOT 16
- PushRegisterService HOT 1
- help starting node.js HOT 2
- Implementing this for Node-Red? HOT 1
- EuFy Security: Petition for open source API’s, a Dev share program, and direct App to hardware communication
- Some additional debug information you might want HOT 4
- Misconception: first/last multipart message HOT 1
- Is it possible to activate profiles with this? HOT 3
- http requests help HOT 8
- Push notification no longer works correctly HOT 30
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 eufy-node-client.