fwestenberg / reolink_dev

Home Assistant Reolink addon
MIT License
550 stars 102 forks source link

switch.py modified to support Spotlight and Siren, but common control… #375

Closed ptyers closed 2 years ago

ptyers commented 2 years ago

This is nowhere near release status, works but on Reolink Duo all switches are duplicated and switch statuses are not linked

Needs work to identify when there is a second channel to a camera and common controls should only be created once.

I am not yet sufficiently familiar with the structure of home assistant entities and/or reolink_dev to work out how to identify the existence of the first camera entity.

Advice required

I could just look for channel number > 0 but I suspect (to be confirmed please) that this could have ramifications with NVRs.

293 #323

ptyers commented 2 years ago

I believe this is now potential release status. The check for channel > 1 and not being an NVR should obviate the creation of duplicated common controls on dual channel cameras

I have only a Reolink Duo so this needs testing against single channel cameras but I believe it is valid.

mpjanofsky commented 2 years ago

I can test this on an RLC-812A that I just got if needed.

ptyers commented 2 years ago

Mpjanofsky, Yes that would be appreciated but I need advice as to how you get the modified routines. If you load the integration as a custom component using my repo I believe you will get the master branch not the SpotandSiren branch.

Advice required! If the repo used in the custom repository installation is https://github.com/ptyers/reolink_dev/tree/SpotandSiren Will that pull down the modified branch to test?

cpainchaud commented 2 years ago

@ptyers I am waiting for your comment earlier in this PR to merge it

ptyers commented 2 years ago

I am confused. You say you are awaiting my comment but I don't know what you are seeking. As far as I can test the PR is ready for merging with the proviso that I was unable to test it with a single lens camera.

ptyers commented 2 years ago

if (base.unique_id[13:] == "1") and not base.api.is_nvr():

Camera is uniquely identified by mac address less ":' seperators concatenated with "-" and then channel_id This test determines that the camera is NOT an NVR but is dual channel. We only want to generate common controls (switches) once not duplicate them on a second channel. There is probably need to consider whether the common sensors, motion detection etc, should also be only generated once but I did not look at this. On a single channel camera the switches are configured but suppressed if its a dual channel camera.

cpainchaud commented 2 years ago

@ptyers ok fine. I am going to allow this PR but I think we also need to find a better way to do it and should update the code accordingly.

For example should just detect that the device has several channels (not just 1) and so create these buttons? Or should we have a static table with all devices so we can check if buttons were already created?

cpainchaud commented 2 years ago

released as 0.40

mpjanofsky commented 2 years ago

Missed the reply to this - but just tested the new release and it works perfectly. Thanks for your hard work on this!