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
507 stars 74 forks source link

[Bug]: Device type of T81A0 Flood camera with HomeBase3 is conflicting with the type parsing #539

Closed kvj closed 1 month ago

kvj commented 2 months ago

Client version

Latest in HASS add-on

Node version

Included into HASS add-on

Operating System type

Linux

Operating system version

Latest

Describe the bug

The issue is here: Sourcecode: if (normalizedMessage.type >= 10000) {

The device ID of T81A0 is 10005 and, because of the condition above, push events are being ignored, as this line is never reached. As a consequence, no detection events and so on are available

Smarter condition (>=10100?) will fix the issue

To reproduce

  1. Buy T81A0, HomeBase3
  2. Connect one via another
  3. Walk in front of the camera
  4. See that no detection events are recorded

Screenshots & Logfiles

Sample push message:

  message: {
    id: 'BCD20A02',
    from: '348804314802',
    to: 'dZoIyTZDhCYHjGmw9Z6x8h',
    category: 'com.oceanwing.battery.cam',
    persistentId: '0:1725194801785124%0d2a775cf9fd7ecd',
    ttl: 3600,
    sent: '1725194801772',
    payload: {
      device_sn: 'T81A0...',
      payload: {
        msg_type: 18,
        event_type: 3102,
        device_sn: 'T81A0....',
        name: 'Parking Flood Camera',
        channel: 1,
        cipher: 0,
        create_time: 1725194797493,
        trigger_time: 1725194797493,
        file_path: '/zx/emmcdata/Camera01/202409/20240901144637/20240901144637.zxvideo',
        pic_url: '',
        pic_filepath: '',
        push_count: 1,
        notification_style: 1,
        storage_type: 1,
        vision: 0,
        mode: 1,
        session_id: '...',
        unique_id: '4045cc366f8931e764c75f880e809488',
        record_id: 2024090100024
      },
      station_sn: 'T8030...',
      'google.c.sender.id': '...',
      title: 'Eufy Security',
      type: '10005',
      push_time: '1725194801766',
      content: 'Someone has been spotted',
      event_time: '1725194801374'
    }
  }

and then:

Normalized push message received {
  message: {
    name: '',
    event_time: 0,
    type: 10005,
    station_sn: '',
    device_sn: '',
    email: undefined,
    person_name: undefined,
    verify_code: undefined
  }
}

Additional context

No response

PhilippEngler commented 2 months ago

Smarter condition (>=10100?) will fix the issue

or, maybe if (normalizedMessage.type in ServerPushEvent) { ?

So, the notification should only handled as server push notification if the type is one of the server push events.