After a bit of trial and error with the dafang firmware I have these cameras working reliably in home assistant.
I dont recommend using the MQTT available with this firmware as it is implemented in an odd way that causes a huge volume of connections and disconnections in your MQTT broker, and in my case it was causing noticeably increased CPU usage and temperatures on my tinkerboard (and possibly MQTT broker crashes as well).
My video settings are as follows in order to remove artefacts and improve the reliability of the stream:
My audio settings are as follows to ensure that audio actually works:
Because I disabled MQTT I needed another way of enabling and disabling night mode, so I added the following commands to the action.cgi file on the microSD card:
EDIT: the latest versions of the dafang firmware now have this function built in, so you dont need to add your own custom commands. The rest functions are night_mode_on, night_mode_off and night_mode_status. I’m leaving the old instructions here in case anyone needs them.
nightvision-enable)
/system/sdcard/bin/setconf -k n -v 1
ir_led on
ir_cut off
;;
nightvision-disable)
/system/sdcard/bin/setconf -k n -v 0
ir_led off
ir_cut on
;;
You can edit this more easily via SSH by logging on to your cam using putty or similar, then using the command: vi /system/sdcard/www/cgi-bin/action.cgi
Press i to enter insert mode. Once you are done hit ESC and enter :wq to write your changes.
I can then add the following REST commands to home assistant and trigger night mode on and off (note that ismart12 is the default password for this firmware):
rest_command:
dafang_garden_nightvision_enable:
url: "https://root:ismart12@IPADDRESS/cgi-bin/action.cgi?cmd=nightvision-enable"
verify_ssl: false
And the config for streaming the camera itself:
camera:
- platform: generic
name: Garden
username: root
password: ismart12
authentication: basic
still_image_url: https://IPADDRESS/cgi-bin/currentpic.cgi
stream_source: rtsp://IDADDRESS:8554/unicast
verify_ssl: false
scan_interval: 5