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.

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.