Hacking the XiaomiFang Wifi camera

I got this error message in my error log.
Your configuration contains extra keys that the platform does not support.
Please remove [icon].
Configuration source: MQTT (topic: ‘homeassistant/binary_sensor/Dafang/motion/config’).
Offending data: {“name”: “Dafang motion sensor”, “unique_id”: “”, “device”: “”, “icon”: “mdi:run”, “state_topic”: “myhome/Dafang/motion”, “device_class”: “”, “platform”: “mqtt”)

Any ideas how to fix this? Where do I find the MQTT configuration. It’s not in config.yaml

Pretty sure this is dealt with earlier in the thread.

I also got a Xiaomi S1 that could successfully hack with https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks , I could as you see the still image in HA, but the RTSP does not show up.

Some info of my environment:

Xiaomi S1 (T20 processor) hacked by https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks
Raspberry Pi3 (Raspbian Stretch)
Installed ffmpeg (sudo apt-get install ffmpeg)
Included ffmpeg: in configuration
Included stream: in configuration

In the camera, using:

rtsp-h264:
VLC - Works
HA still - Works
HA RTSP stream: DO NOT WORK

rtsp-mjpeg:
VLC - Do not work
HA - Do not work
HA RTSP stream - Do nor work

In Camera configuration, I tryed the following (one each time), (As posted here):

  - platform: generic
    name: xiaofang1
    username: root
    password: ismart12
    authentication: basic
    still_image_url: https://192.168.1.71/cgi-bin/currentpic.cgi
    stream_source: rtsp://192.168.1.71:8554/unicast
    verify_ssl: false
    scan_interval: 5


  - platform: ffmpeg
    name: xiaofang1
    username: root
    password: ismart12
    input: -rtsp_transport tcp -i rtsp://192.168.1.71:8554/unicast
    verify_ssl: false

      - platform: ffmpeg
        name: xiaofang1
        input: -rtsp_transport tcp -i rtsp://192.168.1.71:8554/unicast

It seems that some had success using ffmpeg, but not me. It would be nice if someone could shed some more light into this, since I already tryed so many things. Am I missing something?

for the ffmpeg, try changing the name to something other than the one used for generic (at least if you have them both defined at the same time).

Also, my ffmpeg config doesn’t have the username/password/verify bits - and works. Dont think this is the problem though.

What format do you have the video stream set to?

Also as you, VBR. Pretty default settings. Noticed your bitrate 900. Quality decreased a lot using 900, but I tryed anyway, unsig ffmpeg config. As before, it does not work, even the still image, using RTSP mjpeg server. Setting the camera to RTSP H264, I get the still image, updating each 15 or 20s, but clicking in the image the stream does not show up.

Also tested this:

  - platform: ffmpeg
    name: xiaofang1
    input: -rtsp_transport tcp -i rtsp://root:[email protected]:8554/unicast

Do you have anything different than me? Other hardware (not Pi3) or a different configuration? If it works for you it is weird…

for the ffmpeg, try changing the name to something other than the one used for generic (at least if you have them both defined at the same time).

Do you mean “xiaofang1” name? I don’t I understood what you mean, sorry.

Yes - try this - I dont think you should be defining two cameras with one ID (and I suspect this is the issue)

- platform: ffmpeg
    name: xiaofang1f

I’m running direct via virtenv on Ubuntu.

cameras.yaml
    - platform: ffmpeg
      name: DaFang
      input: -rtsp_transport tcp -i rtsp://dafang1:8554/unicast

- platform: generic
  name: Camera
  still_image_url: https://dafang1/cgi-bin/currentpic.cgi
#  stream_source: rtsp://dafang1:8554/unicast
  verify_ssl: false
  username: root
  password:  ismart12
  authentication: basic

and stream: in configuration.yaml

In the lovelace gui I have a picture-entity card:

entity: camera.dafang
show_name: false
show_state: false
type: picture-entity

It shows the static image (usually), and then a stream.

There is an issue with streaming on some systems that causes the main HA system to lock up (0.92.2 locks up? - #12 by walaj) , but that isn’t your issue.

I will probably increase the 900bps rate now I have a better internet uplink - but it was also to save my wifi network :wink:

I got it working. Its weird, because platafform generic (in your case entity camera.camera) is not used in lovelace, but it is necessary to get it working.

The still image updates each 10s. When clicking in the image and it pops up, updates about 2 fps. It’s not a smooth stream, but it can be related to my poor hardware (Raspberry Pi3). How is yours?

I believe this will be useful for others with the same problem. Thank you for your help!

Now I can’t get the stream in VLC and TinyCam (RTSP mjpeg server). Do you know something that can be done about it? That is important because it is the best way to watch when out of home, and the stream is pretty smooth.

And yes, I am using 0.92.2. Maybe I should update, since 0.93.1 is already there, but I don’t know if something is fixed in the new version about the lock up. Maybe will let running that way and see if I will be also hit by the issue.
Thanks.

I also got it working by updating Hassio to the latest version

My config as below

camera:
- platform: ffmpeg
  name: garden
  input: rtsp://192.168.0.193:8554/unicast

Updated to 0.93.1.
Now I got it working under RTSP H264 Server, with ONLY the config below:

  - platform: generic
    name: xiaofang1
    username: root
    password: ismart12
    authentication: basic
    still_image_url: https://192.168.1.71/cgi-bin/currentpic.cgi
    stream_source: rtsp://192.168.1.71:8554/unicast
    verify_ssl: false
    scan_interval: 5

And the stream is full 25 fps, as it is setted in my camera config. With this setup it can be also used with VLC. Great!

1 Like

For those that used the Xiaomi-Dafang-Hacks,
here is a just published instructions how to integrate it with HA, including controls.

FFmpeg will probably be slow on a RPI.

I would presume the generic/rtsp is doing all the video decoding in the browser, rather than recoding via ffmpeg etc.

Re the crash - if I bring up a stream, and view it, the main hass binary will lock up soon after. I dont think this is fixed.

It didn’t crash for me yet, at least.

cool. mine does :slight_smile:

How long does it take to crash after streaming? Can it be related to other processes or it only happens when streaming?

there is a bug somewhere that means a process never returns, so HA sits waiting for ever…

I see. I also have shell command. Anyway, there must be some fatal combination that I were fortunate to do not have. It should be solved soon.

I’m not using shell, but it still locks up

I don’t think there is anything new there?

Anyone figured out how to pan/tilt the camera via HA?

Via mqtt messages which are automatically added to HA as covers.

2 Likes