Hacking the XiaomiFang Wifi camera

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

How much ffmpeg loads CPU with this configuration (for Raspberry Pi 3B)?

I have no idea, my HA / FFMPEG doesn’t run on a Pi but on a dedicated Proliant server.

Using the Xiaomi Dafangs built in motion detection works great now. No more need for an extra motion processing instance.

So you are using Xiaomi Dafang Orginal Firmware then? How do you get the livestream of Xiaomi on your HA then?

No, the modded firmware now has built in motion detection capability.

Do you mind elaborating on how to use this with Home Assistant? I have MQTT going for control and status, but I can’t see anything related to motion detection (apart from the circle on the image feature through the web GUI)

Guys is there any help i can get to get the firmware added to the Camera
I did add the firmware and it was wokring but then the Sd card stoped to work ann i dont see the camera woking any more just a yellow light and it is not getting connected to my router.
Is there any thing that i can do to fix it
I tried the Chat and Wiki as well but there i no much activity there .

Thanks a lot for your help

So does tracking work with that update or does it just recognize motion?

It will just recognize motion for now, but tracking is being worked on.

Can you help me how to install dafang on home assistant?
i’m a newbie of HA
Thanks a lot

Sorry typing from mobile so limited now. Check my earlier posts, I’ve provided everything you need.

I followed…i added these lines to my configuration, but nothing…

#Dafang
camera:
  - platform: ffmpeg
    name: Cam
    input: -rtsp_transport tcp -i rtsp://192.168.1.xx:8554/unicast
    
#Dafang2-mjpeg
- platform: mjpeg
  mjpeg_url: http://192.168.1.xx:8554
  name: Cam2

Is possible to use motion detection too?
Thanks

Have you installed ffmpeg on your system? Won’t work otherwise…

I tried to install ffmpeg but i cannot…

pi@hassbian:~ $ sudo echo "deb http://ftp.debian.org/debian jessie-backports main" >> /etc/apt/sources.list
-bash: /etc/apt/sources.list: Permission denied

Followed all these steps

https://community.home-assistant.io/t/permission-denied-error-after-trying-to-dowload-ffmpeg-component/20080

Edit the file /etc/apt/sources.list with root right and add this line:

deb http://ftp.debian.org/debian jessie-backports main

This will do the same.

The MQTT implementation was working for me a few weeks ago as you outlined above but ever since an update to the mod firmware a few weeks ago the payloads/commands no longer seem to be working. The status for the switches is updating if I change the LEDs etc from the dafang web ui but none of the commands work any more, that includes the left/right and up/down commands.

So I know my broker settings are correct because the status updates are working but again, the commands no longer work.

I think the same is happening for me with regards the MQTT payload.

- platform: mqtt
  name: "LivingMain"
  command_topic: "cmnd/sonoff8/power"
  state_topic: "stat/sonoff8/POWER"
  qos: 1
  payload_on: "ON"
  payload_off: "OFF"

- platform: mqtt
  name: "Dafang Living Room Left Right"
  command_topic: "cam/dafang/set"
  payload_off: "help"
  payload_on: "help"
  optimistic: false

/system/sdcard/config/mqtt

USER=homeassistant
PASS=**********
HOST=192.168.0.22
PORT=1883

TOPIC=cam/dafang

So the LivingMain light comes on/off so I know my embedded MQTT server is working however when I press the defang switch left or right nothing happens??

Using a iPhone app to subscribe to cam/dafand/# I can see some thing happening but the camera never moves.

Any one got any bright ideas because I am lost?

could you please share your configuration for motion detection?

someone can share video with rtsp quality of dafang camera with hack ?

Since support was merged a couple of days ago,
one just has to enable auto discovery in Home Assistant:

To enable mqtt with auto discovery in Home Assistant add in your configuration.yaml:

mqtt:
  discovery: true
  discovery_prefix: homeassistant

Restart your Home Assistant.

On Dafang Camera:

copy /system/sdcard/config/mqtt.dist to /system/sdcard/config/mqtt.conf
and set your LOCATION and DEVICE_NAME
and uncomment AUTODISCOVERY_PREFIX (only then the autoconfig will be published)

For mqtt motion detection alerts:

copy /system/sdcard/config/motion.dist to /system/sdcard/config/motion.conf
publish_mqtt_message=true
and if you want snapshots
save_snapshot=true

restart the camera and make sure mqtt-status, mqtt-control and motion services are running correctly. If evening works, it could look like this (if put in one group):

To get support for motion snapshots via mqtt you will either have to checkout home assistant/dev or wait for my pr to be pulled into the next release.

Update: Autodiscovery for mqtt snapshots is now available in HA 0.67

1 Like