yi-hack-Allwinner-v2 icon indicating copy to clipboard operation
yi-hack-Allwinner-v2 copied to clipboard

No MQTT motion_start message if ai_human_detection activated

Open marcospg75 opened this issue 4 years ago • 20 comments

Hello, After multiple test, I identify that if I activate ai_human_detection, the camera only send motion_stop messages. After desactivating ai_human_detection and rebooting the camera, I receive both start and stop motion messages. Best Regards

marcospg75 avatar Jan 25 '21 19:01 marcospg75

It's a know problem. Check for other issues, also in this project: https://github.com/roleoroleo/yi-hack-Allwinner

roleoroleo avatar Jan 26 '21 07:01 roleoroleo

It's a know problem. Check for other issues, also in this project: https://github.com/roleoroleo/yi-hack-Allwinner

I was jumping issue by issue but can't find the solution... can you post the right link to solve this? BR

marcospg75 avatar Jan 26 '21 09:01 marcospg75

https://github.com/roleoroleo/yi-hack-Allwinner/issues/231 https://github.com/roleoroleo/yi-hack-Allwinner/issues/89 https://github.com/roleoroleo/yi-hack-Allwinner-v2/issues/32

I think it's a bug related to yi program, because it doesn't work even without hack.

roleoroleo avatar Jan 27 '21 07:01 roleoroleo

The mqtt message after an ai_human_detection will be removed in 0.2.0. It's not possible to make it work.

roleoroleo avatar Oct 30 '21 16:10 roleoroleo

Hello, I have also find some issues with motion detection and ai human detection.

Since I have a dog, I'am receiving a lot of motion notifications from Home Assistant, I have turned on the person detection option and stopped receiving "motion_start" in hass through MQTT, after disabling person detection motion_start came back. BTW. I have spend a lot of time till I found this issue.

But I have done a little testing with human detection and I've found that my camera, when person detection is on sends following messages:

/home/yi-hack # ipc_read -n 2 -d
debug on
Clear message in queue... done.
Clear message in queue... done.
IPC message. Len: 11. Status: Success!
Parsing message
4d 4f 54 49 4f 4e 5f 53 54 4f 50 
MOTION_STOP
IPC message. Len: 18. Status: Success!
Parsing message
41 49 5f 48 55 4d 41 4e 5f 44 45 54 45 43 54 49 4f 4e 
AI_HUMAN_DETECTION
IPC message. Len: 11. Status: Success!
Parsing message
4d 4f 54 49 4f 4e 5f 53 54 4f 50 
MOTION_STOP
IPC message. Len: 18. Status: Success!
Parsing message
41 49 5f 48 55 4d 41 4e 5f 44 45 54 45 43 54 49 4f 4e 
AI_HUMAN_DETECTION
IPC message. Len: 11. Status: Success!
Parsing message
4d 4f 54 49 4f 4e 5f 53 54 4f 50 
MOTION_STOP
IPC message. Len: 18. Status: Success!
Parsing message
41 49 5f 48 55 4d 41 4e 5f 44 45 54 45 43 54 49 4f 4e 
AI_HUMAN_DETECTION
IPC message. Len: 11. Status: Success!
Parsing message
4d 4f 54 49 4f 4e 5f 53 54 4f 50 
MOTION_STOP

Those messages are looking pretty accurate, like camera my camera is sending at the start of human motion AI_HUMAN_DETECTION and MOTION_STOP at the end, when person detection is on, in ipc_read there are no timestamps, so I cannot tell how accurate it is, this behaviour is consistent with the app, because app also is sending only person detection notification.

Unfortunately I have a problem, that AI_HUMAN_DETECTION is not being send over MQTT, I'm only receiving MOTION_STOP messages.

I have tried setting the same topic for human detection and motion detection:

TOPIC_AI_HUMAN_DETECTION=motion_detection
TOPIC_MOTION=motion_detection

AI_HUMAN_DETECTION_START_MSG=human_start
AI_HUMAN_DETECTION_STOP_MSG=human_stop
MOTION_START_MSG=motion_start
MOTION_STOP_MSG=motion_stop

