Coder Social home page Coder Social logo

bropat / eufy-security-client Goto Github PK

View Code? Open in Web Editor NEW
466.0 466.0 67.0 2.61 MB

This shared library allows to control Eufy security devices by connecting to the Eufy cloud servers and local/remote stations over p2p.

License: MIT License

TypeScript 99.91% JavaScript 0.09%
cam doorbell eufy eufy-cloud eufycam eufysecurity homebase

eufy-security-client's People

Contributors

bassrock avatar bropat avatar fuatakgun avatar justinlindh avatar lenoxys avatar martijnpoppen avatar martinh1982 avatar palmke avatar philippengler avatar piitaya avatar smitty078 avatar thieren avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

eufy-security-client's Issues

StationGuardModeProperty in types is missing 6: "Off"

Trying to setGuardMode on station to 6 throws the following error:

(node:6913) UnhandledPromiseRejectionWarning: InvalidPropertyValueError: Value "6" isn't a valid value for property "guardMode"
at Object.validValue (/usr/lib/node_modules/homebridge-eufy-security-control/node_modules/eufy-security-client/src/utils.ts:108:19)
at Station.setGuardMode (/usr/lib/node_modules/homebridge-eufy-security-control/node_modules/eufy-security-client/src/http/station.ts:513:13)

I think 6: "Off" should be added to StationGuardModeProperty here?

5: "CUSTOM3",

Adapter

Hallo

Ich hatte den Eufy Adapter installiert gehabt. Leider ging er nicht mehr online. Habe ihn gelöscht und neu insatlliert. Leider erscheint er nicht mehr.
Kannst du mir dabei helfen?
Gelöscht habe ich ihn mit
del iobroker eufy-security
Installiert anschliessend über git.
Installation funktionierte einwandfrei. Die Ordner wurden lle wieder angelegt. Nur die Instanz erscheint nicht mehr.
Danke für deine Hilfe
Gruss Philu

T8424 Floodlight support

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

To Reproduce
Model: T8424
Device is enabled by the app, push notifications on, start livestream fails with below error. I can share stream if you need to debug.

2021-11-07 14:28:01.821  INFO Push notification connection successfully established 
2021-11-07 14:28:11.731  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

Request: RTSP Stream Support for T8111

Sorry to be a pain with these older cameras but may I ask for some help with RTSP stream support?

• station.ts:815 setRTSPStream
node_modules/eufy-security-client/src/http/station.ts:815:19

• message_handler.ts:35 handle
src/lib/device/message_handler.ts:35:31

• server.ts:46 device
src/lib/server.ts:46:34

• server.ts:98 receiveMessage
src/lib/server.ts:98:58

• server.ts:57
src/lib/server.ts:57:53

• events.js:376 emit
events.js:376:20

• websocket.js:834 receiverOnMessage
node_modules/ws/lib/websocket.js:834:20

• events.js:376 emit
events.js:376:20

• receiver.js:437 dataMessage
node_modules/ws/lib/receiver.js:437:14

• receiver.js:367 getData
node_modules/ws/lib/receiver.js:367:17

2021-07-28 17:14:06.861 ERROR Message error
NotSupportedFeatureError This functionality is not implemented or supported by T8111H1219031E29

T8422 Floodlight support

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
        }

T8420 Floodlight: certain properties don't work properly

I'm using the HomeBridge plugin (which uses this library) for a T8420 Floodlight Camera and I'm getting lots of errors like this:

handleEnableGet Wrong return value

I've looked at the plugin code and it seems it's actually an issue with this library as the plugin is calling Camera.getPropertyValue(PropertyName.DeviceEnabled); which is throwing an exception that the plugin is catching. It's throwing the exception as getPropertyValue() isn't finding a property called enabled.

EDIT: Have been doing some digging around, although neither Node nor Javascript is my happy place 🙂 and, from what I can see, the T8420 doesn't seem to support the 'enabled' (ID2001) or 'motion detection' (ID6040) properties.

I'm only basing this on looking at Device.metadata, Device.rawProperties and Device.properties so I may well be way off here! Is anyone able to confirm?

Simple way to control security cam lights

Could someone help me with a how-to guide to control the outdoor security camera floodlights? Ideally I would like to expose this feature in HomeKit via HomeBridge.

Thanks!

Corrupt mp4 when downloading file via station.start_download

I was following the instructions provided in the FuzzyMistborn repo and I don't have much experience with npm and node.js - but I was able to throw together a test script to download a single video. I am at step 5 and trying to process the videoStream coming from the start_download event and when I try to pipe that to a filestreamwriter the resulting file is not a recognized MP4 file when I try to play it.

Wondering if there is some other step I need to do here, thank you and appreciate the help.

  1. Open a P2P connection to the relativ station
  2. use the Station method startDownload to download all videos one by one by using the parameters you got in the 1st call
  3. you get the data of the respective video now over the event start_download
  4. Process the data and save to file
const { Device, Station, HTTPApi, P2PClientProtocol, P2PConnectionType } = require('eufy-security-client')
const fs = require('fs');

