New Xiaomi aqara camera/gateway

Did you install the custom firmware on the camera?

Xiaomi support won’t help with this issue. Officially you’re not allowed to use it with home-assistant as they want you to use it with their own eco-system.

Xiaomi camera in general don’t integrate so well with home-assistant, they are damn cheap, but not very open.

OT: Would you have a suggestion for which cameras integrate well with HASS (MJPEG stream)?

Pardon the OT

This one for example: GRANDSTREAM GXV-3611
But it’s bigger, less design and more expensive…

Xiaomi Dafang with custom firmware works well with HA (ffmpeg).

1 Like

I also owned some Xiaomi Cam and install the custom firmware, is the usage rtsp not very slow? Or even sometimes cannot display the live feed at all?

If ffmpeg is running on RPi, sometimes there is a problem with the live feed (after clicking on the camera tab). With more powerful device (I try NUC with Ubuntu) there is no such problem.

It’s not just a camera though it’s a Gateway also this model of camera is not listed on the custom firmware site as supported

1 Like

I have an HP Gen 8 Micro Server, could not get it fluid enough, even with that.
The preview image was kind of working, but not the live feed. If someone want to use several camera, they can basically forget about those based on rtsp.

This seems to have mjpeg rtsp. Have you tried it out?

The camera is using Kalay TUTK p2p protocol (20 char uid system), sending (encrypted?) h264 video over udp fragments. Should be possible to access the camera feed without modifying anything on the camera and keeping the same functionality.

A simple search with the android app tinyCam > network scan, will find the camera on the wifi network and its UID. Can´t connect however, tinyCam only allows to set a password, but this camera uses user and password (and possibly encryption of the h264 video feed).

Here is how to get the UID, user and password credentials for this camera:

  1. Install GitHub - rytilahti/python-miio: Python library & console tool for controlling Xiaomi smart appliances as in Getting started — python-miio documentation

  2. You need the 32 char token for the camera.
    If you don´t have it, the easiest method is to remove MiHome and install this modified apk https://cloud.mail.ru/public/791a/CbBUrrgnN/ (understand this is a modified apk from this blog ЗАПИСКИ ЛЕНИВОГО ЭНТУЗИАСТА: Модифицированный Mi Home с множеством приятных дополнений , can contain something bad, use it at your own risk) or use one of the more “traditional” methods listed here com.xiaomi-miio/docs/obtain_token.md at master · jghaanstra/com.xiaomi-miio · GitHub

  3. Run:
    miiocli device --ip 192.168.your.camera-ip --token ***32 char token here*** raw_command get_ipcprop "[ 'all' ]"

You will get something like (sensible data replaced with #):

{‘p2p_id’: ‘####################’, ‘app_type’: ‘celing’, ‘offset_x’: ‘0’, ‘offset_y’: ‘0’, ‘offset_radius’: ‘0’, ‘md_status’: 1, ‘video_state’: 1, ‘fullstop’: 0, ‘led_status’: 1, ‘ir_status’: 1, ‘mdsensitivity’: 6000000, ‘channel_id’: 0, ‘flip_state’: 0, ‘avID’: ‘############’, ‘avPass’: ‘############’, ‘id’: 1}

Fields are self explanatory.

There are some other methods like:

miiocli device --ip 192.168.your.camera-ip --token 32-char-token-here raw_command set_led 0

for turning off the led, and a few other found decompiling the aqara camera gateway plugin apk

.field public static final LUMI_CAMERA_GET_FULLSTOP:Ljava/lang/String; = “get_fullstop”

.field public static final LUMI_CAMERA_GET_PROP:Ljava/lang/String; = “get_ipcprop”

.field public static final LUMI_CAMERA_GET_SD_FORMAT:Ljava/lang/String; = “sdformat”

.field public static final LUMI_CAMERA_GET_SD_STATUS:Ljava/lang/String; = “get_sdstatus”

.field public static final LUMI_CAMERA_SET_FLIP:Ljava/lang/String; = “set_flip”

.field public static final LUMI_CAMERA_SET_FULLSTOP:Ljava/lang/String; = “set_fullstop”

.field public static final LUMI_CAMERA_SET_IR:Ljava/lang/String; = “set_ir”

.field public static final LUMI_CAMERA_SET_LED:Ljava/lang/String; = “set_led”

.field public static final LUMI_CAMERA_SET_MD:Ljava/lang/String; = “set_md”

.field public static final LUMI_CAMERA_SET_VIDEO:Ljava/lang/String; = “set_video”

4 Likes

it’s been a while since I was checking the community and I can see now there was some progress :slight_smile: @miguelangel.nubla I’ve tried the steps you mentioned, got the token, avID, avPass etc.but I guess we’re stuck on that? tinyCam doesn’t do anything even with the password entered.

is it a dead end or there’s still hope?

Anyone have ideas on getting the gateway side connected? That’s my bigger concern. I have several motion and water sensors that I would like to automate with HA but I cannot connect to this hub.

1 Like

Hi there! @miguelangel.nubla, I’m pretty sure that you’re familiar with apktool and app-modification process at all. So why don’t you decompile and compare my version with the original one to examine it for “something bad”? :wink:

Hi @vevs, welcome!
Don’t get me wrong, it is the mandatory fair warning when directing people to random modified apks on the web.
I found it 5 minutes before posting that.

By the way, I do use it, thanks for the great work.

Now that you are here i have to ask you, do you know anything about this new mihome-gateway link that we can exploit to use the data outside mihome?
The Aqara Gateway LAN communication protocol is not running for this gateway model and the usual query for sensors answers with a error:

get_device_prop  '["lumi.0","device_list"]'
Error: {'code': -5005, 'message': 'params error'}

@miguelangel.nubla

how to Run:
miiocli device --ip 192.168.your.camera-ip --token ***32 char token here*** raw_command get_ipcprop "[ 'all' ]"

i just installed python in my raspberrypi3

sorry for the question but i also tryn to get the feed of this cam

regards,

matthias

There is still hope!!

I made a program to get a RTSP server working without flashing any alternate firmware and keeping MiHome functionality.:tada:

Instructions to use it with Home Assistant are in the readme. Test reports will be appreciated.

If anyone have other xiaomi cameras please try and report, I don’t know if this will also work on them…

8 Likes

Testing tonight

I got 2 of them, will test this we :slight_smile:.
Thanks for this share

Great Work ! Works fine for me ! thank you so much ! … i have half of the way :wink:

one additional question … is it possible to grab also a MJPEG Stream out of it ?
thanks