roleoroleo / yi-hack-Allwinner-v2

Custom firmware for Yi 1080p camera based on Allwinner platform
MIT License
866 stars 98 forks source link

MQTT sound detection events #713

Closed mcanteri closed 1 week ago

mcanteri commented 1 year ago

Hello, I cannot see any sound detection event coming from any of the two cameras (y21ga) that I have: I am playing with the level but no differences between the 30 or 90 dB levels. I know the noise can be revealed because I am using FFmpeg noise in HA and it is working (sound detected, so the microphone is working) but the MQTT topic "yicam/sound_detection" and message "sound_detected" never show up. My current configuration is:

mqtt:
  binary_sensor:
    - state_topic: "yicam/status"
      name: "Camera Status"
      payload_on: "online"
      payload_off: "offline"
      qos: 1
      unique_id: camera_status
    - state_topic: "yicam/motion_detection"
      name: "Motion Detection"
      payload_on: "motion_start"
      payload_off: "motion_stop"
      qos: 1
      off_delay: 10
      unique_id: motion_detection
    - state_topic: "yicam/sound_detection"
      name: "Sound Detection"
      payload_on: "sound_detected"
      qos: 1
      off_delay: 10
      unique_id: sound_detection

And is this since the beginning of the hack version (0.2 or so) :) Any help/guidance appreciated.

roleoroleo commented 1 year ago

Sorry for the delay in the response. I will try to find the time to check the problem, I have the same cam. Which fw version? 9 or 12?

mcanteri commented 1 year ago

Fw versión 9.0.19.02_202007141512 Thank you 🤗🙏

mcanteri commented 1 year ago

Hello @roleoroleo, did you have the opportunity to check the issue? Thank you, best! M.

roleoroleo commented 1 year ago

I test it just with h52ga and it works. I need to test with my y21ga but I have to unbrick it before...

roleoroleo commented 1 year ago

I completed the test with my y21ga. The sound is correctly detected and the mqtt receives the message: immagine

But I updated to fw 12. I don't know if this could be the difference. If you enable the cloud, do you receive notifications?

mcanteri commented 12 months ago

I am trying to reconnect the camera to the app but it fails the last part of the procedure, where it should connect with the app. I tried many times to reset as the voice suggests in different situations but without luck, do you know any way to reset again the cam to the normal use with the app? It seems to work and boot, just it is not possible to connect to the app. I tried with a new one (just bought) and it worked flawlessly. Any help appreciated.

roleoroleo commented 11 months ago

Did you switch off the cloud option? immagine

If the cloud option is ok, try to boot without the sd card.

mcanteri commented 11 months ago

Yes, I did it. Tried to restore the backup, the soft way various times but nothing happened. Now I've connected the rs232 and I am on the console but the cam seems to not "remember" the configuration and keeps going the same way as before. Maybe the internal memory is corrupted. Do you have any suggestions or willing to read the logs? Maybe you can understand better, for sure :-)

roleoroleo commented 11 months ago

The soft way must work. You don't need to connect the rs232 with this model. Try to create the mtdblock4 image with the option "hacked" (mtdblock3 and mtdblock2 are not necessary if the cam is able to start the wifi connection procedure).

Now I've connected the rs232 and I am on the console but the cam seems to not "remember" the configuration and keeps going the same way as before.

What do you mean with this sentence?

mcanteri commented 11 months ago

I've tried both the soft way, building the one file backup_y21ga or all three with root and home. Using the cable, I followed the procedure but after the reset, it kept rebooting in a loop. I have attached the log from Putty, maybe you can understand why it keeps rebooting. Thank you in advance, best! M. putty.log

mcanteri commented 11 months ago

I found an error and fixed, now it boot and I can reach the root command line, seems a step forward, but the part where the cam acquire the IP address is missing. This log file contains all the procedure I followed, maybe you can see better other errors that can be fixed. Thank you for any help :) Best! putty.log

mcanteri commented 11 months ago

@roleoroleo any suggestion?

mcanteri commented 9 months ago