const main = async () => {

  const httpService = new HTTPApi("[email protected]", "XXXXXXXXXXXX");
  await httpService.updateDeviceInfo();
  const hubs = httpService.getHubs();
  //console.log(hubs);
  const devices = httpService.getDevices();
  //console.log(devices);

  const videos = await httpService.getAllVideoEvents();
  console.log('First Video P2P_DID', videos[0].p2p_did);

  const device = new Device(httpService, devices[videos[0].device_sn]);
  const station = new Station(httpService, hubs[videos[0].station_sn]);

  station.on("start_download", function (station, channel, metadata, videoStream, audioStream) {
    testFile = fs.createWriteStream('test.mp4', {encoding: 'binary'});
    console.log('Station start_download!: ' + channel);
    videoStream.pipe(testFile);
  });

  station.on("finish_download", function (station, channel) {
    console.log('Station finish_download!: ' + channel);
    station.close();
  });

  await station.connect(P2PConnectionType.PREFER_LOCAL, true);

  // wait 2 seconds to start download
  await new Promise(resolve => setTimeout(resolve, 2000));

  await station.startDownload(device, videos[0].storage_path, videos[0].cipher_id);

};

Feature request: Trigger pre recorded response

Could you please add the option to trigger the voice reply.
I can in example trigger the default sentence "Please leave it at the door" from the app and would like to be able to do this from code. Basically like the current quick response but with the custom recorded messages.

Is it possiblem to force getLastCameraImageURL() to be updated

Is it possible to force a new snapshot to be generated for a eufy cam? We use getLastCameraImageURL in homebridge and homebridge has default functionality for updating snapshots at an interval. However the getLastCameraImageURL only seems to change when an event has been triggered.

Homebridge plugin development

Feature Request: Add ability to change state variable

Add the ability to change eufy-security.0.CAMERA_ID.cameras.CAMERA_ID.state?

Reading state is currently present, but changing state not yet.

