This document serves as a comprehensive index of Apple Developer documentation references used throughout HomeAtlas. All citations link to canonical HomeKit framework documentation.
- HomeKit Framework - Coordinate and control home automation accessories
- Enabling HomeKit in your app - Setup entitlements and permissions
- HMHomeManager - Manages a collection of user's homes
- HMHomeManagerDelegate - Receives home manager state updates
- Configuring a home automation device - Setup guide
- HMHome - Represents a physical location
- HMHomeDelegate - Receives home state updates
- HMHomeAccessControl - User permission levels
- HMRoom - Represents a room within a home
- roomForEntireHome - Default room for unassigned accessories
- HMZone - Logical grouping of rooms
- Room for home cannot be in zone - Architecture constraint
- HMAccessory - Represents a home automation accessory
- HMAccessoryCategory - Categorizes accessory types
- HMAccessorySetupManager - Manages new accessory setup
- Interacting with a home automation network - Integration patterns
- HMService - Represents a controllable feature
- HMServiceGroup - Groups related services
- Service Type Constants:
- HMServiceTypeLightbulb - Light source control
- HMServiceTypeThermostat - Temperature control
- HMServiceTypeOutlet - Power outlet control
- HMCharacteristic - Represents a specific characteristic
- HMCharacteristicMetadata - Characteristic constraints
- Characteristic Type Constants:
- HMCharacteristicTypePowerState - On/off state
- HMCharacteristicTypeBrightness - Brightness level
- HMCharacteristicTypeCurrentTemperature - Temperature reading
- HMActionSet - Collection of actions triggered together
- HMTimerTrigger - Periodic time-based triggers
- HMEventTrigger - Event and condition-based triggers
- HMError - HomeKit error structure
- HMError.Code - Error code enumeration
- HMErrorDomain - Error domain identifier
- Error Codes:
- connectionFailed - Accessory connection failure
- communicationFailure - Communication error
- invalidParameter - Invalid input
- HomeKit Accessory Simulator - Test accessories without hardware
- HMAccessorySetupPayload - Authentication payload
- HomeKit Entitlement - Enable HomeKit capability (
com.apple.developer.homekit) - NSHomeKitUsageDescription - Privacy usage string
- iOS: 8.0+
- iPadOS: 8.0+
- macOS: 10.14+ (via Mac Catalyst)
- tvOS: 10.0+
- watchOS: 2.0+
- visionOS: 1.0+
- HomeKit Accessory Protocol Specification - Technical protocol details
- App Store Review Guidelines - HomeKit - Submission requirements
- WWDC Videos on HomeKit - Developer sessions
The Snapshot Export API allows developers to serialize HomeKit home graphs to deterministic JSON format for debugging, backups, and data export scenarios.
- Public API:
HomeAtlas.encodeSnapshot(_:options:) async throws -> Data - Purpose: Export Home entities, relationships, and state to JSON
- Thread Safety:
@MainActorannotation ensures main-thread execution (required for HomeKit API access) - Performance: Typical export time ≤2 seconds for ~100 accessories with ~1000 characteristics
import HomeAtlas
import HomeKit
@MainActor
func exportHomeSnapshot(_ home: HMHome) async throws {
// Basic export
let jsonData = try await HomeAtlas.encodeSnapshot(home)
// With anonymization for privacy
let options = SnapshotOptions(anonymize: true)
let anonymizedData = try await HomeAtlas.encodeSnapshot(home, options: options)
// Save to file
try jsonData.write(to: URL(fileURLWithPath: "home-snapshot.json"))
}Swift 6 macros generate type-safe snapshot types for HomeAtlas classes using @Snapshotable.
Generated types are suffixed with AtlasSnapshot to avoid conflicts with generic snapshot models.
@Snapshotable
public final class LightbulbService: Service { /* ... */ }
// Generated by macro:
public struct LightbulbServiceAtlasSnapshot: Codable, Sendable { /* typed fields */ }
// Example usage (async):
@MainActor
func captureTypedServiceSnapshot(_ service: LightbulbService) async throws -> LightbulbServiceAtlasSnapshot {
try await LightbulbServiceAtlasSnapshot(from: service)
}Applies to: Home, Room, Zone, Accessory, Service subclasses, Characteristic subclasses.
SnapshotOptions.anonymize: Whentrue, redacts user-identifiable names and UUIDs while preserving structure- Home/Room/Accessory/Service names are hashed
- UUIDs remain intact for relationship tracking
- Metadata (manufacturer, model, firmware) preserved
JSON output follows the HomeAtlas Home Snapshot Schema:
{
"id": "home-uuid",
"name": "My Home",
"rooms": [
{
"id": "room-uuid",
"name": "Living Room",
"accessories": [...]
}
],
"zones": [...],
"metadata": null
}Characteristics follow @MainActor read semantics per HMCharacteristic.readValue():
- Readable characteristics: Value captured if
propertiescontains HMCharacteristicPropertyReadable - Permission-restricted:
value: null, reason: "permission"when read access denied - Unavailable devices:
value: null, reason: "unavailable"when device unreachable - Unknown errors:
value: null, reason: "unknown"for other failures
Reference: Apple Developer - HMCharacteristic
All entities sorted lexicographically by name to ensure stable JSON output across exports:
- Rooms sorted by
name(ascending) - Zones sorted by
name(ascending) - Accessories sorted by
name(ascending) - Services sorted by
serviceType, thenname(ascending) - Characteristics sorted by
characteristicType(ascending)
JSON keys output using JSONEncoder.outputFormatting = .sortedKeys for reproducibility.
#if canImport(HomeKit)
// Full snapshot export available on iOS 18+, macOS 15+, etc.
#else
// Fallback: throws HomeKitError.platformUnavailable
#endif- HomeKit platforms: iOS 18.0+, macOS 15.0+, watchOS 11.0+, tvOS 18.0+
- Non-HomeKit platforms: API available but throws
HomeKitError.platformUnavailablewith descriptive reason
All errors map to HomeKitError enum cases:
.homeManagement(operation:underlying:): Home/Room/Zone traversal failures.accessoryOperation(accessoryID:operation:): Accessory/Service reading failures.characteristicOperation(characteristicID:operation:): Characteristic value read failures.platformUnavailable(reason:): HomeKit framework not available on current platform
Reference: HomeKitError.swift
Personally Identifiable Information (PII) in snapshots:
- Home/Room/Zone/Accessory/Service names (user-defined strings)
- UUIDs (device-specific identifiers)
Recommendation: Use SnapshotOptions(anonymize: true) when sharing snapshots for debugging or support to redact PII.
- Export time scales linearly with accessory/characteristic count
- Typical performance: 100 accessories with 1000 characteristics export in <2 seconds
- Use
asynccontext to avoid blocking UI during large exports - Consider background queue for very large homes (200+ accessories)
All Developer Apple references in HomeAtlas source code follow this format:
/// Brief description.
///
/// - Reference: [Apple Developer - Type/Method Name](https://developer.apple.com/documentation/homekit/...)For example:
/// A strongly-typed wrapper for HMAccessory.
///
/// - Reference: [Apple Developer - HMAccessory](https://developer.apple.com/documentation/homekit/hmaccessory)
@MainActor
public final class Accessory { ... }Last Updated: November 11, 2025 Related: Service Extension, Troubleshooting Guide