I was looking for a simple and cheap Wifi camera that would work with Home Assistant and doesn’t rely solely on cloud recording since that can get expensive very quickly. In my search, I came across the Xiaomi Xiaofang camera. Although this camera is ‘cloud only’ by default, @samtap on GitHub has created FangHacks, which is a set of scripts that can be installed on the Xiaofang to enable RTSP, along with a bunch of other features. It will also show you how to add this into Home Assistant. This post will go through the steps involved in installing these modifications.
Here’s what you will need:
- Xiaomi Xiaofang camera – NOTE: This camera is likely the China version. The cloud recording function probably won’t work anywhere outside of China. If you are only planning on recording the video locally like I am, then that shouldn’t really matter.
- MicroSD Card | Amazon – NOTE: I initially had a 2GB SD card, and I couldn’t not get anything to work. I switch to a 16GB card and it worked. The 2GB card worked everywhere else, but not here. I’m wondering if the Xiaofang only reads SDHC cards(usually cards that are 4gb or more). If you run into issues where it seems like the camera isn’t reading the card, try another card.
- Optional Camera Mount – This mount can be used outside.
- Windows computer – This can probably be done with other OS’es, but these steps are all what I did on a Windows computer.
- Win32 Win Disk Imager – Go ahead and install this.
- Home Assistant – Optional
- Ivideon – Optional – This is the software that I use to record from my cameras. You can store locally forever, and they will also store on the cloud for a day for free ( The paid plans will store it longer ).
NOTE: While I was putting together this writeup, the RTSP feed on the camera appears to be hanging every few days. The web interface stays up, and I can just go to http://CamIP/cgi-bin/action?cmd=reboot to reboot it. I haven’t automated this yet, but I think I might use Home Assistant to do that. I’m not sure if this is a problem that will happen on all cameras or just this one that I have.
Here are the steps:
- Downgrade the Firmware
By default, this camera uses the latest Chinese version of their firmware. However, this version prevents the Fang Hacks scripts from working. So this step is for downgrading to a lower version that is also in English.- Download the firmware from HERE
- Copy that file to your empty microSD card. It should be the only file on the SD Card:
- Unplug the camera and put the SD Card in there.
- While using the pin that came with the camera to push the SETUP button on the bottom of the camera, plug the camera in. Continue holding the reset button for 10 seconds. This causes the camera to go into its ‘firmware update mode’ and will copy that bin file to its internal memory.
- After a few minutes, the camera will make a noise, so you will know it is on the new firmware.
- Setup the device on Wifi
- Open the MiHome app, and follow the steps there to setup the WiFi on the camera.
- In the last step, it probably won’t find the camera since the camera will not work with the Chinese servers outside of China. That’s OK. It should have an IP address on it and it should be connected to the network now.
- Login to your router to find the IP address of the unit. If your router shows you the MAC addresses of the connected devices, you can use that to find it in the list on your router. The MAC is on a sticker on the camera’s back.
- If you don’t know how to find it on your router, you can download and run AngryIP Scanner. Run it and have it scan your network and find the IP address associated with that MAC address.
- Load the scripts onto the SD Card.
- Put the SD Card back into your computer and delete the firmware file from the SD Card.
- Download the Fang Hacks image. It’s the latest zip file from HERE. Unzip the file to anywhere on your hard drive.
- Open Win32 Disk Imager.
- Click the Browse button, and point it to the file that you unzipped earlier.
- Select the Drive Letter for the SD Card.
- Click the Write button. This should take about a minute. The SD Card should look like below:
- Run the scripts.
- Power on the camera ( Don’t put the SD Card in yet ).
- Wait for the camera to connect to WiFi and initialize. If you wait about a minute, you should be fine.
- Put the SD Card in the camera. After around 10 seconds, you should hear a ‘ding’ sound. That means the scripts are loaded.
- Go to the following address in your browser, replacing camIP with the IP of the camera: http://camIP/cgi-bin/status
- If you get the Fang Hacks page, that’s a good sign.
- Click the Apply button to activate the hacks.
- DO NOT CHECK THE ‘DISABLE CLOUD APPLICATION’. If you want to disable the cloud applications, make sure you go to ‘Network’ and setup your WiFi settings appropriately.
- As long as the SD card is in the camera, the hacks will now be applied across reboots.
- Test your camera.
- You can test your camera using apps such as TinyCam or VLC or iVideon. Just use rtsp://camIP:554/unicast as the address.
- Optional – View your camera in Home Assistant
- Use the following code in your Home Assistant .yaml file to see the camera in Home Assistant:
ffmpeg: camera: - platform: ffmpeg name: Garage Cam input: rtsp://192.168.45.83:554/unicast
- HASS will then grab an image from the camera every 10 seconds and show it on the home page.
- Use the following code in your Home Assistant .yaml file to see the camera in Home Assistant:
I hope this is able to help someone out. I had a lot of trouble getting a lot of this information with the firmware and downgrading, so I was thinking there might be others that would like this info in one place. If you have any questions or comments, feel free to post them below. I usually reply fairly quickly.
I also have mine setup with my Garage Door Controller so that the Telegram notifications for it will send a picture of the garage when the garage is left open for a while. I will probably post how to do that soon.
Thank you so much! This was so helpful. And very clear instruction!
You’re welcome. Glad I could help.
I’m trying to downgrade my firmware but I don’t hear any sounds. What format does the microSD card have to be in?
FAT32 I believe. I know that when I started, I was using a 2gb as card and it basically couldn’t read it. I’m not really sure why. You may want to try a different card if you can.
After hack can I use Mihome apk also?
Can I save motion video to the NAS?
I’m not too sure about the motion sending to a NAS. I don’t think that will work.
And for the APK, if it worked before the hack, it will work afterwards. If it didn’t work before, it still won’t work.
After hack how to use Xiaofang SD card as Ftp storage?
Hi,
ive made the through the instruktions.
rtsp server cannot connect with vlc.
fanghack works, but for example the network button writes: unsupported command network.
I’m not sure why that would happen. You may want to post on the fang hacks GitHub page.
Tried already 2 sdcards (FAT32) without success. Folks what brand/size was your sdcard for successful firmware downgrade?
Any idea how many days the look back or recorded videos captured?
If you are recording on the SD card then it’s probably solely dependent on how much space is on there.
Hello, is this steps applied for fanghack 2.0 ?
I just need to view from ivideon for free cloud service (10second notif), no pc server.
After istall ivideon android app, I need to add camera, but no xiaomi xiaofang cam, any guidance ?
I could be wrong, but I’m pretty sure the Ivideon server is required.
Help needed …
After I “Run the scripts” I get ….
“404 Not Found
The requested URL /cgi-bin/status was not found on this server. ”
All good – eaxctly as instructed/predicted to here…
Run the scripts.
Power on the camera ( Don’t put the SD Card in yet ).
Wait for the camera to connect to WiFi and initialize. If you wait about a minute, you should be fine.
Put the SD Card in the camera. After around 10 seconds, you should hear a ‘ding’ sound. That means the scripts are loaded.
Go to the following address in your browser, replacing camIP with the IP of the camera: http://camIP/cgi-bin/status ….
Then I get ….
404 Not Found
The requested URL /cgi-bin/status was not found on this server.
I’m not sure why that would happen. Try a different card. You may also want to try posting on the Fang Hacks GitHub.
I’m inserting my camera IP address as …. http://192.168.0.10/cgi-bin/status
Thanks Simit.
Tried new card 3 times. Same result.
I did the Downgrade the Firmware and all seemed to work OK. I got the “camera will make a noise, so you will know it is on the new firmware.” Anyway of checking? I dont know what current firmware is on the camera…. Any way of checking (I cant check via the app because I can only get to the stage where the camera registers on my WiFi as 192.168.0.10 and this matches the MAC on the back of the camera.)
All help appreciated.
I don’t think there was any way of checking the firmware.
I have xiaofang and xiaomi Yi Home 720p. Does it work on both? If not, is there any hack info to make the yi works the same as this xiaofang hack ?
I don’t know. I don’t have that camera. But a quick Google search shows that it is possible:
https://www.google.com/search?client=firefox-b-1&ei=kHigWrSkDIHWzwLpx7PYBw&q=yi+camera+rtsp&oq=yi+camera+rtsp&gs_l=psy-ab.3..0j0i30k1j0i5i30k1l2j0i8i30k1l3.38316.38316.0.38560.1.1.0.0.0.0.84.84.1.1.0….0…1c.1.64.psy-ab..0.1.82….0.sg956VMo9XU
How do I setup my hacked xiaofang with Ivideon? There is a list of cameras , but xiaofang is not on the list. Thank you!!
Use the URL below. IP_Address is the IP of the camera.
rtsp://IP_Address/unicast
Thank you so much! My camera wasn’t even working before following your instructions!
Thanks for the tip on Ivideon… Been using these Xiaomi w/ Fang cam’s for 10 month with TinyCamPro and Ivideon seems like a much better option to manage cameras and using my NAS storage and servers to store footage.
In regard to NOTE: While I was putting together this writeup, the RTSP feed on the camera appears to be hanging every few days. The web interface stays up, and I can just go to http://<em>CamIP</em>/cgi-bin/action?cmd=reboot to reboot it. I haven’t automated this yet, but I think I might use Home Assistant to do that. I’m not sure if this is a problem that will happen on all cameras or just this one that I have.
^^
I experience the same thing, have you automated the restarts in some fashion? Did you end up using HA to do such or another method? Thanks!
No, I haven’t. I’ve been meaning to post on the HA forum to see if there is a way to detect when a camera image goes down.
Thanks for the quick reply; aside from xiaofang — is there another cheap IP camera you’ve come across in the past year that you like for night/day use?
The only other cameras I own are an amcrest pan tilt and the doorbell camera(I wrote about it recently). They both work well with Ivideon and HA.
Check out this pull…hopefully it gets implemented
https://github.com/samtap/fang-hacks/pull/338
very similar to rtsp service check hack detailed on (the overheat mod is also a commit over on fanghacks
a neat fork of FH w what seems a committed dev
https://github.com/openipcamera/openipc-firmware
After the hacks. Where is the video will be saved if the sd card is already use with the hacked firmware.
I have the same doubt.
Thanks Simit for your work. I have questions about after hacking. Should I leave the SD card containing fang.hack files in the camera at all time? Will the camera lose the hacked functions after reboot? Thanks for answering.
You can take it out, but they will be gone if it reboots. It’s best to just get a cheap card dedicated to it.
Hi
I have Defang and have the hack installed. RTSP feed and even http feed is very very slow. It is just like photo slide show. I reduced the resolution to minimum but no difference. Is this the case for Xiofang too? Asking the question as I am wondering to buy one. I use Ivideon and Blue Iris (demo)
I have 6 – 360 panoramic cheap bulb cameras and they woork great and response time way way better. I did not need any hacks for those (they are not IP cameras but you could find RTSP feed see
https://ipcamtalk.com/threads/panoramic-light-bulb-camera-view-from-pc-or-blue-iris.27602/#post-272614
Is this camera farther away from your router than the others? Try moving it closer to see if that helps.
No it is not. I have other cheaper camera’s far away. This camera is <5m with no walls in between
As per above procedures, from inside of the house(router), camera work perfect(TinyCam).
How can I see it from outside with same app. Set up is?
Thanks.
You would need to forward ports on your router. But that would be risky since that would mean other people might be able to access the feed.
Thank you! This was perfect
hey how did you foward ports can you help me here ?
I wouldn’t recommend exposing this to the public internet. But forwarding ports would depend on the router you are using.
Hi,
Stuck at the step 1; need help.
Followed instructions to flash provided firmware. Cam seems not getting the firmware from the SD card… no activity… LED blinking alternate yellow-blue and thats it!
Did you try another sd card?
After use the downgrade firmware the sdcard dont work on Mihome?
my camera does not recognize the sdcard.
Download the Fang Hacks image. It’s the latest zip file from HERE. Unzip the file to anywhere on your hard drive.
The file is corrupted
Applying fang hacks scripts…Source file not found: ‘/media/mmcblk0p1/bootstrap/sdcard’Source file not found: ‘/media/mmcblk0p1/bootstrap/rc.local’Source file not found: ‘/media/mmcblk0p1/bootstrap/rcS’Source file not found: ‘/media/mmcblk0p1/bootstrap/fang_hacks.sh’Source file not found: ‘/media/mmcblk0p1/bootstrap/fang_hacks.cfg’
Help ME !
Very cool. Thanks for that. I used your guide in my article about cameras in Home Assistant https://smarthome.university/camera-for-home-assistant/
I made step by step video for those of us with SSH skills.
RTSP issue https://www.youtube.com/watch?v=FidOYAZqO-I
Step by Step hack with Heat issue fix https://www.youtube.com/watch?v=FidOYAZqO-I
You should avoid using the mihome app it’s pretty shady. Try my generator config app I made and it works in a browser no app required.
Is this tutorial valid with the newer xiaofang with t20 chipset and latest firmware?
thank you
i can’t connect to the http://camip/cgi-bin/status. i followed the steps and i think i what successfully hacked because i heard the sound you are reffering.
Hi, it’s a bit off-topic, but I’m out of ideas. Have a Hualai Xiaofang 1080p that won’t pair with the mihome app. Anyone had a similar problem? where can I found alternative firmware? can anyone help, please…. @Simit?