Hacking the XiaomiFang Wifi camera

Yep, wanted to trigger on that and save locally and then send to telegram as well. I want to save locally since I hope I can use this (which I have previously posted) then https://github.com/home-assistant/home-assistant/pull/17795

Hoping it will run on hassio.

If you take a look at the motion.conf in the camera you will find a setting for save_snapshots. This makes the camera store the image locally with a timestamp in /system/sdcard/motion/stills/. You might be able to use this in some manner until issue #16004 is resolved so we can trigger on the mqtt directly.

1 Like

I don’t get it. I have it all working, mqtt broker, RTSP etc. I can get into the camera using the webinterface and via VLC. But… when I try to get the camera into my config, it won’t show. I only get an idle message… Anybody has an idea? What am I missing…

Thanks

ffmpeg in configuration.yaml?

Yes, like this:

  - platform: ffmpeg
    name: DaFang Camera
    input: rtsp://MYDAFANGIP:DAFANGPORT/unicast

I get to see the snapshot in HASS

What about your ffmpeg component?

It is in my configuation file (and loaded) but I think that has to be the problem. I will try this weekend to take it out of the configuation, reboot en get it back in and reboot again. Hope it works.

I installed hassio all over again, but still no live stream image. ffmpeg is installed and loaded. I can view the rtsp stream from the browser and see snapshots from motion.

It shows inactive on the frondend.

It has to be something in Hassio because an other camera (no dafang) has the same problem. I just don’t know that it is and how to solve the problem

Anyone else getting dafang disconnecting (mqtt) all the time in mosquitto log?

I’ve found a way to use generic ip camera instead of ffmpeg.
So it’s much faster in retrieving the picture and much better for a slow cpu (like raspberry)
Try this:

  - platform: generic
    still_image_url: https://root:PW@IP_ADDRESS/cgi-bin/currentpic.cgi
    name: cam1
    verify_ssl: false
    authentication: digest
1 Like

Great! Thanks! What video settings are you using in dafang?

I have a Xiaofang S1, the small cubic one. I use 1280x720.

Works with my dafang, with the Elias Kotlyar firmware. Quite a delay (have not timed it yet). Thank you.

It works for me only activating RTSP H264 server.
And if i turn on MQTT status server it stop working.
Any ideas ?
I would like to activate a mqtt motion sensor in HA. But it seems that the two server can’t work together.

Ok, i found that’s a common problem:

Yup. All the time.

I set up mqtt on my dafang yesterday on ha 0.81.6. I included mqtt auto discovery. Worked fine and had an image in the ha frontend, and a whole lot of switches.

Updated to 0.82 today and I now also have a dafang motion snapshot panel as well. All working good.

So, looking in the mosquitto log you dont have connecting and disconnecting all the time?

I was answering the issue of whether mqtt was affecting the camera feed, which mine doesn’t.

I have now looked at the mosquitto log and yes there are constant connections and disconnections. I guess this is because dafang firmware uses mosquitto_pub to publish to mqtt. So every time new data is published, mosquitto_pub connects and disconnects. I don’t think it is an error.

It might be by design but it pushes CPU usage on my Pi. But you might be correct, probably by design then.

How do you know it is pushing cpu up?