feat: Tessie GPS navigation service
Proposed change
It fixes this proposal: https://community.home-assistant.io/t/tessie-navigate-service/879754
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
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) - [ ] Tests have been added to verify that the new code works.
If user exposed functionality or configuration variables are added/changed:
- [x] Documentation added/updated for www.home-assistant.io
If the code communicates with devices, web services, or third-party tools:
- [x] The manifest file has all fields filled out correctly.
Updated and included derived files by running:python3 -m script.hassfest. - [X] New or updated dependencies have been added to
requirements_all.txt.
Updated by runningpython3 -m script.gen_requirements_all. - [X] For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
To help with the load of incoming pull requests:
- [ ] I have reviewed two other open pull requests in this repository.
Hey there @bre77, mind taking a look at this pull request as it has been labeled with an integration (tessie) you are listed as a code owner for? Thanks!
Code owner commands
Code owners of tessie 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 tessieRemoves 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.
@Bre77 thank you for your comments. In an attempt at making this more Home Assistant standard, I have also extracted the service into two separate calls.
Be mindful though that Teslemetry defines Domain services, and I've opted for Entity-based services.
Comparison here:
I personally believe (based on this) that Entity-based is better, and that Teslemetry actually should also opt for those kinds of services. Thoughts?
Oh, and be mindful that I still need to extensively test these latest changes before we merge, but it should be reviewable now.
I personally believe (based on this) that Entity-based is better, and that Teslemetry actually should also opt for those kinds of services. Thoughts?
There was some specific reason I was using domain automations, but it's been so long I can't remember and it's possible it only applied to the first few. I'll consider changing this up.
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks :+1:
Okay so the big benefit of normal services over entity services is that normal services are registered even when the entry was not able to set up, for example when Tessie is down or your system has no internet.
The reason why we want to register these in async_setup is to always set it up is that we want to be able to validate your automations. Because if you use a service that does not exist, your automation would error and we want you to know that upfront. By always setting up the services first, we are sure that we can validate correctly!
We should only do entity services when there's an architectural need for them
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. If you are the author of this PR, please leave a comment if you want to keep it open. Also, please rebase your PR onto the latest dev branch to ensure that it's up to date with the latest changes. Thank you for your contribution!
@joostlek wrote:
Okay so the big benefit of normal services over entity services is that normal services are registered even when the entry was not able to set up, for example when Tessie is down or your system has no internet.
The reason why we want to register these in async_setup is to always set it up is that we want to be able to validate your automations. Because if you use a service that does not exist, your automation would error and we want you to know that upfront. By always setting up the services first, we are sure that we can validate correctly!
We should only do entity services when there's an architectural need for them
This is not correct, we should do entity services when targeting entities.
Moreover, there's now a new API for registering entity services which doesn't rely on the platform and can be called from async_setup: https://github.com/home-assistant/core/blob/dfbaf66021c59ae916f0e6a15b2b3d60a4559180/homeassistant/helpers/service.py#L1172
@ffMathy what's this PR waiting for?
@emontnemery what direction I should go for (entity or domain services) and time for me to QA it. Don't have a lot of time these days but will get it in a month or so.
@ffMathy if it makes sense for the service to take entity ids as input (and not config entry id, device id or something else identifying the car), it should be an entity service.
If it should be an entity service you should however update the PR to register the entity service from the integration's async_setup as documented here https://developers.home-assistant.io/docs/dev_101_services?_highlight=async_register_platform_entity_service#entity-service-actions
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. If you are the author of this PR, please leave a comment if you want to keep it open. Also, please rebase your PR onto the latest dev branch to ensure that it's up to date with the latest changes. Thank you for your contribution!