Integrating HomeKit for Smart Home Control via iOS

NOVASOLUTIONS.TECHNOLOGY is engaged in the development, support and maintenance of iOS, Android, PWA mobile applications. We have extensive experience and expertise in publishing mobile applications in popular markets like Google Play, App Store, Amazon, AppGallery and others.
Development and support of all types of mobile applications:
Information and entertainment mobile applications
News apps, games, reference guides, online catalogs, weather apps, fitness and health apps, travel apps, educational apps, social networks and messengers, quizzes, blogs and podcasts, forums, aggregators
E-commerce mobile applications
Online stores, B2B apps, marketplaces, online exchanges, cashback services, exchanges, dropshipping platforms, loyalty programs, food and goods delivery, payment systems.
Business process management mobile applications
CRM systems, ERP systems, project management, sales team tools, financial management, production management, logistics and delivery management, HR management, data monitoring systems
Electronic services mobile applications
Classified ads platforms, online schools, online cinemas, electronic service platforms, cashback platforms, video hosting, thematic portals, online booking and scheduling platforms, online trading platforms

These are just some of the types of mobile applications we work with, and each of them may have its own specific features and functionality, tailored to the specific needs and goals of the client.

Showing 1 of 1 servicesAll 1735 services
Integrating HomeKit for Smart Home Control via iOS
Complex
~1-2 weeks
FAQ
Our competencies:
Development stages
Latest works
  • image_mobile-applications_feedme_467_0.webp
    Development of a mobile application for FEEDME
    756
  • image_mobile-applications_xoomer_471_0.webp
    Development of a mobile application for XOOMER
    624
  • image_mobile-applications_rhl_428_0.webp
    Development of a mobile application for RHL
    1050
  • image_mobile-applications_zippy_411_0.webp
    Development of a mobile application for ZIPPY
    947
  • image_mobile-applications_affhome_429_0.webp
    Development of a mobile application for Affhome
    862
  • image_mobile-applications_flavors_409_0.webp
    Development of a mobile application for the FLAVORS company
    445

HomeKit Integration for Smart Home Control via iOS

HomeKit is Apple's smart home ecosystem: lamps, thermostats, locks, sensors. An application gains access to accessories through HomeKit.framework, manages them through HMAccessory and HMCharacteristic. Before writing the first line of code, understand: HomeKit works only with certified equipment, and the testing procedure with real accessories in Apple HomeKit simulator has limitations.

Core HomeKit Concepts

HMHome — a home. Can be multiple (primary residence, vacation home). HMRoom — a room inside the home. HMAccessory — physical device (lamp, lock). HMService — accessory function (lamp has lighting service + information service). HMCharacteristic — specific service attribute: brightness, color temperature, lock state.

Hierarchy: Home → Room → Accessory → Service → Characteristic.

Setup and Access

import HomeKit

class HomeKitManager: NSObject, HMHomeManagerDelegate {
    let homeManager = HMHomeManager()

    override init() {
        super.init()
        homeManager.delegate = self
    }

    func homeManagerDidUpdateHomes(_ manager: HMHomeManager) {
        guard let home = manager.primaryHome else {
            // no configured home — offer to create or add accessories
            return
        }
        listAccessories(in: home)
    }

    func listAccessories(in home: HMHome) {
        for accessory in home.accessories {
            print("Accessory: \(accessory.name)")
            for service in accessory.services {
                print("  Service: \(service.serviceType)")
                for characteristic in service.characteristics {
                    print("    Characteristic: \(characteristic.characteristicType)")
                }
            }
        }
    }
}

Info.plist is mandatory: NSHomeKitUsageDescription. Without it — crash on first HMHomeManager access.

Entitlement: com.apple.developer.homekit — requested via Apple Developer Portal. Without it, the application cannot interact with HomeKit even on simulator with virtual accessories.

Reading and Writing Characteristics

func setLightBrightness(_ accessory: HMAccessory, brightness: Int) {
    guard let lightService = accessory.services.first(where: {
        $0.serviceType == HMServiceTypeLightbulb
    }),
    let brightnessChar = lightService.characteristics.first(where: {
        $0.characteristicType == HMCharacteristicTypeBrightness
    }) else { return }

    brightnessChar.writeValue(brightness) { error in
        if let error = error {
            // HMError.communicationFailure — accessory unavailable
            // HMError.operationNotSupported — characteristic is read-only
            print("Write failed: \(error)")
        }
    }
}

func readCurrentTemperature(_ accessory: HMAccessory) {
    guard let thermostat = accessory.services.first(where: {
        $0.serviceType == HMServiceTypeThermostat
    }),
    let tempChar = thermostat.characteristics.first(where: {
        $0.characteristicType == HMCharacteristicTypeCurrentTemperature
    }) else { return }

    tempChar.readValue { error in
        if error == nil {
            let temp = tempChar.value as? Double
            print("Temperature: \(temp ?? 0)°C")
        }
    }
}

Event Subscriptions

func subscribeToLockState(_ lockChar: HMCharacteristic) {
    lockChar.enableNotification(true) { error in
        guard error == nil else { return }
        // now HMAccessoryDelegate receives notifications
    }
}

// HMAccessoryDelegate:
func accessory(_ accessory: HMAccessory,
               service: HMService,
               didUpdateValueFor characteristic: HMCharacteristic) {
    if characteristic.characteristicType == HMCharacteristicTypeCurrentLockMechanismState {
        let isLocked = characteristic.value as? Int == 1
        updateLockUI(isLocked: isLocked)
    }
}

Automations and Triggers

HMTrigger — automation by condition. Two types:

  • HMTimerTrigger — by time
  • HMEventTrigger — by event (door opening, temperature change)
let fireDate = Date().addingTimeInterval(3600)
let timer = HMTimerTrigger(name: "Evening lights", fireDate: fireDate,
                            timeZone: .current, recurrence: nil, recurrenceCalendar: nil)
home.addTrigger(timer) { error in
    guard error == nil else { return }
    // add action set to trigger
}

Accessory Simulator for Development

Apple HomeKit Accessory Simulator (part of Xcode Additional Tools) creates virtual accessories on Mac. Application in iOS simulator sees them via Wi-Fi. This is the only way to develop without real hardware.

Limitation: some scenarios (Bluetooth accessories, Thread devices) don't work fully with simulator — requires real iPhone and certified accessory.

Matter vs HomeKit

Matter (new smart home standard) works via HomeKit as one of the transports on iOS. HMAccessory with Matter profile appears in HomeKit automatically when added via HMHome.addAndSetupAccessories. No separate handling required — HomeKit abstracts the protocol.

Implementation timeframe: 1–2 weeks — accessory management, characteristic read/write, basic automations. Cost calculated individually.