roleoroleo / yi-hack_ha_integration

Home Assistant custom integration for Yi cameras: yi-hack-MStar, yi-hack-Allwinner, yi-hack-Allwinner-v2, yi-hack-v5 and sonoff-hack
GNU General Public License v3.0
216 stars 32 forks source link

Dome U Pro - Switch to enable / disable AI Human Detection and Face Detection #35

Closed SmartM-ui closed 4 months ago

SmartM-ui commented 3 years ago

Hi, Would it be possible to provide the switches to activate / deactivate the AI Human Detection and Face Detection control present on the YI app for the U Pro Dome cam?

Thank you

roleoroleo commented 3 years ago

I need to find a solution here https://github.com/roleoroleo/yi-hack-Allwinner-v2/issues/210 before.

SmartM-ui commented 3 years ago

Hi @roleoroleo

this is the data that is detected when I press AI human detection from the YIhome app

AI Humand Detect OFF IPC message. Len: 20. Status: No error information! Parsing message. 01 00 00 00 08 00 00 00 3c 10 01 00 04 00 00 00 00 00 00 00

AI Humand Detect ON IPC message. Len: 20. Status: No error information! Parsing message. 01 00 00 00 08 00 00 00 3c 10 01 00 04 00 00 00 01 00 00 00

Thanks

roleoroleo commented 3 years ago

Ok, now try to send these messages. 1 - Save the binary code (20 bytes) into a file (use hxd if you are a windows user). 2 - Use the command ipc_cmd -x file.bin 2 - Use the command ipc_cmd -f file.bin 3 - Refresh the app and check if the switch is changed.

SmartM-ui commented 3 years ago

ipc_cmd -x file.bin

Hi @roleoroleo

I installed HxD and pasted the code "01 00 00 00 08 00 00 00 3c 10 01 00 04 00 00 00 01 00 00 00" in a new file. Saving the AI.bin file, I saw that it takes up 20 bytes.

I copied the file to the root of the MicroSd

Through terminal I gave the command: killall ipc_multiplexer / tmp / sd / yi-hack / bin / ipc_cmd -x AI.bin

but the switch inside the YIhome app doesn't change

Schermata 2021-07-07 alle 17 24 34 Schermata 2021-07-07 alle 17 24 51
roleoroleo commented 3 years ago

Sorry, use -f parameter. -x is another feature.

SmartM-ui commented 3 years ago

Sorry, use -f parameter. -x is another feature.

@roleoroleo Good morning, thanks, i tried but i must have made a mistake using HxD (i had never used it).

The following error is returned with the - f command: killall ipc_multiplexer /tmp/sd/yi-hack/bin/ipc_cmd -f AI.bin Error opening file AI.bin

Opening the AI.bin file whit HxD (which I saved by manually adding the .bin extension), I see this:

Schermata 2021-07-08 alle 10 17 18
roleoroleo commented 3 years ago

Try to add the absolute path to the AI.bin The content of the file seems to be ok.

SmartM-ui commented 3 years ago

Try to add the absolute path to the AI.bin The content of the file seems to be ok.

Hi, The absolute path should be AI.bin, I put it in the root of the microSD. Or create a temporary file inside the tmp / sd folder?

roleoroleo commented 3 years ago

It's not important where you copy the file. If it's in the root of the microSD try: /tmp/sd/yi-hack/bin/ipc_cmd -f /tmp/sd/AI.bin

SmartM-ui commented 3 years ago

It's not important where you copy the file. If it's in the root of the microSD try: /tmp/sd/yi-hack/bin/ipc_cmd -f /tmp/sd/AI.bin

GREAT @roleoroleo

It works! AI.bin file manages to activate human detection in the official YI app!

After lunch I also try to create the file to deactivate it and I inform you.

Thanks again :-)

SmartM-ui commented 3 years ago

Hi @roleoroleo The code works to both activate and deactivate the AI Human Detect:

AI Human Detect ON: 01 00 00 00 08 00 00 00 3C 10 01 00 04 00 00 00 01 00 00 00

AI Human Detect OFF: 01 00 00 00 08 00 00 00 3C 10 01 00 04 00 00 00 00 00 00 00

This code enable the AI Face Detection:

Face detect ON 01 00 00 00 08 00 00 00 3d 10 01 00 04 00 00 00 01 00 00 00

