core icon indicating copy to clipboard operation
core copied to clipboard

Add support for animal detection in unifiprotect

Open wfltaylor opened this issue 1 year ago • 2 comments

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!)
  • [x] 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

  • [x] The code change is tested and works locally.
  • [x] Local tests pass. Your PR cannot be merged unless tests pass
  • [x] There is no commented out code in this PR.
  • [x] I have followed the development checklist
  • [x] I have followed the perfect PR recommendations
  • [x] The code has been formatted using Ruff (ruff format homeassistant tests)
  • [x] 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 avatar Apr 27 '24 11:04 wfltaylor

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks :+1:

Learn more about our pull request process.

home-assistant[bot] avatar Apr 27 '24 11:04 home-assistant[bot]

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.

home-assistant[bot] avatar Apr 27 '24 11:04 home-assistant[bot]

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

halomakes avatar May 10 '24 18:05 halomakes

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

josephdc18 avatar May 30 '24 15:05 josephdc18

@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.

halomakes avatar May 30 '24 17:05 halomakes

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

xenia-09A avatar Jun 04 '24 01:06 xenia-09A

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 avatar Jun 04 '24 01:06 bdraco

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 avatar Jun 04 '24 01:06 bdraco

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

bdraco avatar Jun 04 '24 04:06 bdraco

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

frenck avatar Jun 04 '24 04:06 frenck

@bdraco @frenck I’ve updated the tests.

wfltaylor avatar Jun 04 '24 05:06 wfltaylor

codecov seems to be ratelimited right now.

I'll try again in a bit

bdraco avatar Jun 10 '24 15:06 bdraco

manual testing looks good

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

bdraco avatar Jun 10 '24 15:06 bdraco

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%

bdraco avatar Jun 10 '24 15:06 bdraco