Add support for animal detection in unifiprotect
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:
- [ ] Documentation added/updated for www.home-assistant.io
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 runningpython3 -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:
- [ ] I have reviewed two other open pull requests in this repository.
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks :+1:
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 closeCloses the pull request.@home-assistant rename Awesome new titleRenames the pull request.@home-assistant reopenReopen the pull request.@home-assistant unassign unifiprotectRemoves the current integration label and assignees on the pull request, add the integration domain after the command.@home-assistant add-label needs-more-informationAdd a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.@home-assistant remove-label needs-more-informationRemove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.
Installed this to test on my installation, works great! Able to detect when my puppy wants to go outside now
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 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.
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
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.
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
It looks like the tests are failing, please check. Thanks!
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
@bdraco @frenck I’ve updated the tests.
codecov seems to be ratelimited right now.
I'll try again in a bit
manual testing looks good
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%