Face detect OFF 01 00 00 00 08 00 00 00 3d 10 01 00 04 00 00 00 00 00 00 00

Would it be possible to create the switch from Home Assistant?

roleoroleo commented 3 years ago

I need to add them to the fw before to add to ha.

SmartM-ui commented 3 years ago

I need to add them to the fw before to add to ha.

I look forward to! Thank you

SmartM-ui commented 3 years ago

I need to add them to the fw before to add to ha.

Hi @roleoroleo , maybe you will have to insert only face detection in the firmware because from further tests, I was able to ascertain that already currently, by modifying the "AI Human Detection" parameter from your web page YIHACK (camera setting), the YIhome app receives the command and synchronizes it. This only happens in one sense, WEBpage YIHACS> YIhome app and not vice versa. (Maybe integrating it into the firmware will be able to sync it both ways?)

Having already the AI Human Detection sensor in your WebPage, is it already possible to have this switch in Home Assistant or can you tell me how to create it manually?

Thanks

roleoroleo commented 3 years ago

maybe you will have to insert only face detection in the firmware because from further tests, I was able to ascertain that already currently, by modifying the "AI Human Detection" parameter from your web page YIHACK (camera setting), the YIhome app receives the command and synchronizes it.

Ok.

This only happens in one sense, WEBpage YIHACS> YIhome app and not vice versa. (Maybe integrating it into the firmware will be able to sync it both ways?)

This is normal and I can't fix it at the moment.

Having already the AI Human Detection sensor in your WebPage, is it already possible to have this switch in Home Assistant or can you tell me how to create it manually?

Create a switch with a http request like this:

http://IP-CAM:8080/cgi-bin/camera_settings.sh?ai_human_detection=yes
http://IP-CAM:8080/cgi-bin/camera_settings.sh?ai_human_detection=no
SmartM-ui commented 3 years ago

maybe you will have to insert only face detection in the firmware because from further tests, I was able to ascertain that already currently, by modifying the "AI Human Detection" parameter from your web page YIHACK (camera setting), the YIhome app receives the command and synchronizes it.

Ok.

This only happens in one sense, WEBpage YIHACS> YIhome app and not vice versa. (Maybe integrating it into the firmware will be able to sync it both ways?)

This is normal and I can't fix it at the moment.

Having already the AI Human Detection sensor in your WebPage, is it already possible to have this switch in Home Assistant or can you tell me how to create it manually?

Create a switch with a http request like this:

http://IP-CAM:8080/cgi-bin/camera_settings.sh?ai_human_detection=yes
http://IP-CAM:8080/cgi-bin/camera_settings.sh?ai_human_detection=no

THANK YOU!

I try to create a switch using restful

SmartM-ui commented 3 years ago

Create a switch with a http request like this:

http://IP-CAM:8080/cgi-bin/camera_settings.sh?ai_human_detection=yes
http://IP-CAM:8080/cgi-bin/camera_settings.sh?ai_human_detection=no

Hi @roleoroleo ... sorry again, i was trying to make a switch with http, but it doesn't seem to work. If you managed to do this, could you fix my code please?

switch:

Thanks in advance

roleoroleo commented 3 years ago

Try a command line switch with curl. This service is not really rest.

SmartM-ui commented 3 years ago

Try a command line switch with curl. This service is not really rest.

Ok, I try

SmartM-ui commented 3 years ago

Try a command line switch with curl. This service is not really rest.

Hi @roleoroleo I have managed to create a switch, but I have seen that it does not always work as well as the switches you have directly integrated.

I believe, for everyone's sake, that you will also have to integrate the AI Human Detect switch directly into the integration when you update the firmware :-)

The best code of all the tests turned out this, if it were to be useful to someone:

shell_command: switch_1_on: curl -k "http://IPCAM:8080/cgi-bin/camera_settings.sh?ai_human_detection=yes" switch_1_off: curl -k "http://IPCAM:8080/cgi-bin/camera_settings.sh?ai_human_detection=no"

switch:

SmartM-ui commented 3 years ago

Hi @roleoroleo I don't know where it is right to make the request, but in order not to let this request die, I only propose the link with the request made directly on yi-hack-Allwinner-v2 :-)

https://github.com/roleoroleo/yi-hack-Allwinner-v2/issues/210#issuecomment-911727758

https://github.com/roleoroleo/yi-hack-Allwinner-v2/issues/209#issuecomment-911742216

THANK YOU!!!

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.