Skip to content

feat: add CMD_DATABASE_QUERY_BY_DATE (10006) support for HB3#768

Merged
max246 merged 1 commit intobropat:developfrom
temp-droid:feature/cmd-10006-database-query-by-date
Feb 3, 2026
Merged

feat: add CMD_DATABASE_QUERY_BY_DATE (10006) support for HB3#768
max246 merged 1 commit intobropat:developfrom
temp-droid:feature/cmd-10006-database-query-by-date

Conversation

@temp-droid
Copy link
Copy Markdown
Contributor

Description

Adds support for CMD_DATABASE_QUERY_BY_DATE (command 10006) to query video recordings by date range. This enables retrieving the recording history with metadata like storage paths, thumbnails, and timestamps.

Testing

Tested on HomeBase 3 (T8030) - Firmware 3.7.3.6.

station.on("image download", (station: Station, file: string, image: Buffer) => this.onStationImageDownload(station, file, image));
station.on("database query latest", (station: Station, returnCode: DatabaseReturnCode, data: Array<DatabaseQueryLatestInfo>) => this.onStationDatabaseQueryLatest(station, returnCode, data));
station.on("database query local", (station: Station, returnCode: DatabaseReturnCode, data: Array<DatabaseQueryLocal>) => this.onStationDatabaseQueryLocal(station, returnCode, data));
station.on("database query by date", (station: Station, returnCode: DatabaseReturnCode, data: Array<DatabaseQueryByDate>) => this.onStationDatabaseQueryByDate(station, returnCode, data));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to add documentation in eufysecurity.ts.html

@temp-droid
Copy link
Copy Markdown
Contributor Author

Hi @max246, I can't find eufysecurity.ts.html. Did you mean a different file?

@max246
Copy link
Copy Markdown
Collaborator

max246 commented Jan 24, 2026

you

my bad, was looking locally, and that was my coverage jest test , will approve and you can merge it

@max246
Copy link
Copy Markdown
Collaborator

max246 commented Feb 1, 2026

just nee to rebase I think, but you can merge it when I approve it, otherwise I am happy to merge it in

@nhols
Copy link
Copy Markdown

nhols commented Feb 2, 2026

Tried this on my HB3 (T8030) via eufy-security-ws but I keep getting empty array as response. I've tried lots of different start/end date inputs

Firmware: 3.7.3.6

station.database_query_by_date

{
  "type": "event",
  "event": {
    "source": "station",
    "event": "database query by date",
    "serialNumber": "***",
    "returnCode": 0,
    "data": []
  }
}

same for station.database_count_by_date

{
  "type": "event",
  "event": {
    "source": "station",
    "event": "database count by date",
    "serialNumber": "***",
    "returnCode": 0,
    "data": []
  }
}

and driver.get_video_events

[2026-02-02T22:56:42.072Z] Query driver.get_video_events payload: {"startTimestampMs":1769468202072,"endTimestampMs":1770073002072,"maxResults":5}
[2026-02-02T22:56:42.241Z] Driver Video Events: {
  "type": "result",
  "success": true,
  "messageId": "7",
  "result": {
    "events": []
  }
}

@temp-droid
Copy link
Copy Markdown
Contributor Author

temp-droid commented Feb 3, 2026

@nhols Did you try with a single day? Eufy is quite picky about what we can ask.

I managed to get events with this code for example (replace the WS URL with your service)

node -e " 
  const WS = require('ws');
  const ws = new WS('ws://<TODO>:3000');
  ws.on('error', e => console.log('Error:', e.message));
  const send = (c, p) => { console.log('>>> ' + c); ws.send(JSON.stringify({ messageId: Date.now(), command: c, ...p })); };
  const fmt = d => d.toISOString().slice(0,10).replace(/-/g,'');

  ws.on('open', () => {
    console.log('Connected!');
    send('set_api_schema', {schemaVersion:21});
    send('start_listening');
  });

  ws.on('message', d => {
    const m = JSON.parse(d);
    console.log('<<< type:', m.type, 'event:', m.event?.event || m.result?.state ? 'state' : '');

    if (m.result?.state?.stations) {
      console.log('Stations:', m.result.state.stations);
      const t = new Date(), n = new Date(t); n.setDate(n.getDate()+1);
      m.result.state.stations.forEach(s => send('station.database_query_by_date', {
        serialNumber:s, serialNumbers:[], startDate:fmt(t), endDate:fmt(n), eventType:0, detectionType:0, storageType:0
      }));
    }

    if (m.event?.event === 'database query by date') {
      console.log('=== RESULTS ===');
      console.log('Events:', m.event.data?.length || 0);
      if (m.event.data?.[0]) console.log(JSON.stringify(m.event.data[0], null, 2));
      ws.close(); process.exit();
    }
  });

  setTimeout(() => { console.log('Timeout'); process.exit(1); }, 30000);
  "
Connected!
>>> set_api_schema
>>> start_listening
<<< type: version event:
<<< type: result event:
<<< type: result event: state
Stations: [ 'xxx' ]
>>> station.database_query_by_date
<<< type: result event:
<<< type: event event: state
=== RESULTS ===
Events: 15
{
  "device_sn": "xxx",
  "device_type": 48,
  "start_time": "2026-02-03T16:32:52.000Z",
  "end_time": "2026-02-03T16:33:02.000Z",
  "storage_path": "/zx/emmcdata/Camera01/202602/xxx/xxx.zxvideo",
  "thumb_path": "/zx/emmcdata/Camera01/202602/xxx/snapshort.jpg",
  "cipher_id": 0,
  "folder_size": 1898932,
  "frame_num": 139,
  "trigger_type": 4,
  "video_type": 2,
  "record_id": xxx,
  "station_sn": "xxx",
  "storage_type": 1,
  "storage_cloud": 0
}

@nhols
Copy link
Copy Markdown

nhols commented Feb 3, 2026

@temp-droid this worked - thank you!

@temp-droid temp-droid force-pushed the feature/cmd-10006-database-query-by-date branch from aa12a0f to 1e683f2 Compare February 3, 2026 18:14
@temp-droid temp-droid force-pushed the feature/cmd-10006-database-query-by-date branch from 1e683f2 to aab1402 Compare February 3, 2026 18:14
@temp-droid
Copy link
Copy Markdown
Contributor Author

@max246 I believe I do not have permission to merge, you will need to do it yourself if you are OK with the conflict resolution

@max246 max246 merged commit 49a81af into bropat:develop Feb 3, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants