Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reolink IP NVR/Camera integration #84081

Merged
merged 34 commits into from Dec 27, 2022
Merged

Conversation

starkillerOG
Copy link
Contributor

@starkillerOG starkillerOG commented Dec 15, 2022

Breaking change

Proposed change

Add Reolink NVR/camera integration.

Based on the custom components:
https://github.com/JimStar/reolink_cctv
https://github.com/fwestenberg/reolink_dev

Many thanks to @JimStar @fwestenberg for their work.

This is a stripped down version of the custom components that (schould) adhere to the HomeAssistant standards, from one I believe is that only a single platform can be added at a time.
Now only the camera platform is implemented.
Follow up PRs will implement binary_sensors (motion, people, vehicle. pet, doorbell detection), switches etc.
But first this basis needs to be accepted.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

@starkillerOG
Copy link
Contributor Author

starkillerOG commented Dec 15, 2022

@JimStar would you also like to become codeowner of this (official) integration, since you are now also working actively on the custom component?

@fwestenberg would you also like to become codeowner of this (official) integration, since you have made the original custom component?

@starkillerOG
Copy link
Contributor Author

@bdraco thank you very much for the review!
I have processed all feedback, could you review again?

@fwestenberg
Copy link
Contributor

fwestenberg commented Dec 20, 2022

@JimStar would you also like to become codeowner of this (official) integration, since you are now also working actively on the custom component?

@fwestenberg would you also like to become codeowner of this (official) integration, since you have made the original custom component?

Not necessary, but thanks. At this moment I only use Frigate + addon.
Great work!

@starkillerOG
Copy link
Contributor Author

@bdraco I processed all feedback of the second review, could you review again/merge?
Could we get this merged before the beta cut?

@starkillerOG
Copy link
Contributor Author

@bdraco since it was decided to use a seperate client session here: #84573, I think this is ready to be merged.

@bdraco bdraco added the smash Indicator this PR is close to finish for merging or closing label Dec 27, 2022
starkillerOG and others added 2 commits December 27, 2022 20:21
Co-authored-by: J. Nick Koston <nick@koston.org>
Co-authored-by: J. Nick Koston <nick@koston.org>
@starkillerOG
Copy link
Contributor Author

@bdraco thanks for the last suggestion and approval.
I have commited your changes.

Does it need a second review, or can you merge this when the tests complete?

@bdraco
Copy link
Member

bdraco commented Dec 27, 2022

@bdraco thanks for the last suggestion and approval. I have commited your changes.

👍

Does it need a second review, or can you merge this when the tests complete?

I always like to get a second set of 👀, but I don't see anything that I'm particularly concerned about here so should be good to merge if the CI passes. Corrections and improvements can always happen later. This looks like a good MVP

@bdraco bdraco merged commit a06b1ea into home-assistant:dev Dec 27, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Dec 28, 2022
Copy link
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address the comments in a new PR. Thanks!

homeassistant/components/reolink/__init__.py Show resolved Hide resolved
homeassistant/components/reolink/__init__.py Show resolved Hide resolved
homeassistant/components/reolink/__init__.py Show resolved Hide resolved
homeassistant/components/reolink/camera.py Show resolved Hide resolved
homeassistant/components/reolink/camera.py Show resolved Hide resolved

return True

async def update_states(self) -> bool:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this return a boolean? What does that mean?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked into the library. It seems the boolean represents if there's an error. Shouldn't we react to an error?

Looks like the library is both logging errors (at error level) and raising errors in some cases. That's usually bad practice. If the library has decided to raise an error, it's better to let the library user decide what to do with that error.

Debug logging is of course always ok.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend to change the library to follow one practice only. Either trap all exceptions and only log errors, or don't log errors at all and just raise library specific exceptions. It's often easier to control the flow by using exceptions than checking booleans.


async def update_states(self) -> bool:
"""Call the API of the camera device to update the states."""
return await self._api.get_states()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Side note: get_states sounds like it should return or retrieve more than one state. The naming and return value typing seems inconsistent.

tests/components/reolink/test_config_flow.py Show resolved Hide resolved
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla-signed has-tests integration: reolink new-integration smash Indicator this PR is close to finish for merging or closing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants