core icon indicating copy to clipboard operation
core copied to clipboard

Add CarPlay storage API to iOS integration

Open bgoncal opened this issue 1 month ago • 6 comments

Breaking change

Proposed change

Added CarPlay storage to iOS integration and API's to update it's content. This will be used to define server global configurations, such as if CarPlay should be disabled for all and default entities to show in quick access tab

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:
  • Link to developer documentation pull request:
  • Link to frontend pull request:

Checklist

  • [x] I understand the code I am submitting and can explain how it works.
  • [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.
  • [x] Any generated code has been carefully reviewed for correctness and compliance with project standards.

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.

To help with the load of incoming pull requests:

bgoncal avatar Dec 02 '25 20:12 bgoncal

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

Code owner commands

Code owners of ios 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 ios 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 Dec 02 '25 20:12 home-assistant[bot]

Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration (mobile_app) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of mobile_app 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 mobile_app 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 Dec 02 '25 20:12 home-assistant[bot]

Code looks fine and follows previous patterns, however at homeassistant/components/mobile_app/init.py you are using

carplay_config = config.get(DOMAIN, {}).get("carplay", {})

when you could be using

carplay_config = config[DOMAIN]["carplay"] 

The code uses redundant configuration retrieval. The schema defines a default value for 'carplay' at line 85, and the validated config already includes it. The nested .get('carplay', {}) call is unnecessary as you can directly access config[DOMAIN]['carplay'] instead of using config.get(DOMAIN, {}).get('carplay', {}).

If this is fixed I believe that it should be ready to go. Nice new feature.

MS2620 avatar Dec 07 '25 18:12 MS2620

I changed the approach to use a storage that can be updated by using the new API inside iOS integration

bgoncal avatar Dec 08 '25 16:12 bgoncal

@MartinHjelmare Whats the proper way that I can restrict this to Admin only?

bgoncal avatar Dec 09 '25 10:12 bgoncal

I think we can use the require_admin decorator. Example: https://github.com/home-assistant/core/blob/7ed8613411d1ca65fa6cc8ed2a8fab38e5258f43/homeassistant/components/config/view.py#L87-L98

MartinHjelmare avatar Dec 09 '25 22:12 MartinHjelmare