And following sensor in the HASS:

  - platform: mqtt
    name: "Living room human motion sensor"
    state_topic: "yicam/motion_detection"
    payload_on: "human_start"
    payload_off: "motion_stop"
    availability_topic: "yicam/status"
    payload_available: "online"
    payload_not_available: "offline"
    device_class: motion

But human_start is not being sand, I'm monitoring this in HASS MQTT settings, listening to yicam/#

I've done little digging in the code and found than in mqttv4/include/ipc.h

Human detection start command is different (longer) than that my camera is sending:

#define IPC_AI_HUMAN_DETECTION_START    "\x41\x49\x5F\x48\x55\x4D\x41\x4E\x5F\x44\x45\x54\x45\x43\x54\x49\x4F\x4E\x5F\x53\x54\x41\x52\x54" 

VS

41 49 5f 48 55 4d 41 4e 5f 44 45 54 45 43 54 49 4f 4e 

Is there any way I can investigate why human_start is not being send over MQTT?

My camera is: YI Dome X on MStar Firmware Version | 0.4.7 Base Version | 4.0.0.0F_201909251646 Model Suffix | y30

kamkilt avatar May 21 '22 11:05 kamkilt

The queue you are reading isn't the queue where yi processes send the messages. It's the queue where ipc_multiplexer writes when it detect a message in the original queue.

This is the sequence:

  • yi sends a message to ipc_dispatch
  • ipc_multiplexer reads the message from ipc_dispatch
  • ipc_multiplexer writes the message (different from the one read) to ipc_dispatch_x (where x is 1-9)
  • mqttv4 reads the message from ipc_dispatch_1

If you want to read messages from the original queue, you have to use ipc_sniff and not ipc_read.

The message 41 49 5f 48 55 4d 41 4e 5f 44 45 54 45 43 54 49 4f 4e is the word "AI_HUMAN_DETECTION" in hex form and it's not the original yi message.

roleoroleo avatar May 21 '22 14:05 roleoroleo

What is the difference between different queues?

AI_HUMAN_DETECTION message is not showing in queue 1 but it is showing on queue 2 in ipc_read. That could be reason that it is not being forwarded by mqttv4?

I will test sniffer tomorrow.

kamkilt avatar May 21 '22 15:05 kamkilt

There is no difference. Probably you can't see the message in ipc_dispatch_1 because mqttv4 reads the queue and remove the message, before you can read it.

Anyway, mqttv4 doesn't check for message "AI_HUMAN_DETECTION" and this is not correct. I could build a beta version to try.

roleoroleo avatar May 21 '22 15:05 roleoroleo

Check this interesting issue: https://github.com/roleoroleo/yi-hack-Allwinner-v2/issues/333

roleoroleo avatar May 21 '22 18:05 roleoroleo

I tried this, but same AI_HUMAN_DETECTION messages are not being send over MQTT. Please build a beta version if you can.

kamkilt avatar May 22 '22 11:05 kamkilt

I have played a little bit with ipc_sniffer and found following commands regarding motion and human detection. When person detection is on (filtered with beginning of 01 00 00 00 02 00 00 00):

01 00 00 00 02 00 00 00 f5 00 f5 00 00 00 00 00 
01 00 00 00 02 00 00 00 ed 00 ed 00 00 00 00 00 
01 00 00 00 02 00 00 00 ed 00 ed 00 00 00 00 00 
01 00 00 00 02 00 00 00 7d 00 7d 00 00 00 00 00 
01 00 00 00 02 00 00 00 ed 00 ed 00 00 00 00 00 
01 00 00 00 02 00 00 00 7d 00 7d 00 00 00 00 00 
01 00 00 00 02 00 00 00 ed 00 ed 00 00 00 00 00 
01 00 00 00 02 00 00 00 7d 00 7d 00 00 00 00 00 
01 00 00 00 02 00 00 00 f6 00 f6 00 00 00 00 00 
01 00 00 00 02 00 00 00 f5 00 f5 00 00 00 00 00 
01 00 00 00 02 00 00 00 ed 00 ed 00 00 00 00 00 

