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 support for animal detection in unifiprotect #116290

Merged
merged 4 commits into from
Jun 10, 2024

Conversation

wfltaylor
Copy link
Contributor

Proposed change

This adds support for smart animal detection already supported by pyunifiprotect. As with the other smart detections, this is exposed as binary sensor and a switch to control whether the detection is enabled.

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

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

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
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format 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:

@wfltaylor wfltaylor requested a review from bdraco as a code owner April 27, 2024 11:05
home-assistant[bot]

This comment was marked as resolved.

@home-assistant

This comment was marked as resolved.

@home-assistant home-assistant bot marked this pull request as draft April 27, 2024 11:05
@home-assistant
Copy link

Hey there @AngellusMortis, @bdraco, mind taking a look at this pull request as it has been labeled with an integration (unifiprotect) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of unifiprotect can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign unifiprotect Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

@halomakes
Copy link

Installed this to test on my installation, works great! Able to detect when my puppy wants to go outside now
image

@josephdc18
Copy link

josephdc18 commented May 30, 2024

I updated to the latest home assistant but do not see the animal detections? I have Home Assistant OS installed and just use the default unifi protect plugin for my UNVR Pro. Is this correct?

I can see person, object, and vehicle detection. I have a slew of G4 Pros and G5 Cameras. Thanks in advance

@halomakes
Copy link

@josephdc18 this has not been merged into the core integration yet, as you can see by the open status. If you would like to test it out for yourself you will need to grab a copy of the files from fork wfltaylor:unifiprotect-animal-detection and put them in your custom_components (make sure there's a version specified in manifest.json) to override it.

@xenia-09A
Copy link

xenia-09A commented Jun 4, 2024

thanks so much for this @wfltaylor , do we know when this will be merged?
I am new to HA so I will need to really dig around to follow @halomakes to try to load this now
is SSH needed to load this or can be done from GUI? thanks

currently found this https://developers.home-assistant.io/docs/creating_integration_manifest/
which I will take a read later tomorrow

@bdraco
Copy link
Member

bdraco commented Jun 4, 2024

Looks good.

I don't think there are any docs changes needed but will need to review https://www.home-assistant.io/integrations/unifiprotect/ to check.

@bdraco
Copy link
Member

bdraco commented Jun 4, 2024

I'll try to test this sometime this week. June is super busy for me to it might not be until next week but shouldn't be a problem to get merged before 2024.7

@bdraco
Copy link
Member

bdraco commented Jun 4, 2024

It looks like the tests are failing, please check. Thanks!

@frenck frenck marked this pull request as draft June 4, 2024 04:45
@frenck
Copy link
Member

frenck commented Jun 4, 2024

As pointed out above, the test are failing, could you take a look @wfltaylor?

I've marked the PR as draft, please mark it ready for review once the issue has been addressed.

Thanks! 👍

../Frenck

@wfltaylor wfltaylor force-pushed the unifiprotect-animal-detection branch from 34713a8 to c000c74 Compare June 4, 2024 05:48
@wfltaylor
Copy link
Contributor Author

@bdraco @frenck I’ve updated the tests.

@wfltaylor wfltaylor marked this pull request as ready for review June 4, 2024 05:51
@bdraco
Copy link
Member

bdraco commented Jun 10, 2024

codecov seems to be ratelimited right now.

I'll try again in a bit

@bdraco
Copy link
Member

bdraco commented Jun 10, 2024

manual testing looks good

Screenshot 2024-06-10 at 10 01 48 AM Screenshot 2024-06-10 at 10 01 51 AM

@bdraco
Copy link
Member

bdraco commented Jun 10, 2024

checked coverage locally.
new decrease

pytest --cov=homeassistant/components/unifiprotect/ --cov-report term-missing -- tests/components/unifiprotect/

homeassistant/components/unifiprotect/sensor.py 133 1 99% 781
homeassistant/components/unifiprotect/switch.py 111 0 100%

Copy link
Member

@bdraco bdraco left a comment

Choose a reason for hiding this comment

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

Thanks @wfltaylor

@bdraco bdraco added the smash Indicator this PR is close to finish for merging or closing label Jun 10, 2024
@bdraco bdraco merged commit 30fab7b into home-assistant:dev Jun 10, 2024
24 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jun 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla-signed has-tests integration: unifiprotect new-feature small-pr PRs with less than 30 lines. 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

6 participants