Add CarPlay configuration export/import with automatic server ID migration
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.homeassistantJSON file - Uses iOS share sheet for distribution via AirDrop, Messages, etc.
Import:
- "Import Configuration" button accepts
.homeassistantfiles - 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 viamigrateItemsIfNeeded(), saves to database - Added
migrateItemsIfNeededtoMagicItemProviderProtocolfor 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.