Hacking the XiaomiFang Wifi camera

edited
The main settings that you need would be (these are examples):

netcam_url rtsp://192.168.0.33:8554/unicast (IP of the Dafang)
stream_port 8081(1 port per camera, so next cam would 8082 for example)
stream_maxrate 5 this is the max frame rate for the stream (the recording would be at full frame rate)
stream_localhost off this is to ensure you can also access the stream on a different machine than the one where motion is running.

The other options you can change to suit your needs (e.g. record on motion detection or not, whether you want text / timestamp etc to be displayed on the video, where you’ll save the recordings,…)
Probably best to check this page for more info on the config options.

Hi @thundergreen


Check the content of the firmware_mod\config\mqtt.dist file for more info

Sorry…my dumb fault. I don’t have dafang… But I’ll buy some right now …absolutely great with mqtt.thanks a lot!

Yea… everything is configured that way… Could there be a problem with me having a ssl certificate?

I started motion via “sudo motion start” and then tried to open “http://raspberryip:8081/” and it’s says ERR_CONNECTION_REFUSED.

if you get a connection refused it’s either before your stream is limited to localhost, so make sure you have stream_localhost off.
Another way to check is to log on the server that runs motion, open a web browser then see if you can access http://localhost:8080 and if you can access http://IP-Address:8080
If both fail, make sure you’ve restricted access to registered users (see here) at least for setup. You can always lock down later as you wish

Yea both are not working still “ERR_CONNECTION_REFUSED”.

So I have to set a passowrd for webcontrol_authentication? I have done that and it’s still not working… I am still thinking it’s not working cause off HTTPS?

By default motion is not using https… So yes try without https…

So the thing is my HA is using https by default, so i can use it secure when i am not at home, so how could I do it without https?

Hi Wibias,

Just invited you to discord for a chat, would be easier.
In the meantime, https from HA has nothing to do with motion
For now you need to forget HA while trying to set motion up.
I’m logged on discord now if you’re available.

@lolouk44

Hi I have order a Dafang camera its in the way.
When I read the install it says:
The microSD card you have to format in FAT
I have a 8GB sdcard I can’t format in FAT but in FAT32 should it work?
Thanks

Fat 32 is fine yes

1 Like

Hi

Can you help with mqtt config file in SD storage and configuration in HA ,

and problem with camera:

  • platform: ffmpeg
    name: Cam
    input: -rtsp_transport tcp -i rtsp://192.168.x.x:8554/unicast
    if using motion in the middle, your config should look like this:

  • platform: mjpeg
    mjpeg_url: http://192.168.x.x:808x
    name: Cam

my ip is 10.0.0.90

from webpage working OK .

First I would suggest you try and use the MJPEG option on the camera itself if you’re going to integrate directly in HA.
This will be easier for first implementation.
You will also need to ensure you’ve installed ffmpeg on your HA server for this to work.
Make sure you stop the H264 stream first, as per the message on your screenshot.

Houy HA config will look like this:

platform: ffmpeg
name: Cam
input: -rtsp_transport tcp -i rtsp://10.0.0.90:8554/unicast

(I take it 10.0.0.90 is the IP of your camera, not your HA server)

For your MQTT settings, make sure you’ve correctly populated the mqtt.dist file on on the SD card and renamed it into mqtt (no extension). This might be your issue here since MQTT Control comes up in red.

first thanks for quick answer :wink:

  1. need to install ffmpeg .ok i will do it
    2.ip for camera 10.0.0.90 ip for HA 10.0.0.201
    3.i rename the mqtt.dist to mqtt but iam not sure what i put inside the file and the HA config for that

do you have small example file ?

Thanks
Emil

Inside the mqtt file you need to put the details of your mqtt broker. If you don’t have any yet, you can use your HA’s own broker, or you can sign up for a free account on www.cloudmqtt.com

The mqtt file already has example data:

USER=mqtt-user
PASS=mqtt-password
HOST=mqtt-host
PORT=1883

Just replace with your own credentials / details

yep excellent i have mqtt broker i will insert broker details .

Working :slight_smile: after ffmpeg installation

i will try to config MQTT later at home .

Thanks

1 Like

is there an updated firmware for the Xaiofang that incorporates the MQTT functions?

Not as far as I know

I know this is a bit off-topic, but I hope this will help some people: As for people having issues getting the custom firmware to work, I have had the same problem. If you screw things up it is extremely annoying to debug this since you don’t have access to any log files if you need to find what you did wrong (also a lot of documentation is in Chinese).

What worked for me was creating a fat16 partition of 100mb (as some one suggested in this thread, thank you so much) on my fake Samsung sd-card I got with the camera (AliExpress). I used gparted for this. In the beginning I actually thought it was my SD card but I got it working anyway using this method. Please keep in mind that even with this SD card of shady quality flashing took less than a minute and not 5 (or even 10) minutes as is written in some guide.

For the reset button, hold it 10 seconds in advance and 10 seconds after plugging in (just to be sure, it will work when you press it for a shorter period of time).

1 Like