JanLoebel / eufy-node-client

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

Some additional debug information you might want #4

Closed rogro82 closed 3 years ago

rogro82 commented 3 years ago

Thanks for your amazing work! I have been analyzing some additional data to send commands to each device (channel) and with some minor adjustments its working.

Wireshark logs:

cam0 off: 8800 0000 0100 0000 0000 0000 0000 0100 0000 cam0 on: 8800 0000 0100 0000 0000 0000 0000 0000 0000 cam1 off: 8800 0000 0100 0100 0000 0100 0000 0100 0000 cam1 on: 8800 0000 0100 0100 0000 0100 0000 0000 0000 cam2 off: 8800 0000 0100 0200 0000 0200 0000 0100 0000 cam2 on: 8800 0000 0100 0200 0000 0200 0000 0000 0000

I have altered buildIntStringCommandPayload to include the channel (0x00, 0x01, 0x02) as can be seen above. These correspond with device_channel in the json-payload received from get_devs_list.

export const buildIntStringCommandPayload = (value: number, actor: string, channel = 0): Buffer => {
  const headerBuffer = Buffer.from([0x88, 0x00]);
  const emptyBuffer = Buffer.from([0x00, 0x00]);
  const magicBuffer = Buffer.from([0x1, 0x00]);
  const channelBuffer = Buffer.from([channel, 0x00]);
  const valueBuffer = Buffer.from([value, 0x00]);
  const actorBuffer = Buffer.from(actor);
  const rest = Buffer.alloc(88);

  return Buffer.concat([
    headerBuffer,
    emptyBuffer,
    magicBuffer,
    channelBuffer,
    emptyBuffer,
    channelBuffer,
    emptyBuffer,
    valueBuffer,
    emptyBuffer,
    actorBuffer,
    rest,
  ]);
};

Now you can send commands to the individual channels:

To switch individual cameras on/off use command 0b04 (1035) with 0 (on) or 1 (off)

Turn camera 0 on service.sendCommandWithIntString(CommandTypes.CMD_DEVS_SWITCH, 0, 0);

Turn camera 2 off service.sendCommandWithIntString(CommandTypes.CMD_DEVS_SWITCH, 1, 2);

Im currently using CMD_NAS_TEST to manually start/stop the RTSP stream which seems to work just fine.

JanLoebel commented 3 years ago

Awesome, do you want to open a pull request for your updated: buildIntStringCommandPayload method? Or should I just include it?

JanLoebel commented 3 years ago

@rogro82 I've added your changes to the code! Thanks! You've wrote that you use the CMD_NAS_TEST command to start/stop RTSP, can you give some further details? With which method and value do you send that command and how can you access the RTSP then?

rogro82 commented 3 years ago

Thanks! Sorry i totally overlooked your previous message.

If you have the doorbell you first need to enable RTSP. I guess you can just use CMD_NAS_SWITCH to enable RTSP for the doorbell, but before I had that working I had already decompiled the Android app and basically the RTSP support is there but the menu-option is just hidden. I altered the smali-code and compiled/signed and after that I could enable RTSP like all the other camera's.

I use CMD_NAS_TEST as that is what is used in the app to manually start the stream when setting up the RTSP connection on a NAS. It enables the RTSP stream for a fixed amount of time, so you can just use that to start recording using anything you want.

Currently i use your push-message solution to run CMD_NAS_TEST and then cast the stream from my synology to my homehub when someone rings the doorbell. Its not perfect yet but its getting there.

rogro82 commented 3 years ago

The command I use to manually enable the RTSP stream ( on device/channel 2 ):

service.sendCommandWithIntString(CommandTypes.CMD_NAS_TEST, 1, 2);