State variables:
{
“0”: “OFFLINE”,
“1”: “ONLINE”,
“2”: “MANUALLY_DISABLED”,
“3”: “OFFLINE_LOWBAT”,
“4”: “REMOVE_AND_READD”,
“5”: “RESET_AND_READD”

Thank you so much in advance, great code.

Using FloodLight Camera, isEnabled() and isMotionDetectionEnabled() return the value directly instead of PropertyValue

Describe the bug
Using FloodLight Camera, isEnabled() and isMotionDetectionEnabled() return the value directly instead of PropertyValue

public isEnabled(): PropertyValue {

public isMotionDetectionEnabled(): PropertyValue {

To Reproduce
You need a floodlight camera

Expected behavior
These 2 functions should return PropertyValue. The guy who is facing this, removed me the shared access to the floodlight. So I can't dig on it.

Screenshots & Logfiles

[2021-08-23T09:29:31.588Z] DEBUG: ef/32061 on v1.0.0-rc.2: Found device T8210PXXXXXXXX Front of the House BATTERY_DOORBELL
[2021-08-23T09:29:31.588Z] DEBUG: ef/32061 on v1.0.0-rc.2: Found device T8420NXXXXXXXX Backyard FLOODLIGHT

[2021-08-23T09:29:49.530Z] DEBUG: ef/32061 on v1.0.0-rc.2: Front of the House Triggered GET Motion: { value: true, timestamp: 1626738263000 }
[2021-08-23T09:29:49.531Z] DEBUG: ef/32061 on v1.0.0-rc.2: Backyard Triggered GET Enable: undefined
[2021-08-23T09:29:49.532Z] ERROR: ef/32061 on v1.0.0-rc.2: Backyard handleEnableGet Wrong return value


[2021-08-23T09:29:49.532Z] DEBUG: ef/32061 on v1.0.0-rc.2: Front of the House Triggered GET MotionDetected: false
[2021-08-23T09:29:49.532Z] DEBUG: ef/32061 on v1.0.0-rc.2: Front of the House Triggered GET Motion: { value: true, timestamp: 1626753557000 }
[2021-08-23T09:29:49.532Z] DEBUG: ef/32061 on v1.0.0-rc.2: Backyard Triggered GET MotionDetected: false
[2021-08-23T09:29:49.533Z] DEBUG: ef/32061 on v1.0.0-rc.2: Backyard Triggered GET Motion: undefined
[2021-08-23T09:29:49.533Z] ERROR: ef/32061 on v1.0.0-rc.2: Backyard handleMotionOnGet Wrong return value

Versions:

  • Client version: 1.1.2
  • Node version: v14.17.5
  • Operating system: debian

Additional context
Add any other context about the problem here.

Using speaker and microphone from Eufy cam?

Hello,
Some devices like the Eufy Solo IndoorCam 2k Pan&Tilt P24 allow two way communication. Is there some way to use the speaker and microphone of these devices by this library? I looked through the code but could not find something but maybe I overlooked something.

plugin available for hoobs ?

Hello i am using hoobs on my raspberry. but didn't found your plugin in the library for installing.
maybe a stupid question but iam ot a professional.

thanks

Can't configure the plugin in Homebridge

I’m a total newbie to this so please apologize for the stupid questions.
I've installed homebridge on a raspberry pi and wanted to install your Eufy Security Client plugin.
So I used the command : npm install Eufy-security-client and got it on the system.
But I can’t see it listed in the homebridge plugin list or neither access any UI to configure the plugin.

I guess there is something I’m doing wrong or maybe it isn’t ready yet to function on homebridge ?
I would love your advice and guidance to help me set up my battery video doorbell with homebridge.

I’m using this plugin for now : https://github.com/birkir/homebridge-plugin-eufy-security
But wasn't really satisfied as it won’t stream the video in HomeKit.

I wanted to give your plugin a try.

Any help is welcome

thanks

Multiple RTSP streams are not managed

Describe the bug
I can send commands to start RTSP on multiple cameras and they are working fine but when I need to stop, only last one is succeeded and initial ones are throwing errors.

To Reproduce
Steps to reproduce the behavior:

set_rtsp_stream serial_number_2 True -> rtsp_livestream_started event generated
set_rtsp_stream serial_number_1 True -> RTSPLivestreamNotRunningError  RTSP livestream for device serial_number_1 could not be stopped, because it is not running
set_rtsp_stream serial_number_2 True -> rtsp_livestream_stopped event generated

Expected behavior
As RTSP is managed by devices, there is no reason to limit number of parallel streams. They should all be playing independently.

Versions:
Eufy Security WS 0.5.2

Token error: return code 401, invalidate token

Describe the bug
I seem to be not getting a clean run with setting guard mode.
I am using the examples that are present in a PR here: #19

When trying to connect I get the following log output.

Load previous login_hash:
Authenticate and get an access token
Request:
done
Response:
Switching to another API_BASE (https://security-app-eu.eufylife.com/v1) and get new token.
Renew token
Authenticate and get an access token
Request:
Response:
Response code not ok
Token error
Authenticate and get an access token
Request:
Response:
Response code not ok
Token error
Request:
Status return code 401, invalidate token
Stations - Response:
Status return code not 200
Authenticate and get an access token
Request:
Response:
Response code not ok
Token error
Request:
Status return code 401, invalidate token
Devices - Response:
Status return code not 200

I don't have any problem logging into the official portal (or the phone app), but I now get a captcha.
Could this be stopping a correct logon?

I have tried deleting the persistence file, but this has no affect.

This did once work, so not sure what has changed.

Steps to reproduce
I followed the example code

I have 2x 2K Indoor Pan/Tilt cams

Versions
Node Version: v12.22.2
Module Version: 1.2.1

image

getAllVideoEvents fails with 404

Describe the bug

When calling await eufy.getApi().getAllVideoEvents() a 404 error is returned.

To Reproduce
Steps to reproduce the behaviour:

  1. Call await eufy.getApi().getAllVideoEvents()
  2. Wait for 404

Expected behaviour
A list of video events to be returned

Screenshots & Logfiles

2021-11-22 14:55:15.001  DEBUG [HTTPApi.request] Request:
{
  method: 'post',
  endpoint: 'event/app/get_all_video_record',
  baseUrl: 'https://security-app-eu.eufylife.com',
  token: '<REDACTED>',
  data: {
    device_sn: '',
    end_time: 1637592915,
    id: 0,
    id_type: 1,
    is_favorite: false,
    num: 1000,
    pullup: true,
    shared: true,
    start_time: 1164552915,
    station_sn: '',
    storage: 0,
    transaction: '1637592915001'
  },
  headers: {
    app_version: 'v3.3.1_1058',
    os_type: 'android',
    os_version: '30',
    phone_model: 'EUFYCLIENT',
    country: 'GB',
    language: 'en',
    openudid: '<REDACTED>',
    uid: '',
    net_type: 'wifi',
    mnc: '02',
    mcc: '262',
    sn: '<REDACTED>',
    Model_type: 'PHONE',
    timezone: 'GMT+00:00',
    'Cache-Control': 'no-cache',
    'User-Agent': 'okhttp/3.12.1',
    'X-Auth-Token': '<REDACTED>'
  }
}
2021-11-22 14:55:15.029  DEBUG [HTTPApi._getEvents] getVideoEvents - Response: 404 page not found
2021-11-22 14:55:15.029  ERROR [HTTPApi._getEvents] getVideoEvents - Status return code not 200
{
  status: 404,
  statusText: 'Not Found'
}

Versions:

  • Client version: 1.3.0
  • Node version: v14.18.1
  • Operating system: OSX

Additional context
Seems to be new since the 204 error code fix?

`livestream video data` event is not fired

Describe the bug
With latest update, I am not able to receive livestream video data events anymore. I have tried with two different cameras, both 2c, and only receiving livestream audio data events without video.

To Reproduce
Steps to reproduce the behavior:

  1. Start eufy-security-ws server
  2. Initiate start listening
  3. Send start live stream command
  4. I have received successful message and received chunks of audio data but video data is missing

Expected behavior
Next to audio data, video chunks should be forwarded

Screenshots & Logfiles
image

Versions:

  • Client version:
  • Node version:
  • Operating system:

Additional context
Tested with my own fork (https://github.com/fuatakgun/eufy_security) and livestream_video_data events are raised.
image

Password can't be entered properly.

When entering the password, the field to enter disappears. Password with @ symbol is not stored properly.
JSON download shows nonsense password.
Manually editing password in JSON and uploading that one works fine.

Thomas

Changing guardmode to home (value 1) doesn't trigger a push notification

When changing guard mode on station to 1 no push notification is generated. 0, 3 and 63 all generate push notifications. Don't know if it is guardModeChanged or currentModeChanged that prevents the call to emit of guard mode.

this.emit("guard mode", this, message.station_guard_mode, message.station_current_mode);

https://github.com/bropat/eufy-security-client/blob/master/src/http/station.ts#L288-L290

Log:
this.eufyStation.setGuardMode(63);
{"name":"eufyLog","hostname":"raspberrypi","pid":14352,"level":30,"msg":"Alarm mode for station T8010P2320281428 changed to: DISARMED","time":"2021-06-10T21:07:02.384Z","v":0}
{"name":"eufyLog","hostname":"raspberrypi","pid":14352,"level":30,"msg":"Received push notification for changing guard mode { guard_mode: 63, current_mode: 63, stationSN: 'T8010P2320281428' }","time":"2021-06-10T21:07:03.012Z","v":0}

this.eufyStation.setGuardMode(1);

{"name":"eufyLog","hostname":"raspberrypi","pid":14352,"level":30,"msg":"Alarm mode for station T8010P2320281428 changed to: HOME","time":"2021-06-10T21:07:03.726Z","v":0}
{"name":"eufyLog","hostname":"raspberrypi","pid":14352,"level":30,"msg":"Received push notification for changing guard mode { guard_mode: 1, current_mode: 1, stationSN: 'T8010P2320281428' }","time":"2021-06-10T21:07:04.091Z","v":0}

Version 0.8.3

Documentation

Hi! thanks for the amazing work, do you have plans to add any documentation/examples on how to use the client?

Take a picture?

Hi @bropat, hi all,

first of: thank you for this library 😍 Very cool, all the effort your pour into this.

My question: has anybody figured out how to trigger this "take a picture" functionality? I would love to take a picture every hour to later glue together a timelapse. But I couldn't find anything in your API.

Did I overlook it? Or is it not something the API actually provides? I thought maybe it was just the Android App actually taking a picture from the rtsp stream but then again it's got 3MP (2304*1296, 2MB) and it doesnt seem to be too dependent on the quality of the actual stream. I might be mistaken of course.

Or even better, take a snapshot and save it onto the Station? Or for that matter: trigger a recording onto the station (without motion happening necessarily) ?

Thanks
Andreas

Wrong 0.9.2 Version

The 0.9.2 is not the good one on npm.
I think the npm run build was forgotten before the npm publish.

Maybe a Github Action can void similar issues in the future. What do you think about it ?

New Request: Asking for pair of functions to start and stop RTSP

Thanks to @butabi, we had noticed that set_rtsp_stream function might disable RTSP functionality for a camera, which was not my intention at all. I thought that calling this function with TRUE and FALSE, should just start the stream over respective URL and finish it when desired. To keep backwards compatibility and functionality as intact on your end, can you come up with a pair of functions as start_rtsp_stream and stop_rtsp_stream?

Respective issue: fuatakgun/eufy_security#53

Issues Starting and Stopping Stream

Describe the bug
Ok let me first try and explain what I'm trying to do and my current setup. Like many of us I'm an IT person so I get most of this but I'm not a programmer by trade. I'm a Network Engineer so very familiar with Cisco, Wireshark, Fortigate, etc.

I have several Wyze cameras already setup with RSTP through FFMPEG and eventually I plan on building a DeepStack AI Facial Recognition with a Jetson Nano soon, so I would like to be able to add this to that mix. Now I bought the 1080p version of the wired camera but it's somewhat confusing as far as their 2K camera vs the 1080p. But anyway the model number is T8201.

I have everything setup like you have in your install script. Including the 2 conditional cards for viewing. I'm able to see all of the sensors and the last captured image. If I click on the still image it starts the generic Eufy Start Stream and the stream then progresses through the WebRTC plugin. So the problem comes after the 3 min stream and trying to reset the environment for another viewing. So after a fresh boot of HA, I can click the image and the stream works fine. If I then run camera.turn_off and turn_on accordingly, the stream still stays hung. I end up having to restart both the Eufy and RSTP add-on and then reloading the Eufy integration before everything resets and I'm able to view the stream again. That or restart HA

To Reproduce
Steps to reproduce the behavior:
See above

Expected behavior
Person clicks on latest still image captured and live stream starts, after so many min it goes back to the last image captured and if you want to view the stream again, just click the image

Or even better, click the image and it stays streaming until the person leaves the page. But can still go back, click the pic again, and get a live stream.

Screenshots & Logfiles
If applicable, add screenshots and logfiles to help explain your problem.

Versions:

  • Client version: <0.5.3>
  • Node version:
  • Operating system:

Additional context
Add any other context about the problem here.

Sometimes some commands fail with ERROR_COMMAND_TIMEOUT

Hi @bropat ,

Do you think, we can add a simple or exponential retrial mechanism into eufy-security-client? I have seen many warnings in docker output as below and retrial might help us to resolve this.

2021-10-12 14:09:22.993  WARN Station T8010NXXX - Result data for command not received 
{
  message: {
    sequence: 43,
    command_type: 1145,
    nested_command_type: undefined,
    channel: 1,
    data: <Buffer d1 00 00 2b 58 5a 59 48 79 04 88 00 00 00 01 00 01 00 00 00 01 00 00 00 00 00 00 00 64 30 64 61 38 35 64 35 62 61 31 38 33 66 32 37 37 63 33 64 37 65 ... 106 more bytes>,
    retries: 1,
    acknowledged: true,
    return_code: -133,
    timeout: Timeout {
      _idleTimeout: 20000,
      _idlePrev: null,
      _idleNext: null,
      _idleStart: 584022,
      _onTimeout: [Function (anonymous)],
      _timerArgs: undefined,
      _repeat: null,
      _destroyed: false,
      [Symbol(refed)]: true,
      [Symbol(kHasPrimitive)]: false,
      [Symbol(asyncId)]: 11886,
      [Symbol(triggerId)]: 112
    }
  }
}

T8124 : SoloCam S40 Support

Describe the bug
Massive battery drain on Eufy SoloCam S40

To Reproduce
Start eufy-security-ws
Utilize eufy-security integration in HASS
eufy.log

Eufy API is returning 204 errors causing the library to fail

Describe the bug
Calls seem to be randomly failing and returning 204 errors

To Reproduce
Steps to reproduce the behavior:

  1. Use code:
     const eufy: EufySecurity = new EufySecurity(config, logger);
     if (!await eufy.connect()) {
         console.log("Couldn't connect");
     }
    
     await eufy.refreshCloudData();
    
  2. View logs

Expected behavior
Calls to not fail.

Screenshots & Logfiles
If applicable, add screenshots and logfiles to help explain your problem.
Without debug logging:

> tsc -p .

2021-11-18 23:15:33.860  ERROR Status return code not 200
{
  status: 204,
  statusText: 'No Content'
}
2021-11-18 23:15:34.391  ERROR Station <REDACTED> - Status return code not 200
{
  status: 204,
  statusText: 'No Content'
}

With debug logging:

2021-11-18 23:31:17.342  DEBUG [HTTPApi.request] Request:
{
  method: 'post',
  endpoint: 'app/get_hub_list',
  baseUrl: 'https://security-app-eu.eufylife.com/v1',
  token: '<REDACTED>',
  data: undefined,
  headers: {
    app_version: 'v2.8.0_887',
    os_type: 'android',
    os_version: '30',
    phone_model: 'EUFYCLIENT',
    country: 'GB',
    language: 'en',
    openudid: '<REDACTED>',
    uid: '',
    net_type: 'wifi',
    mnc: '02',
    mcc: '262',
    sn: '<REDACTED>',
    Model_type: 'PHONE',
    timezone: 'GMT+00:00'
  }
}
2021-11-18 23:31:17.498  DEBUG [HTTPApi.updateDeviceInfo] Stations - Response:
2021-11-18 23:31:17.498  ERROR [HTTPApi.updateDeviceInfo] Status return code not 200
{
  status: 204,
  statusText: 'No Content'
}

Versions:

  • Client version: 1.2.4
  • Node version: v14.18.1
  • Operating system: OSX 10.15.7

Additional context
The calls don't always fail. For example, two calls right after each other:

2021-11-18 21:11:52.841  DEBUG [HTTPApi.request] Request:
{
  method: 'post',
  endpoint: 'app/cipher/get_ciphers',
  baseUrl: 'https://security-app-eu.eufylife.com/v1',
  token: '<REDACTED>',
  data: {
    cipher_ids: [
      16
    ],
    user_id: '<REDACTED>',
    transaction: '1637269912840'
  },
  headers: {
    app_version: 'v2.8.0_887',
    os_type: 'android',
    os_version: '30',
    phone_model: 'EUFYCLIENT',
    country: 'GB',
    language: 'en',
    openudid: '<REDACTED>',
    uid: '',
    net_type: 'wifi',
    mnc: '02',
    mcc: '262',
    sn: '<REDACTED>',
    Model_type: 'PHONE',
    timezone: 'GMT+00:00'
  }
}
2021-11-18 21:11:52.986  DEBUG [HTTPApi.getCiphers] Response:
{
  code: 0,
  msg: 'Succeed.',
  data: [
    {
      cipher_id: 16,
      user_id: '<REDACTED>',
      private_key: '-----BEGIN RSA PRIVATE KEY-----\n' +
        '<REDACTED>' +
        '-----END RSA PRIVATE KEY-----\n'
    }
  ]
}
2021-11-18 21:11:52.987  DEBUG [HTTPApi.request] Request:
{
  method: 'post',
  endpoint: 'app/cipher/get_ciphers',
  baseUrl: 'https://security-app-eu.eufylife.com/v1',
  token: '<REDACTED>',
  data: {
    cipher_ids: [
      16
    ],
    user_id: '<REDACTED>',
    transaction: '1637269912987'
  },
  headers: {
    app_version: 'v2.8.0_887',
    os_type: 'android',
    os_version: '30',
    phone_model: 'EUFYCLIENT',
    country: 'GB',
    language: 'en',
    openudid: '<REDACTED>',
    uid: '',
    net_type: 'wifi',
    mnc: '02',
    mcc: '262',
    sn: '<REDACTED>',
    Model_type: 'PHONE',
    timezone: 'GMT+00:00'
  }
}
2021-11-18 21:11:53.106  DEBUG [HTTPApi.getCiphers] Response:
2021-11-18 21:11:53.106  ERROR [HTTPApi.getCiphers] Status return code not 200
{
  status: 204,
  statusText: 'No Content'
}

Question about http api

Hey there, it seems this is the only place I can ask about API stuff for eufy security...
I'm curious if the set param call in the http API (

public async setParameters(stationSN: string, deviceSN: string, params: { paramType: number; paramValue: any; }[]): Promise<boolean> {
) can be used to set the guard mode. Does the body require all params or just the ones you want to change? I'm working with Tasker so I can't really do p20 stuff easily (but HTTP requests are easy).

Also FYI it seems that with only the REST API you can determine if a station /homebase 2 is offline.
It seems parameter 1140 is set to 0 if it is offline, and 1 if it is online. So there is no need for this p2p stuff to read simple statistics.

T8423 Flood Light Cam 2 Pro not working

Describe the bug
Live Streaming is not working for Flood Light Cam 2 pro.

To Reproduce
Steps to reproduce the behavior:
Follow the steps to install and add a Floodlight cam 2 pro as a camera. RTSP works like a camera, when you enable and disable it, you can view it in WebRTC, however, when you click on the camera, it doesn't stream or turn on for Flood Light Cam 2 pro.

Expected behavior
Please add support for T8423N

Camera Name: %s Front Door
Serial Number: %s XXXXX
Station Serial Number: %s XXXXXX
Last Camera Image URL: %s https://zhixin-security-pr.s3.us-west-2.amazonaws.com/thumb/2021/12/01/station/
Starting RTSP Stream
Stream URL: %s rtmp://p2p-vir-6.eufylife.com/hls/

Camera Name: %s Garage
Serial Number: %s T8423NXXXXXX
Station Serial Number: %s T8423XXXXXXXX
Last Camera Image URL: %s https://zhixin-security-pr.s3.us-west-2.amazonaws.com/thumb/2021/12/01/station/
Starting RTSP Stream
Unexpected error

Websocket

Hi! Excited that you've put so much work into this great library; thank you!

What would you think about some sort of two-way websocket that would allow non-JS/TS libraries to interact with this? I'm thinking of Home Assisstant, which is Python-based; rather than re-implementing everything you've done in Python, a read/write websocket could allow a Python library to interact with Eufy Security via this library.

You could even do read-only as step one.

I'm a top Home Assistant contributor and own several Eufy Security devices, so I would be happy to collaborate with you on this!

Sometimes, P2P stream cannot be started

Following on timeout discussion, opening new issue to discuss further p2p timeout.

Sometimes, when i call start_livestream to initiate p2p stream, client does not receive any livestream started event and further video data.

This is happening randomly and all cameras behave same and i checked with mobile app and cameras are accessible and streaming on demand through mobile app.

Getting all logs might be too much as it is happening randomly, do you have any advice to track this?

No Bug - More a question (and a thank you)

So,

I have recently setup some new Indoor 2K P/T cams, they work really well, and being very much a DIY-er, stumbled on this Lib, for which I am very grateful! so thank you!.

I do however, have a question around the P2P/Local interface.

I have set Homekit recording for both Home & Away, but control it via setting Station.setMotionDetection.
until Apple Introduce scheduling or the ability to control it via scenes - this library is filling a massive gap for a lot of situations for many people, again Thank you!

But....

if I have all devices and hubs serialised/stored, for which I can pass to the P2P constructor, do I need to call into the official Api each time? or does the dskkey change, so much so that I need to call into the official API before I can do P2P/Local?

I guess my main concern, is that, as this isn't an official approach, Anker could kill it off, and ultimately, break some pretty well thought out automation setups

Many Thanks

EDIT:
All device IP's are static if it makes any difference.

Station livestream is dark and doesn't use IR nightvision

Bug
Using the station livestream returns a stream which is rather dark and doesn't make use of the IR night vision

To Reproduce
Steps to reproduce the behavior:

  1. Receive videostream from
    private onStartLivestream(channel: number, metadata: StreamMetadata, videoStream: Readable, audioStream: Readable): void {
    this.emit("livestream start", this, channel, metadata, videoStream, audioStream);
    }
  2. Make snapshot with ffmpeg https://github.com/schliemann/homebridge-eufy-security-control/blob/F-Realtime_Snapshot/src/streamingDelegate.ts#L330-L374
  3. Compare darkness and nightvision with cloud livestream

Expected behavior
Station livestream makes use of IR night vision and is comparable in colour to cloud livestream.

Screenshots & Logfiles
Snapshot from station livestream:
StationLiveStream

Snapshot from eufy app
EufyApp

Video shows cloud livestream and then a very dark snapshot. The livestream uses IR night vision the stream from the station doesn't:

video-1625089409.mp4

Corrupt videoStream is received on the start_livestream event

Describe the bug
Corrupt videoStream is received on the start_livestream event (blockiness/colour artifacts).

To Reproduce

  1. git clone [email protected]:davyrolink/eufy-test-stream.git
  2. cd eufy-test-stream
  3. nano src/App/Parameters.ts (edit this file; enter your username, password and cameraDeviceId)
  4. npm install
  5. npm run start-dev (takes +/- 15sec)
  6. ffplay output/test-stream.dump (ffplay / ffmpeg must be installed)

The video stream that is captured is corrupt and shows blockiness/colour artifacts.

Expected behavior
A video stream dump without artifacts.

Screenshots & Logfiles
test-stream dump example01

Versions:

  • eufy-security-client: 0.6.0
  • Operating system: macOS
  • Device: Battery Doorbell 2K (T8210)

Additional context
The Eufy app settings for the camera "Video Quality" make a difference to the amount of corruption.
Worst case: Steaming Quality -> High, Video Encoding Format -> High

The problem is almost not visible during night time (black&white), only some small artifacts

What does StationGuardModeProperty 6 represent?

How is StationGuardModeProperty 6 set? I don't see how this can be set in the eufy app?

195431939_291616539311740_8323919827071496444_n

export const StationGuardModeProperty: PropertyMetadataNumeric = {
key: ParamType.GUARD_MODE,
name: PropertyName.StationGuardMode,
label: "Guard Mode",
readable: true,
writeable: true,
type: "number",
states: {
0: "AWAY",
1: "HOME",
2: "SCHEDULE",
3: "CUSTOM1",
4: "CUSTOM2",
5: "CUSTOM3",
6: "OFF",
47: "GEO",
63: "DISARMED",
},
}

Brief start-up

Hey there, I was wondering what are the most bare bone requirements or things to keep in mind when creating a client for eufy security?
Is it just the p2p that's really the most complex part here?

Video Codes is unknown

For one example client, video codes was coming as UNKNOWN, I have used H264, it worked but it is better to fix this from here.

  • 'metadata': {'videoCodec': 'UNKNOWN', 'videoFPS': 15, 'videoHeight': 480, 'videoWidth': 640}}
  • Model: T8200
  • hardwareVersion: P2
  • softwareVersion: 2.333
{'name': {'value': 'Doorbell', 'timestamp': 1627503608000}, 
'model': {'value': 'T8200', 'timestamp': 1627503608000}, 
'serialNumber': {'value': 'T8200NXXX', 'timestamp': 1627503608000}, 
'type': {'value': 5, 'timestamp': 1627503608000}, 
'hardwareVersion': {'value': 'P2', 'timestamp': 1627503608000}, 
'softwareVersion': {'value': '2.333', 'timestamp': 1608619568000}, 
'stationSerialNumber': {'value': 'T8200NXXX', 'timestamp': 1627503608000}, 
'pictureUrl': {'value': 'https://SOMEURL', 'timestamp': 1627496583000}, 
'watermark': {'value': 0, 'timestamp': 1615480081000}, 
'enabled': {'value': True, 'timestamp': 1615479987000},
 'motionDetected': {'value': False, 'timestamp': 0}, 
'personDetected': {'value': False, 'timestamp': 0}, 
'personName': {'value': '', 'timestamp': 0}, 
'ringing': {'value': False, 'timestamp': 0}}

Playing sound via the Microphone

Feature request:

I just wanted to see if there is a chance to integrate -if API permits- to use the builtin microphone and play some mp3 to it.

eufyLog: No devices found.

Describe the bug
No devices are found. Using a guest account for Eufy which only has access to the Doorbell.

To Reproduce
I installed the samemory/homebridge-eufy-security plugin for HomeBridge that utilises your repo to connect to Eufy accounts. However, It seems no devices are found. I have created a guest account that has access to the Eufy Battery Powered Doorbell. I tried using birkir/homebridge-plugin-eufy-security with which the Doorbell did show up in the Home app.

Expected behavior
I'm expecting the doorbell to show up in HomeBridge as an accessory and thus in the Home app as well.

Screenshots & Logfiles
Starting to advertise 'Homebridge 0BDF' using bonjour-hap backend!
[8/1/2021, 2:01:52 PM] Homebridge v1.3.4 (Homebridge) is running on port 51826.
{"name":"eufyLog","hostname":"redacted","pid":350,"level":30,"msg":"No stations found.","time":"2021-08-01T12:01:52.949Z","v":0}
{"name":"eufyLog","hostname":"redacted","pid":350,"level":30,"msg":"No devices found.","time":"2021-08-01T12:01:53.300Z","v":0}
{"name":"eufyLog","hostname":"redacted","pid":350,"level":30,"msg":"No stations found.","time":"2021-08-01T12:01:53.345Z","v":0}
�[0;37m[8/1/2021, 2:01:53 PM] �[0m�[0;36m[Homebridge UI]�[0m �[0;33mHomebridge Config UI X v4.41.2 is listening on 0.0.0.0 port 8124�[0m
{"name":"eufyLog","hostname":"redacted","pid":350,"level":30,"msg":"No devices found.","time":"2021-08-01T12:01:53.727Z","v":0}
{"name":"eufyLog","hostname":"redacted","pid":350,"level":30,"msg":"Push notification connection successfully established","time":"2021-08-01T12:02:04.399Z","v":0}
{"name":"eufyLog","hostname":"redacted","pid":350,"level":30,"msg":"Push notification connection successfully established","time":"2021-08-01T12:02:04.399Z","v":0}

Versions:

  • Client version: 0.9.1
  • Node version: v0.9.4
  • Operating system: Docker

Stream not restarting

Describe the bug

I was asked to reopen this issue here.

Ok let me first try and explain what I'm trying to do and my current setup. Like many of us I'm an IT person so I get most of this but I'm not a programmer by trade. I'm a Network Engineer so very familiar with Cisco, Wireshark, Fortigate, etc.

I have several Wyze cameras already setup with RSTP through FFMPEG and eventually I plan on building a DeepStack AI Facial Recognition with a Jetson Nano soon, so I would like to be able to add this to that mix. Now I bought the 1080p version of the wired camera but it's somewhat confusing as far as their 2K camera vs the 1080p. But anyway the model number is T8201.

I have everything setup like you have in your install script. Including the 2 conditional cards for viewing. I'm able to see all of the sensors and the last captured image. If I click on the still image it starts the generic Eufy Start Stream and the stream then progresses through the WebRTC plugin. So the problem comes after the 3 min stream and trying to reset the environment for another viewing. So after a fresh boot of HA, I can click the image and the stream works fine. If I then run camera.turn_off and turn_on accordingly, the stream still stays hung. I end up having to restart both the Eufy and RSTP add-on and then reloading the Eufy integration before everything resets and I'm able to view the stream again. That or restart HA

To Reproduce
Steps to reproduce the behavior:
See above

Expected behavior
Person clicks on latest still image captured and live stream starts, after so many min it goes back to the last image captured and if you want to view the stream again, just click the image

Or even better, click the image and it stays streaming until the person leaves the page. But can still go back, click the pic again, and get a live stream.

Screenshots & Logfiles
If applicable, add screenshots and logfiles to help explain your problem.

Versions:

Client version: <0.5.3>
Node version:
Operating system:
Additional context
Add any other context about the problem here.

Alarm triggered events

Are there currently any alarm triggered events? For example if an entry sensor is opened while in away mode.

SoloCam E40 rapid battery drain when add-on enabled

Describe the bug
The battery for the SoloCam E40 is drained in a few hours when add-on is enabled.

To Reproduce
I have a Eufy 2K Doorbell and SoloCam E40. Both seem to work fine with the add-on. However the battery of the SoloCam E40 is drained from 100% to 0% in just a few hours once the add-on is enabled. Prior to installing the add-on I had the SoloCam running fine for a few months, so am confident it's not a hardware fault. However, if I check the logs I can see the add-on repeatedly connecting and disconnecting from the SoloCam multiple times each minute. I would imagine it's this behaviour that is draining the battery.

Expected behavior
Functionality wise the add-on seems to work with the SoloCam E40, and entities are populated correctly. It seems this connecting/disconnecting behaviour could be the cause of the battery drain though?

Screenshots/logs
2021-12-02 15:20:22.278 INFO Eufy Security server listening on port 3000
2021-12-02 15:20:24.179 INFO Connected to station T8010P23211226D3 on host x.x.x.x and port 11265
2021-12-02 15:20:24.855 INFO Push notification connection closed
2021-12-02 15:20:24.989 INFO Push notification connection successfully established
2021-12-02 15:20:27.489 INFO Connected to station T8131N63212326AB on host 172.16.0.81 and port 28588
2021-12-02 15:20:30.215 INFO Push notification connection successfully established
2021-12-02 15:20:37.385 INFO Disconnected from station T8131N63212326AB
2021-12-02 15:20:46.181 INFO Connected to station T8131N63212326AB on host 172.16.0.81 and port 25130
2021-12-02 15:20:55.945 INFO Disconnected from station T8131N63212326AB
2021-12-02 15:21:05.040 INFO Connected to station T8131N63212326AB on host 172.16.0.81 and port 18840
2021-12-02 15:21:14.184 WARN Station T8010P23211226D3 - Heartbeat check failed. Connection seems lost. Try to reconnect...
2021-12-02 15:21:14.185 INFO Disconnected from station T8010P23211226D3
2021-12-02 15:21:15.032 INFO Disconnected from station T8131N63212326AB
2021-12-02 15:21:19.857 INFO Connected to station T8010P23211226D3 on host x.x.x.x and port 16090
2021-12-02 15:21:20.265 INFO Connected to station T8131N63212326AB on host 172.16.0.81 and port 17707
2021-12-02 15:21:29.924 INFO Disconnected from station T8131N63212326AB
2021-12-02 15:22:04.968 WARN Station T8131N63212326AB - Tried all hosts, no connection could be established
2021-12-02 15:22:04.968 INFO Timeout connecting to station T8131N63212326AB
2021-12-02 15:22:19.407 INFO Connected to station T8131N63212326AB on host 172.16.0.81 and port 22940
2021-12-02 15:22:29.168 INFO Disconnected from station T8131N63212326AB
2021-12-02 15:22:37.792 INFO Connected to station T8131N63212326AB on host 172.16.0.81 and port 19281
2021-12-02 15:22:47.618 INFO Disconnected from station T8131N63212326AB
2021-12-02 15:22:56.493 INFO Connected to station T8131N63212326AB on host 172.16.0.81 and port 18824
2021-12-02 15:23:06.206 INFO Disconnected from station T8131N63212326AB
2021-12-02 15:23:15.231 INFO Connected to station T8131N63212326AB on host 172.16.0.81 and port 18199
2021-12-02 15:23:25.000 INFO Disconnected from station T8131N63212326AB
2021-12-02 15:23:34.136 INFO Connected to station T8131N63212326AB on host 172.16.0.81 and port 25216
2021-12-02 15:23:43.931 INFO Disconnected from station T8131N63212326AB
2021-12-02 15:23:52.774 INFO Connected to station T8131N63212326AB on host 172.16.0.81 and port 29405
2021-12-02 15:24:02.534 INFO Disconnected from station T8131N63212326AB
2021-12-02 15:24:11.692 INFO Connected to station T8131N63212326AB on host 172.16.0.81 and port 14104
2021-12-02 15:24:21.513 INFO Disconnected from station T8131N63212326AB

(This repeats continuously. Obfuscated some public IP addresses)

**Hardware Information about Home Assistant
Home Assistant 2021.11.5 running in a VMware ESXi Virtual Machine.

**Hardware Information about Cameras

SoloCam E40
Live Streaming Protocol: N/A
Additional context
The SoloCam E40 in the logs appears to be 'T8131N63212326AB '.
My 2K doorbell and HomeBase 2 is 'T8010P23211226D3'. This works fine so can be ignored I believe.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.