eufy-security-snapshotter
v1.0.1
Published
Modular Node.js SDK for capturing snapshots from Eufy Pan/Tilt cameras (including custom support for eufyCam C31) with offline local ONNX weather classification.
Maintainers
Readme
Eufy Security Snapshotter with Local Weather Classification
A modular Node.js SDK and utility for capturing snapshots from Eufy Pan/Tilt cameras (including fully custom support for the eufyCam C31 / T817L), rotating the camera to specific preset angles, and running fully offline local AI image inference using ONNX to classify weather conditions.
Key Features
- Object-Oriented SDK Design: Exports a reusable, developer-friendly class that integrates seamlessly into larger applications.
- Persistent Sessions: Automatically saves authentication tokens locally to minimize 2FA prompt frequency.
- Preset Position Control: Moves Pan/Tilt cameras to specific preset indices before taking the capture.
- Efficient Frame Capturing: Establishes local P2P livestreaming, captures a single high-quality frame with FFmpeg, and instantly shuts down the stream. Falling back to Eufy Cloud image URLs if livestreaming is unsupported.
- Local ONNX Weather Inference: Runs a lightweight 5.9MB pre-trained 14-class ResNet50 model offline in under 650ms.
- Re-normalized Prediction Filtering: Restricts predictions to 6 core atmospheric weather classes (
cloudy,fogsmog,rain,shine(sunny),rainbow, andsnow), re-normalizing their relative confidence to 100% and discarding misleading classifications like lens condensation or dew.
SDK API Reference
Installation
npm install eufy-security-snapshotterUsage Example
const EufySecuritySnapshotter = require('eufy-security-snapshotter');
async function main() {
// 1. Instantiate the class with your credentials and config
const snapshotter = new EufySecuritySnapshotter({
username: "[email protected]",
password: "your-password",
deviceSerial: "T817LT002605061C", // Camera serial number
presetIndex: 3, // Preset to rotate to (optional)
snapshotsDir: "./custom_snapshots",// Where to save files (optional)
tokenPath: "./persistent.json" // Session cache (optional)
});
try {
// 2. Initialize and connect to the Eufy Cloud & Local P2P
console.log("Connecting...");
await snapshotter.initialize();
// 3. Option A: Capture a standard raw image snapshot (returns Buffer)
const imageBuffer = await snapshotter.takeSnapshot();
console.log(`Captured image buffer of size: ${imageBuffer.length} bytes`);
// 4. Option B: Capture snapshot AND run local weather analysis (returns Buffer + Metadata Object)
const { imageBuffer, metadata } = await snapshotter.takeSnapshotWithWeather();
console.log(`Captured image buffer of size: ${imageBuffer.length} bytes`);
console.log(`Detected Weather: ${metadata.weather.label} (${(metadata.weather.confidence * 100).toFixed(2)}%)`);
} catch (error) {
console.error("Snapshot failed:", error.message);
} finally {
// 5. Cleanly close the session
await snapshotter.close();
}
}
main();Demo Utility
This repository includes a standalone demo utility (demo.js) allowing you to trigger on-demand snapshots and verify your setup.
1. Prerequisites
- Node.js: Latest LTS version.
- FFmpeg: Must be installed on your system path.
- Amazon Linux / RHEL / Fedora:
sudo dnf install ffmpeg-free -y - Ubuntu / Debian:
sudo apt update && sudo apt install ffmpeg -y
- Amazon Linux / RHEL / Fedora:
2. Setup Configuration
Clone the repository and install dependencies:
git clone https://github.com/elijahparker/eufy-security-snapshotter.git cd eufy-security-snapshotter npm installCopy the environment template:
cp .env.example .envOpen
.envand fill in your details:EUFY_USERNAME="[email protected]" EUFY_PASSWORD="your-eufy-account-password" DEVICE_SERIAL="T817LT002605061C" PRESET_INDEX=3
3. Run the Demo
To capture a snapshot and run the ONNX weather classification (saves a .jpg and .json in ./snapshots):
node demo.jsTo run a raw snapshot only without loading the ONNX model or running classification:
node demo.js --only-snapshot4. View Saved Weather Logs
A companion .json file is saved with each capture preserving the complete list of normalized class scores:
# Print the results of the newest snapshot weather analysis
cat $(ls -t snapshots/*.json | head -n 1)Example JSON metadata output:
{
"timestamp": "2026-06-18T14:01:49.389Z",
"camera": {
"name": "Garage",
"serial": "T817LT002605061C",
"model": "T817L"
},
"weather": {
"label": "cloudy",
"confidence": 0.6898,
"scores": {
"cloudy": 0.6898,
"rain": 0.2014,
"fogsmog": 0.0542,
"shine": 0.0315,
"snow": 0.0182,
"rainbow": 0.0049
}
}
}License
MIT License.
