Hacking the XiaomiFang Wifi camera

Hi All

I recently acquired a few Xiaomi products and thanks to the community, I have been successful in integrating “most” of them into HA.

This post is about one such integration - XiaomiFang Wifi camera.

All I really did was follow the instructions from this project to hack it. The hack works great (even on the latest firmware 3.0.4.9) and opens up lots of features (ssh, telnet, sftp, rtsp etc) There is also an option of completely disabling cloud communications making the camera local only.

Once I managed to do that and verify the rtsp stream (http://camera-ip/unicast), then it was simply a case of adding a camera component into HA.

My configuration looks like this.
> camera:
> - platform: ffmpeg
> input: -rtsp_transport tcp -i rtsp://camera-ip/unicast
> name: Garage Cam

There are also ways to use the camera with Synology Surveillance station.. I haven’t tested this yet.

Good luck hacking :slight_smile:

16 Likes

I hope i will get mine soon, but its already on the way :slight_smile: How many fps do you get over HA and is the nightvision working right? I’m a bit excited about it :slight_smile:

That sounds great! Can you pull an .jpg using this xiaomi fang camera when automation with doorbell rings?

How is your stream? Mine is choppy with the standard settings you listed.

Also, what ffmpeg did you install?

1 Like

Stream’s alright, not great, but not choppy either. It’s smooth on the phone and laptop.
Don’t remember the ffmpeg version. Will check and let you know.

I’d installed libav-tools by sudo apt-get install libav-tools

Now with ffmpeg -version I get the following:

avconv version 11.9-6:11.9-1~deb8u1+rpi1, Copyright (c) 2000-2017 the Libav developers
built on Apr 26 2017 06:57:28 with gcc 4.9.2 (Raspbian 4.9.2-10)
avconv 11.9-6:11.9-1~deb8u1+rpi1
libavutil 54. 3. 0 / 54. 3. 0
libavcodec 56. 1. 0 / 56. 1. 0
libavformat 56. 1. 0 / 56. 1. 0
libavdevice 55. 0. 0 / 55. 0. 0
libavfilter 5. 0. 0 / 5. 0. 0
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 0. 0 / 3. 0. 0

Yes, you can with the following script.

#!/bin/sh
export DATETIME=`date +%Y%m%d%H%M%S`
ffmpeg -loglevel fatal -i rtsp://10.1.1.110/unicast -vframes 1 -r 1 /home/pi/snapshots/$DATETIME.jpg

Adapted from domoticz forum post

1 Like

hm strange. When I use your script I get this:

pi@hassbian:/home/homeassistant/.homeassistant/config $ bash snapshot.sh
'jpgle to find a suitable output format for '/home/pi/snapshots/20170529163929

There’s a better way now, thanks to @touliloup

1 Like

Just stumbled onto this post. I would be interested to hear comments on how the cameras are working for you so far, but my real question is: Is there a way to turn the cameras off somehow? I would rather not be streaming or recording when we are home.

Are you saying with the hack you can not only view the camera stream on HA but also listen to any sounds from the live stream? As the camera has a built in mic and speaker, so I suppose you could also talk from HA and get the output from the camera’s speaker?

1 Like

The camera is working fine. I have a couple around the house with the hack and no issues whatsoever.

I haven’t really tried to turn them off. Will try different settings and let you know.

Haven’t tried that either. My primary intention was for the camera not to connect to china. The hack satisfies that.

1 Like

@Mukund That would be great if you can try to see if there is a way to turn it off or stop streaming … I think that they are cute cameras and I could see the use of stacking 2 of them together in some areas. Keep us posted if you can.

I did all. It works well on VLC (rtsp://IP/unicast), also well in Tinycam pro.

but is not working in HASS, no matter the commands I use.

I think have a problem with ffmpeg component, not sure how to solve

what about this – Rtsp stream support for camera

I run a windows 7 VM on my QNAP and then use contacam to convert the rtsp feed into a jpg which works perfectly in HA. I do that for 2 camera that only have rtsp as I found rtsp in HA was god damn slow. I use the VM as my backup server, so now I have found another use for it :slight_smile:

Only issue with this and the hack is the nightvision is just rubbish, blocky/grainy black and white. Is this normal ?

Cheers
Mark

hi i got my cam today and followed the tutorial. Well … I cannot see anything in vlc… no connection could be etablished … do i have to deactivate the cloud? the hack is running on the cam

ok works… but home assistant (hassio) freezes and breaks down when trying to watch the stream

Are you using the RTSP or MJPEG stream?
I have been using the RTSP and its working OK on my hass.io install… but am running hass.io on a VM on xeon server, so has much more cpu etc for ffmpeg to process the 1080p stream from the xiaofang.
BTW the out of box ffmpeg provided in hass.io image is working fine, but I noticed that the rtsp server on the camera is not very stable and often quits :frowning:

I’m going to try the MJEPG version of the xiaofang hack linked above.