eufy-security-client 3.7.2-dev.1 → 3.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dont-care.js ADDED
@@ -0,0 +1,101 @@
1
+ const WebSocket = require('ws');
2
+ const fs = require('fs');
3
+
4
+ const WS_URL = 'ws://192.168.50.9:3000';
5
+
6
+ const ws = new WebSocket(WS_URL);
7
+ let id = 0;
8
+ let videoChunks = [];
9
+ let outputPath = '';
10
+
11
+ const send = (cmd, params) => ws.send(JSON.stringify({ messageId: ++id, command: cmd, ...params }));
12
+ const formatDate = (d) => d.toISOString().slice(0, 10).replaceAll('-', '');
13
+
14
+ console.log('Connecting to', WS_URL);
15
+
16
+ ws.on('open', () => {
17
+ send('set_api_schema', { schemaVersion: 21 });
18
+ send('start_listening');
19
+ });
20
+
21
+ ws.on('message', (data) => {
22
+ const msg = JSON.parse(data);
23
+
24
+ const stations = msg.result?.state?.stations;
25
+ if (stations?.length) {
26
+ console.log('Stations:', stations.join(', '));
27
+ const today = new Date(), tomorrow = new Date(today);
28
+ today.setDate(today.getDate() -1);
29
+ tomorrow.setDate(today.getDate() + 1);
30
+ stations.forEach(sn => {
31
+ if (sn === "T8030T2324021302") {
32
+ // if (sn === "T813452025312177") {
33
+ send('station.database_query_local', {
34
+ serialNumber: sn, serialNumbers: [],
35
+ startDate: formatDate(today), endDate: formatDate(tomorrow)
36
+ });
37
+
38
+ send('station.database_query_local', {
39
+ serialNumber: sn, serialNumbers: [sn],
40
+ startDate: formatDate(today), endDate: formatDate(tomorrow)
41
+ });
42
+ // send('station.get_commands', {
43
+ // serialNumber: sn
44
+ // });
45
+ }
46
+ }
47
+ );
48
+ }
49
+
50
+ const evt = msg.event?.event;
51
+
52
+ console.log(msg)
53
+
54
+ // if (evt === 'database count by date' && msg.event.data?.length) {
55
+ if (msg.messageId === 3) {
56
+ console.log("msg yess");
57
+ //console.log(msg.event.data)
58
+ //const r = msg.event.data[0];
59
+ //console.log(r)
60
+ //outputPath = './' + r.storage_path.split('/').pop().replace('.zxvideo', '.raw');
61
+ //console.log(`Found ${msg.event.data.length} events, downloading: ${r.storage_path}`);
62
+
63
+ //send('station.database_query_latest_info', { serialNumber: "T8030T2324021302" });
64
+ //station.database_query_latest_info
65
+ // send('device.start_download', { serialNumber: r.device_sn, path: r.storage_path, cipherId: r.cipher_id });
66
+ }
67
+
68
+ // if (evt === 'database query latest' && msg.event.data?.length) {
69
+ // console.log(msg.event.data);
70
+ // const r = msg.event.data[1];
71
+ // if (r.crop_local_path) {
72
+ // console.log("aaa");
73
+ // outputPath = './' + r.crop_local_path.split('/').pop().replace('.zxvideo', '.raw');
74
+ // console.log(outputPath);
75
+ // }
76
+ // }
77
+
78
+
79
+ //
80
+ // if (evt === 'download started') console.log('Download started...');
81
+ //
82
+ // if (evt === 'download video data' && msg.event.buffer?.data) {
83
+ // videoChunks.push(Buffer.from(msg.event.buffer.data));
84
+ // if (videoChunks.length % 100 === 0) process.stdout.write(` ${videoChunks.length} chunks\r`);
85
+ // }
86
+ //
87
+ // if (evt === 'download finished') {
88
+ // const buffer = Buffer.concat(videoChunks);
89
+ // fs.writeFileSync(outputPath, buffer);
90
+ // const mp4Path = outputPath.replace('.raw', '.mp4');
91
+ // console.log(`\nSaved ${buffer.length} bytes to ${outputPath}`);
92
+ // console.log(`Convert to mp4: ffmpeg -f h264 -i ${outputPath} -c:v copy -movflags +faststart ${mp4Path}`);
93
+ // ws.close();
94
+ // process.exit(0);
95
+ // }
96
+
97
+ if (msg.success === false) { console.log('ERROR:', msg.error); ws.close(); process.exit(1); }
98
+ });
99
+
100
+ ws.on('error', (e) => { console.error('Error:', e.message); process.exit(1); });
101
+ setTimeout(() => { console.log('Timeout'); ws.close(); process.exit(1); }, 120000);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eufy-security-client",
3
- "version": "3.7.2-dev.1",
3
+ "version": "3.7.2",
4
4
  "description": "Client to communicate with Eufy-Security devices",
5
5
  "author": {
6
6
  "name": "bropat",
@@ -45,7 +45,7 @@
45
45
  "dependencies": {
46
46
  "@cospired/i18n-iso-languages": "^4.2.0",
47
47
  "crypto-js": "^4.2.0",
48
- "date-and-time": "^4.3.0",
48
+ "date-and-time": "^4.2.0",
49
49
  "fs-extra": "^11.3.3",
50
50
  "got": "^14.4.2",
51
51
  "i18n-iso-countries": "^7.12.0",
@@ -56,7 +56,7 @@
56
56
  "node-schedule": "^2.1.1",
57
57
  "p-throttle": "^8.1.0",
58
58
  "protobufjs": "^8.0.0",
59
- "qs": "^6.15.0",
59
+ "qs": "^6.14.2",
60
60
  "sweet-collections": "^1.1.0",
61
61
  "tiny-typed-emitter": "^2.1.0",
62
62
  "typescript-logging": "^2.2.0",