bropat / eufy-security-client

This shared library allows to control Eufy security devices by connecting to the Eufy cloud servers and local/remote stations over p2p.
MIT License
467 stars 67 forks source link

T8422 Floodlight support #50

Closed fuatakgun closed 2 years ago

fuatakgun commented 2 years ago

Describe the bug
Floodlight camera is seen as disabled and no commands could be sent to it.

To Reproduce
Model: T8422 Device is enabled by the app, start livestream fails with below error. I have also shared the response of 'start_listening' call

2021-10-10 17:56:53.240  ERROR Unexpected error
 RangeError  The value "-128" is invalid for option "size"
details:
{
  code: 'ERR_INVALID_OPT_VALUE'
}
error stack:
• buffer.js:370 alloc
    buffer.js:370:3
• utils.ts:25 stringWithLength
    node_modules/eufy-security-client/src/p2p/utils.ts:25:30
• utils.ts:102 buildIntCommandPayload
    node_modules/eufy-security-client/src/p2p/utils.ts:102:70
• session.ts:337 sendCommandWithInt
    node_modules/eufy-security-client/src/p2p/session.ts:337:25
• station.ts:2359 startLivestream
    node_modules/eufy-security-client/src/http/station.ts:2359:39
• message_handler.ts:100 handle
    src/lib/device/message_handler.ts:100:39
• server.ts:46 device
    src/lib/server.ts:46:34
• server.ts:98 receiveMessage
    src/lib/server.ts:98:58
• server.ts:57 <anonymous>
    src/lib/server.ts:57:53
• events.js:375 emit
    events.js:375:28

Start Listening Response;

station;

        {
          'name': 'Patio',
          'model': 'T8422',
          'serialNumber': 'T8422XYZ',
          'hardwareVersion': 'P1',
          'softwareVersion': '2.0.4.6',
          'lanIpAddress': 'XYZ',
          'macAddress': 'XYZ',
          'currentMode': 1,
          'guardMode': 1,
          'connected': True
        }

device;

        {
          'name': 'Patio',
          'model': 'T8422',
          'serialNumber': 'T8422XYZ',
          'hardwareVersion': 'P1',
          'softwareVersion': '2.0.4.6',
          'stationSerialNumber': 'T8422XYZ',
          'enabled': False,
          'motionDetected': False,
          'personDetected': False,
          'personName': '',
          'autoNightvision': True,
          'ledStatus': True,
          'motionDetection': True,
          'pictureUrl': 'XYZ',
          'motionDetectionType': 5,
          'motionDetectionSensivity': 1,
          'light': False,
          'microphone': True,
          'speaker': True,
          'speakerVolume': 80,
          'audioRecording': True,
          'recordingEndClipMotionStops': False,
          'recordingClipLength': 75,
          'recordingRetriggerInterval': 0,
          'videoStreamingQuality': 0,
          'lightSettingsEnable': True,
          'lightSettingsBrightnessManual': 100,
          'lightSettingsBrightnessMotion': 100,
          'lightSettingsBrightnessSchedule': 100,
          'lightSettingsMotionTriggered': True,
          'lightSettingsMotionTriggeredTimer': 30,
          'notificationType': 2
        }
bropat commented 2 years ago

@fuatakgun

This model has never been tested. To implement it correctly, I need someone to share the device with me.

fuatakgun commented 2 years ago

@rpitera, we need your help here.

rpitera commented 2 years ago

@fuatakgun - can you give @bropat your access or do I need to create another account? I'm OK with you giving @bropat the access or I can create another account. Just let me know how I can help!

fuatakgun commented 2 years ago

@bropat can you share your account details so @rpitera can share the device with you.

bropat commented 2 years ago

@rpitera us or eu account?

rpitera commented 2 years ago

Sorry, for the delay - US Account @bropat. And thanks so much for looking at this.

Some background - I was seeing the T8422 snapshots in ioBroker using the eufy security plugin and the REST API. Then I started having issues with ioBroker after it's last update and I went back to using @fuatakgun's method with the addon/component and it's come such a long way that I'd prefer to stick with it. I've disabled ioBroker, but left it installed in case there's any value in seeing how it handles the 8422.

Again, my thanks to you both.

bropat commented 2 years ago

@rpitera

patrick.broetto+us1@gmail.com

rpitera commented 2 years ago

OK, invite sent.

bropat commented 2 years ago

@rpitera

I have found the error and fixed it. Have tested all functions successfully :)

The only problem now is the "timeout", which does not always occur. From tomorrow until Saturday I am on holiday and will not have the opportunity to work on it. I therefore ask for a little patience so that I can also solve this problem. :)

fuatakgun commented 2 years ago

Enjoy your vacation

rpitera commented 2 years ago

The only problem now is the "timeout", which does not always occur.

Could this just be a network issue on my end? I'm not sure in what context the timeout occurs, but are the conditions comparable across the different models? In other words, are you able to compare the same condition on any of the other cams? If so, then maybe it's signal dropouts on my wifi; I have been experiencing them for a while now and just learned to live with it until I replace my router. But it's never caused the other eufycams from producing a last event url - or at least they recover, because I'm still getting last event snapshots (which, honestly is more important to me personally as I don't need to stream from HA often).

Anyways, rambling aside, my thanks for finding this so quickly. Take as long as you need and I hope you make an effort to enjoy yourself! If there is any other info or tests I can run on my end, please don't hesitate to ask.

Thanks @fuatakgun for getting me connected and figuring this out.

And I guess I'm moving up the router project...

bropat commented 2 years ago

@fuatakgun @rpitera

I have found the cause. ;)

rpitera commented 2 years ago

Damn. Talk about your cliffhangers.... tune in for the next episode! LOL

(Nice one @bropat!)

bropat commented 2 years ago

@fuatakgun @rpitera

I am effectively not getting the feedback packet from the station, so the error is correct. Interestingly, the Eufy Station has just now been updated with new firmware.... Let's see if the problem is still there :P

fuatakgun commented 2 years ago

Have you seen this menu in app?

Screenshot_2021-10-12-23-47-33-081_com.oceanwing.battery.cam.jpg

bropat commented 2 years ago

@fuatakgun

yes I have. @rpitera has enabled Performance.

bropat commented 2 years ago

When I have the timeout problem, it persists throughout the connection, mainly with the P2P command 1103. If I disconnect and reconnect and the error does not occur, it runs fine.

bropat commented 2 years ago

It could be that certain commands that I have discovered through reverse engineering lead to this instability in a certain sequence. It would be interesting to know if this timeout problem only occurs with many devices. For example, I have 2 Eufycam 2 connected to one station and have never had this problem.

bropat commented 2 years ago

Anyway, this new performance setting makes me think of nothing good.... :P As the description says:

"Enhance stability and fluency when connecting multiple devices"

bropat commented 2 years ago

@fuatakgun

How many devices have you registered at the station?

bropat commented 2 years ago

That's enough for today. I'll be in touch when I return from my holiday.

rpitera commented 2 years ago

If you suggest turning it off, I will. But I mean at this point you have admin so feel free to do it yourself if you think it's best.

It would be interesting to know if this timeout problem only occurs with many devices. For example, I have 2 Eufycam 2 connected to one station and have never had this problem.

The irony is that the only one exhibiting the issue is the one that doesn't connect to the base station. Though there IS a sync button on it and Eufy has said this might/would/kinda come in a future FW update when I asked. It was a company contact provided to me via Best Buy - I do reviews for them in exchange for products and the Floodlight Cam was one of them.

fuatakgun commented 2 years ago

@fuatakgun

How many devices have you registered at the station?

4 devices, all are 2c

rpitera commented 2 years ago

You should be able to enjoy it even more knowing that you found the issue. Cheers! See you when you get back.

bropat commented 2 years ago

@rpitera

The irony is that the only one exhibiting the issue is the one that doesn't connect to the base station.

The timeout comes from the base station not from the floodlight. The floodlight is working well after my fix.

bropat commented 2 years ago

@fuatakgun

If I understand correctly, you also have a timeout problem with the base station. Correct? If so, you can try removing 2 of the 4 cameras from the base station, reboot it and then test everything again and check if the timeout still occurs.

After this test, you can of course return to the previous configuration. ;)

bropat commented 2 years ago

@fuatakgun

Have you done the test described above?

bropat commented 2 years ago

Added in version 1.2.0

yieldhog commented 2 years ago

Hi @bropat -- can you have a look when you get a chance at T8424? I am available to test. Thank you