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
205 stars 32 forks source link

feature: set various configurations #100

Closed trombik closed 2 months ago

trombik commented 1 year ago

as a user, i would like to configure cameras via HA, such as enabling or disabling motion detection so that i can enable motion detection when i am away using Automation.

the integration does not offer much when it comes to configuring cameras. only privacy switch is implemented.

https://github.com/roleoroleo/yi-hack_ha_integration/blob/454f3aa3d243453eec64f9a31c0f915642adfe64/custom_components/yi_hack/switch.py#L17-L20

with this feature, one can implement "Home and Away" feature found in the yi mobile app.

trombik commented 1 year ago

the HTTP APIs are implemented at:

https://github.com/roleoroleo/yi-hack-Allwinner-v2/blob/69d947fa654e8a30f75643254142578a10b77e8d/src/www/httpd/cgi-bin/camera_settings.sh#L46-L58

roleoroleo commented 1 year ago

Where do you want to receive motion messages? HA (via mqtt) or Yi app?

trombik commented 1 year ago

both if possible. because it is backward compatible and probably many users expects the app works even when the hack is installed.

however, i personally do not like the app and i am happy with notifications from HA only (via MQTT) because:

roleoroleo commented 1 year ago

"Home and Away" feature in the app and privacy option are very different. AFAIK the 1st feature switches off all detections (notifications). But the cam still working normally and continues to communicate with the cloud. I'm not completely sure because I have not been able to identify the message used when you change the mode (the message sent from the app to the cam, if it exists). Maybe it's only a cloud feature, the cloud receives notifications but it doesn't route them to the app.

Privacy is a option that I added to switch off all stream/pictures features related to the hack. So it kills rtsp server, snapshots and records. But it doesn't stop the stream from going to the cloud.

If you want to use the "Home and Away" feature by Yi, I have to detect this message and I don't know if it's possible. Otherwise, I could send many messages, one for each dection to enable/disable them. Or other possibilities like stop mqtt notification service (only ha side, not yi side). Or... I accept advice.

trombik commented 1 year ago

well, I do not need exactly same feature as "Home and Away" implements. I need to configure settings from HA. they would be building blocks to implements whatever feature users need.

roleoroleo commented 1 year ago

What switches do you need? I could add to the integration the switches I implemented in the "Camera Settings" page:

trombik commented 1 year ago

@roleoroleo the list sounds great.

roleoroleo commented 1 year ago

Do you want to try this beta? yi_hack_switches.tar.gz

The only problem is that when you change the configuration on the app, HA takes a long time to update.

trombik commented 1 year ago

@roleoroleo I will.

would you create a branch for that archive and push to GitHub? that would help others to understand the code.

roleoroleo commented 1 year ago

https://github.com/roleoroleo/yi-hack_ha_integration/tree/switches

trombik commented 1 year ago

@roleoroleo it seems to work (i haven't tested all the switches). let me try to improve the diff (i need an input select to change the sensitivity of human detection) .

another reason why you should not use the yi app; the app failed to notify when human is detected sometimes while you can see the events in HA.

github-actions[bot] commented 3 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.