There are both messages being send: IPC_AI_HUMAN_DETECTION_START (01 00 00 00 02 00 00 00 f5 00 f5 00 00 00 00 00) IPC_AI_HUMAN_DETECTION_STOP (01 00 00 00 02 00 00 00 ed 00 ed 00 00 00 00 00)

but ipc_read shows only

ipc_read -n 2
AI_HUMAN_DETECTION
MOTION_JPG
MOTION_STOP

on MQTT without any change, no messages for AI_HUMAN_DETECTION.

I also tried following commands from yi-hack-Allwinner-v2: IPC_AI_HUMAN_DETECTION_OFF IPC_AI_HUMAN_DETECTION_ON IPC_SOUND_DETECTION_ON IPC_SOUND_DETECTION_OFF

They are working correctly and they are missing in ipc_cmd for yi-hack-MStar.

kamkilt avatar May 22 '22 13:05 kamkilt

but ipc_read shows only

You can't read other messages because ipc_multiplexer doesn't forward them. I will send a beta.

roleoroleo avatar May 23 '22 06:05 roleoroleo

mqttv4.gz ipc_multiplexer.gz

Overwrite these files. You have to kill the processes before overwriting.

This version uses only motion detection topic. It doesn't use ai human detection topic.

roleoroleo avatar May 24 '22 07:05 roleoroleo

mqttv4.gz ipc_multiplexer.gz

Overwrite these files. You have to kill the processes before overwriting.

This version uses only motion detection topic. It doesn't use ai human detection topic.

Is it for MStar?

I killed the processes, overite files in /home/yi-hack/bin/, chmod 755 mqttv4 ipc_multiplexer and they are not starting:

/home/yi-hack/bin # /home/yi-hack/bin/mqttv4
-sh: /home/yi-hack/bin/mqttv4: not found
/home/yi-hack/bin # 

/home/yi-hack/bin # /home/yi-hack/bin/ipc_multiplexer
-sh: /home/yi-hack/bin/ipc_multiplexer: not found

kamkilt avatar May 24 '22 09:05 kamkilt

Is it for MStar?

No, for Allwinner-v2. Use these: ipc_multiplexer.gz mqttv4.gz

roleoroleo avatar May 24 '22 14:05 roleoroleo

I have tested those modules for couple of days and it's working! When person detection is ON, motion_start and motion_end are being send like in official app, only when human is detected.

kamkilt avatar May 30 '22 06:05 kamkilt

I will share this solution in this thread: https://github.com/roleoroleo/yi-hack-Allwinner-v2/issues/333 and I will check if I can release it as a standard solution.

roleoroleo avatar May 30 '22 10:05 roleoroleo

New to this hack but is mqtt enabling required for recording human detection? Also, the recording in this hack is looping around after some days or deletes older once sd card fills up?

On Mon, May 30, 2022 at 6:50 AM roleo @.***> wrote:

I will share this solution in this thread: #333 https://github.com/roleoroleo/yi-hack-Allwinner-v2/issues/333 and I will check if I can release it as a standard solution.

— Reply to this email directly, view it on GitHub https://github.com/roleoroleo/yi-hack-Allwinner-v2/issues/75#issuecomment-1141005790, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA7IJS4KRA3PHSB5TBVGJTDVMSMPJANCNFSM4WSH6KOA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

gl2007 avatar May 30 '22 14:05 gl2007

New to this hack but is mqtt enabling required for recording human detection?

Only if you want to receive the event with your mqtt server. If you use the app, it's not required.

Also, the recording in this hack is looping around after some days or deletes older once sd card fills up?

By default it fills up the sd card. The hack allows you to delete the old mp4 files setting the minimum free space.

roleoroleo avatar May 31 '22 08:05 roleoroleo

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Dec 09 '22 03:12 stale[bot]