I've setup another camera, y291ga, and has the same behaviour of the older y21ga, I am thinking that maybe the noise sensor that I have, that works perfectly, is interfering?


    input: rtsp://192.168.1.X:8554/livingroom_audio
    name: Livingroom Camera Noise
    initial_state: false
    #peak: -40
    peak: -35
    duration: 2
    reset: 10
    extra_arguments: -nostats -rtsp_transport tcp -analyzeduration 15```
roleoroleo commented 9 months ago

I've setup another camera, y291ga, and has the same behaviour of the older y21ga, I am thinking that maybe the noise sensor that I have, that works perfectly, is interfering?

I don't know. Did you try to sniff IPC commands between processes? Maybe the problem is mqtt.

ipc_sniff.gz

Check if the sniffer shows this message:

define IPC_SOUND_DETECTION "\x04\x00\x00\x00\x02\x00\x00\x00\x04\x60\x04\x60\x00\x00\x00\x00"

mcanteri commented 9 months ago

When I run the ipc_sniffer it exits without writing anything. There is a process that need to be running? I saw in another thread that ipc_multiplex is used, but when it boots in my cam there is no such process. When I run it I can see timely messages and a motion start and stop messages but even the messages changes (from no error to resource unavailable) and I don't know if it is a problem or it is regular, you can check in the following lines:

IPC message. Len: 16. Status: No error information!
Parsing message.
01 00 00 00 04 00 00 00 22 40 01 00 00 00 00 00
IPC message. Len: 16. Status: No error information!
Parsing message.
01 00 00 00 02 00 00 00 7d 00 7d 00 00 00 00 00
Sending MOTION_START to queue #1
Sending MOTION_START to queue #2
Sending MOTION_START to queue #3
Sending MOTION_START to queue #4
Sending MOTION_START to queue #5
Sending MOTION_START to queue #6
Sending MOTION_START to queue #7
Sending MOTION_START to queue #8
Sending MOTION_START to queue #9
IPC message. Len: 20. Status: Resource temporarily unavailable!
Parsing message.
01 00 00 00 10 00 00 00 e8 00 e8 00 00 00 00 00 7c 01 00 00
IPC message. Len: 16. Status: Resource temporarily unavailable!
Parsing message.
01 00 00 00 04 00 00 00 22 40 01 00 00 00 00 00
IPC message. Len: 31. Status: Resource temporarily unavailable!
Parsing message.
02 00 00 00 04 00 00 00 07 10 01 00 0f 00 00 00 2f 74 6d 70 2f 6d 6f 74 69 6f 6e 2e 6a 70 67

..... cut messages

Sending MOTION_STOP to queue #1
Sending MOTION_STOP to queue #2
Sending MOTION_STOP to queue #3
Sending MOTION_STOP to queue #4
Sending MOTION_STOP to queue #5
Sending MOTION_STOP to queue #6
Sending MOTION_STOP to queue #7
Sending MOTION_STOP to queue #8
Sending MOTION_STOP to queue #9
IPC message. Len: 20. Status: Resource temporarily unavailable!
Parsing message.
01 00 00 00 10 00 00 00 e8 00 e8 00 00 00 00 00 4f 01 00 00
IPC message. Len: 16. Status: Resource temporarily unavailable!

Another piece of information that I get is that the board of my cam says it is a Y29GA_MB_V2.1 (2020/04/07) model, I don't know if it is relevant, but is the first cam I hacked at the beginning, maybe I need to use another firmware (y29ga)? Thank you! M,

roleoroleo commented 9 months ago

The label in the board is not relevant. The Yi fw version is important.

ipc_multiplex was removed some version ago: now it's a library. ipc_sniff must be executed with the name of the queue as an argument: ./ipc_sniff /ipc_dispatch_3 And yes, ignore the errors, check only if the hex sequence appear when a sound should be detected: 04 00 00 00 02 00 00 00 04 60 04 60 00 00 00 00

mcanteri commented 9 months ago

Okay, I tried ./ipc_sniff /ipc_dispatch_3 | grep "04 00 00 00 02 00 00 00 04 60 04 60 00 00 00 00" and nothing appears trying to make some noise in the meantime :)

roleoroleo commented 9 months ago

If ipc_sniff doesn't catch this message, probably the cam doesn't detect the sound. I don't remember: does the cam detect the sound in the factory configuration? I mean no hack and using Yi app? I can't figure out which part of the hack breaks this functionality.

mcanteri commented 9 months ago

I will not try again to connect the cam with the app since I already tried with the other camera with the result of having it stuck and maybe bricked, since the procedure to restore it, doesn't function, so I will not do that check. I surely know that the microphone is working perfectly since my noise sensor is working smoothly, so it is somewhere else the problem. I can see the same issue on the new camera anyway, with the y291ga firmware. If it is of any help, my configuration on RTSP Audio is set on ulaw. Adding: the videos that are recorded automatically by the camera are muted, and no sound recorded, while listening on the rtsp stream the audio is present.

roleoroleo commented 9 months ago

If it is of any help, my configuration on RTSP Audio is set on ulaw. Adding: the videos that are recorded automatically by the camera are muted, and no sound recorded, while listening on the rtsp stream the audio is present.

Interesting... could you try to set audio in aac?

mcanteri commented 9 months ago

Using aac sound doesn't work on chrome on the y291ga and neither on the y20ga but it works on an appropriate video/audio player. I see that you have motion detection off, of course mine is on but I don't know if changes something. Any change about the sound sensor via mqtt, it doesn't run.

roleoroleo commented 8 months ago

I need to check it again. I don't know where is the problem.

github-actions[bot] commented 5 months ago

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.

mcanteri commented 5 months ago

I need to check it again. I don't know where is the problem.

Did you have the chance to check?

roleoroleo commented 5 months ago

No, at the moment. I will try the next week.

github-actions[bot] commented 1 month ago

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.