Hacking the XiaomiFang Wifi camera

I read that the custom firmware supports onvif now. Anyway can tell me how can we use it in HA?

Where did you read that?

somewhere on github. I also can see an option on the webui to start onvif server.

“Onvif has been added in a05a6e7 thanks to sian in #1296.”

I have installated the motion eye addon. But when I try do add my dafang cam e get the ssl certificate error. The certificate is expired. Is there any command to generate a new certificate file?
Thank you

Hi all, I noticed that fw got a big update. New entities have been created but something is confusing:

For example for RSTP there are several switch and some doesn’t work.

I’m the only one that noticed it?

I updated the elias kotlyar firmware a couple of weeks ago, and it hasn’t restarted since! holiday project.

I had a similar problem. RTSP was fine but had an issue with mqtt.
I changed camera’s name in mqtt.conf from “Front Door” to “front” and it’s worked.
So the spaces in name are completely intolerable.

But I don’t see all features, only 4 of them.

How can I get all of them (like night mode switch on/off for example)?

found!


You could turn off the camera but you wouldn’t be able to restart it programmatically.
A better option is to just stop the rtsp server via the home assistant MQTT switch because if the rtsp server is down the video feeds and motion detection are stopped as well.
The only thing still accessing the camera then will be jpegSnap which afaik is only used for the pseudo live image (really just a javascript calling that jpegSnap api) on the web ui.

You can extend your https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks/blob/0b6a19ae4ed25dfeb63d975883fc1974144ff2f7/firmware_mod/scripts/mqtt-control.sh to execute a script on the camera to your likings.

You should be able to reboot the camera using the url:

curl -k "https://user:password@cameraip/cgi-bin/action.cgi?cmd=reboot”

I did this using a command line switch in configuration.yaml

1 Like

What did you set your swapfile size to?

The default in the swap config file is 256mb. But I’ve read on the link below that that’s not enough still. And to try 384mb. For some reason a swapfile size of 512mb causes issues as well.

Ive updated to the big firmware update from Dec 2020. The UI and setup is an improvement from a usability perspective. However, still seem to be experiencing the camera crashing and unresponsive after a couple of hours. Or a lot of motion events.

Are other people experiencing the crashing issues? Is it worth disabling MQTT still? And if MQTT is off, how do you get trigger an automation? I’d be using the MQTT motion detected sensor to run automations inside Homeassistant.

Hi, today I integrated my Dafang via MQTT using autodiscovery capability. Nevertheless I prefer write the MQTT configuration in a file to have more control on HA entities configuration.
Can someone post here the full MQTT Dafang YAML configuration for defining all the Dafang entities?
Thank you

I have two dafangs, with the a reasonably recent version of dafang-hacks. I’ve not touched the swapfile settings so it will have what ever is default.

I’m using MQTT autodiscovery, one with and one without MQTT triggered motion detection - neither have crashed or become unresponsive.

What do you have the video settings at?

With a little tweaking, I’ve not had any stability issues and the camera has been running 24hours a day for the last 6 days. Video and audio settings from the DaFang camera are below. I also increased the swap size to 384M and have MQTT auto-discovery sensors setup for most things on the camera, including a binary_sensor which is trigger on a motion detection event direct from the camera.

@walaj How are you triggering motion capture if you don’t have an MQTT sensor set for this?

1 Like

I wonder if the video compression using high res image to small bit rate is causing some of your memory issues?

I’m running mine as H264, 960x540, 3000Kbps, 25fps, and VBR.

I only have motion capture running on one - the other camera never got fully integrated.

1 Like

I just installed the defang hack on my wyze v2 and it seems to be working great so far, the only issue so far is that I can’t get audio to work in Home Assistant. Audio stream works via VLC, but when I put it in HA the volume icon is crossed out. This is my config

platform: generic
stream_source: rtsp://admin:[email protected]:8554/unicast
still_image_url: https://x.x.x.x/cgi-bin/currentpic.cgi
username: !secret defang_username
password: !secret defang_password
authentication: basic
verify_ssl: false
name: Garage Defang

image

I’ve also tried ffmpeg in HA, as well as changing the audio from mp3 to PCMU. Nothing seems to work. Any ideas on how to get audio in the RTSP stream into HA?