iOS icon indicating copy to clipboard operation
iOS copied to clipboard

Add CarPlay configuration export/import with automatic server ID migration

Open Copilot opened this issue 2 months ago • 0 comments

Summary

Adds export/import functionality for CarPlay configurations via .homeassistant files. Exported configurations automatically migrate server IDs on import using existing migration logic, allowing configurations to be shared across devices with different server setups.

Export:

  • "Share Configuration" button exports current config as CarPlay.homeassistant JSON file
  • Uses iOS share sheet for distribution via AirDrop, Messages, etc.

Import:

  • "Import Configuration" button accepts .homeassistant files
  • Confirmation dialog prevents accidental overwrites
  • Automatically migrates server IDs by matching entity IDs across available servers
  • Preserves all tabs, quick access items, and customizations

Implementation:

  • exportConfiguration() - Encodes config to JSON, saves to temp directory
  • importConfiguration(from:completion:) - Decodes file, runs migration via migrateItemsIfNeeded(), saves to database
  • Added migrateItemsIfNeeded to MagicItemProviderProtocol for cross-module access
  • 8 new localization strings for UI and error messages

Screenshots

No UI screenshots provided - feature adds buttons to existing CarPlay configuration screen

Link to pull request in Documentation repository

Documentation: home-assistant/companion.home-assistant#

Any other notes

Migration logic reuses existing MagicItemProvider.migrateItemsIfNeeded() which handles server ID mismatches by finding matching entities across configured servers. This enables seamless configuration transfer even when server identifiers differ between devices (e.g., after re-adding a server).

Original prompt

In CarPlay configuration screen let's add a button to share carplay configuration, this share exports a file called "CarPlay.homeassistant", then implement a import flow which will receive this file, import to that users CarPlay configuration and then run the migration flow that we already have to replace serverId if needed, since the user that receives this file will have servers configured with different IDs, even though it is the same server. User has to approved the import before proceeding


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot avatar Dec 17 '25 11:12 Copilot