UP  |  HOME

Wyze and Dafang Cameras

Table of Contents

Dafang Hacks Firmware

WiFi Config

Just edit config/wpa_supplicant.conf on the micro SD card.

A simple motion recording script

I think I had a simple systemd unit to run this, but I don't know where it is now.

Listing 1: motion_record.sh
#!/bin/bash
TIMER=0
FFMPEG_PID=0
# connect to mosquitto server and listen for motion ON/OFF
mosquitto_sub -h 192.168.1.2 -u attic -P password -t attic/dafang/motion |
while true; do
    read -r -t 1 LINE;
    if [ "$LINE" = "ON" ]; then
        if [ "$TIMER" -le 0 ]; then
            ffmpeg -i rtsp://dafang.local:8554/unicast -acodec copy -vcodec copy "attic-$(date +%Y-%m-%d\ %H:%M:%S).mp4" & < /dev/null
            FFMPEG_PID=$!
            echo "STARTED RECORDING: attic-$(date +%Y-%m-%d\ %H:%M:%S).mp4"
        fi
        TIMER=30
    fi
    if [ "$TIMER" -gt 0 ]; then
        let "TIMER--"
    fi
    if [[ "$TIMER" -eq 0 ]] && [[ "$FFMPEG_PID" -ne 0 ]]; then
        echo "STOPPED RECORDING"
        kill -2 $FFMPEG_PID;
        FFMPEG_PID=0
    fi
done

Pi Home Assistant

See Ragna logs for device setup.