Archive for April 17th, 2019

Xiaomi Dafang Hacks: Timelapse Images

With the Wyze and Xiamoi Dafang cameras running the Xiaomi-Dafang Hacks firmware and software, I tried the timelapse functions on the yard camera.

The config/timelapse.conf file:

# Interval between snaps, in seconds
# Duration of the script should run, in minutes, set to 0 for unlimited
# Save dir config
# Enable compression

The images, named along the lines of 13-04-2019_191810_001.jpg, appear in the DCIM/timelapse directory, tucked into daily directories with names like 2019-04-13, a mismatch obviously in need of tweaking. There’s also a time_lapse directory which seems like cruft from an earlier revision; you can configure the target directory in scripts/

Start the script manually or from a crontab entry, wait until it’s done, then transfer the images to somewhere more convenient with a Bash one-liner:

find /system/sdcard/DCIM/timelapse/ -name \*jpg -exec curl -s -n -T {} \; 

The -s silences all curl output; omit it until you’re sure the lashup works as you expect. I always forget the backslash before the semicolon terminating the -exec command.

The -n pulls the userID and password from the ~/.netrc file you previously set up for manual ftp sessions:

login ftp-user-id
password secret-password

The IP address corresponds to my ancient NAS drive; your mileage may vary.

From my desktop box, mount the NAS drive:

sudo mount -t cifs -o "credentials=/root/.nas-id,vers=1.0,uid=ed" "//nasty/Timelapse" /mnt/part

The drive’s credentials aren’t particularly secret, but tucking them into /root/.nas-id means you could automount the drive with no hassle. The NAS drive requires the oldest possible CIFS version, of course.

Then view the pix:

Xiaomi Dafang - 15-04-2019_13.26.18
Xiaomi Dafang – 15-04-2019_13.26.18

You could set up the camera as an NFS share, but having all the cameras deposit their pix in a common location seems more convenient, particularly after I get around to automating the image transfer. Regrettably, the NAS drive doesn’t support subdirectories.