JanLoebel / eufy-node-client

Experiment to talk to eufy security
43 stars 6 forks source link

Doorbell working? #2

Closed vandalon closed 3 years ago

vandalon commented 3 years ago

Did you get the doorbell notifications working?

JanLoebel commented 3 years ago

Not yet, no.. Still working on it. It seems they have switched from mqtt to firebase (fcm). So far I've created a frida script to intercept and log P2P and HTTPs messages. But this week I'm in holidays, sorry.

JanLoebel commented 3 years ago

@vandalon now we should be able to listen to any cloud notification so also doorbell notifications should be received. Could you give it a try?

vandalon commented 3 years ago

Hi Jan,

Sure, but can you tell me what you need me to do? :)

JanLoebel commented 3 years ago

Sure, please clone the repository and call npm install to install all needed packages. Then copy the .env.example file to .env and fill in username and password. Afterwards you can start the project with npm start. Wait 10-15seconds and then press your doorbell. You should see the notification in the console.

vandalon commented 3 years ago

I don't see much happening on console. can I turn on debugging so I can see that at least login goes correctly?

vandalon commented 3 years ago

const address = await lookupService.lookup('192.168.68.101');

should this be my eufy homebase 2 ip? :)

JanLoebel commented 3 years ago

That line ist just if you want to test p2p messages and not the push notifications. So you can ignore that line.

vandalon commented 3 years ago

i don't see anything i'm afraid, it just stays silent after I start it.

JanLoebel commented 3 years ago

Strange.. let me include some log statements and retry it at home. I will let you know.

JanLoebel commented 3 years ago

@vandalon I've added some log messages. Please execute a git pull and the npm start. Wait for Ready to listen to push events.... Afterwards try to change the alarm mode in the app or press the door bell and wait some seconds. Sometimes it takes 10 seconds to receive the first push message. If it does not work please attach log lines but remove the credentials.

lexusburn commented 3 years ago

I've cloned your repo, changed the hardcoded ip address of your homebase to mine, builded, created .env with my credentials and run the code. I've got some debug informations then.

After this i changed the method which was called from mainReadMultiPackages() to mainPush(), builded again and started. Now i can see that your code got registered successfully, and is ready to listen to push events but i've get no notifications from doorbell or any other cam. No push messages for motions, arm status changes or ringing doorbell.

I'm registered on the european eufy servers. Does i have to change something in this case?

JanLoebel commented 3 years ago

Yes, depending on your use-case you have to enable / disable the method to call in the index.ts, it's just a library not a product. The login handles the registration on the european eufy servers, so normally you should not need to change anything. Did you get the Ready to listen to push events... console log? Could you remove your tokens from the log and send me the output?

lexusburn commented 3 years ago

Hello Jan, i know that it's not a final product, but i thought that the push part would be work after i enabled the call. ;-)

Here is the output of your script:

> typed@1.0.0 start /home/biermann/eufy/eufy-node-client
> nodemon src/index.ts

[nodemon] 2.0.4
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: ts,json
[nodemon] starting `ts-node src/index.ts`
Starting...
Registered and got credentials: { keys:
   { privateKey: 'myPrivateKey',
     publicKey:
      'myPublicKey',
     authSecret: 'mySecret' },
  fcm:
   { token:
      'tokenA',
     pushSet:
      'd22F_jyEjrU:APA91bGFQMEJJExkfhLFTRAtlWeopdWxQgvvyeYZY5K7HzNmIMwrjuhGbERJzde2S51me0eSkA5B2Kr4mxcQuO-3xaSO7AFDbQKb9JQfU2p2lKLAxZd_vzM3ihjB3e2IJ4qVAa2Y96Gx' },
  gcm:
   { token:
      'tokenB',
     androidId: '5360061810315316255',
     securityToken: 'securityToken',
     appId: '1:970832592257:android:49786eca9d117e162d7c80' } }
Registered push receiver with credentials: { keys:
   { privateKey: 'myPrivateKey',
     publicKey:
      'myPublicKey',
     authSecret: 'mySecret' },
  fcm:
   { token:
      'tokenA',
     pushSet:
      'd22F_jyEjrU:APA91bGFQMEJJExkfhLFTRAtlWeopdWxQgvvyeYZY5K7HzNmIMwrjuhGbERJzde2S51me0eSkA5B2Kr4mxcQuO-3xaSO7AFDbQKb9JQfU2p2lKLAxZd_vzM3ihjB3e2IJ4qVAa2Y96Gx' },
  gcm:
   { token:
      'tokenB',
     androidId: '5360061810315316255',
     securityToken: 'securityToken',
     appId: '1:970832592257:android:49786eca9d117e162d7c80' } }
Registered at eufy with: tokenA
Executed push token check
Ready to listen to push events...

All seems fine, but i've get no push messages. I'm using a second account with admin rights specially for this script which can see all my devices: doorbell, 2 outdoor cams, 1 indoor cam.

The http method is working fine except the dkim-method. The local P2P method is working too.

Would be great if you can help.

JanLoebel commented 3 years ago

@lexusburn there we go. I've tested it also with a second account (admin/guest) and that is not working, it only works with my main account. I will have to check if the second account is within the app able to get push notifications. But currently I'm working on the decryption of the video sequences. So not sure when I will be able to see how that is going. Will leave this issue open as a reminder.

JanLoebel commented 3 years ago

@lexusburn I was curious and debugged the app with my admin account. I could not find any difference. After retrying the script from this morning without touching anything it worked. I guess there could be a timing problem with the registration of the token. But to be sure I've added some more debug information (especially the http-requests). Could you revert your changes in the code (your .env file can stay) and execute git pull to receive the new changes. Afterwards just retry to start via npm start. You don't have to change the hardcoded IP, because it is not used for the PUSH-use-case. If you receive no messages kill the script and wait about 10 minutes and give it another try. If it doesn't work please attach the log again (remember to remove the token / user_id / etc..).

lexusburn commented 3 years ago

@JanLoebel: i updated and now i get more debug output and push token check in a 10 seconds loop. And i've got push events now for my homebase 2.

That looks great:

push-msg-data: { device_sn: '',
  payload:
   { a: 9,
     s: 'T8010N**********',
     t: '1602576301',
     arming: 0,
     mode: 0,
     alarm: 0,
     alarm_delay: 0,
     user: 2,
     user_name: 'myusername' },
  station_sn: 'T8010N**********',
  title: 'Eufy Security',
  type: '0',
  push_time: '1602576302141',
  content: 'Arming change',
  event_time: '1602576301601' }

Therefore it's working now for me. Thank you very much! :-)

One thing i have to check is how i can get the events from internal cam (2k pan & tilt) because now i get only events from homebase 2. I think it's related to push event registration with http method, because the internal camera isn't connected to homebase 2, it's standalone.

JanLoebel commented 3 years ago

@lexusburn great! I don't have a camera which is standalone.. so I can't debug that to check how that works. Sorry :) But if you find any information let me know :)