├── .gitignore ├── HomeKitDemo.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── HomeKitDemo ├── AccessoriesViewController.swift ├── AccessoryDetailsViewController.swift ├── AppDelegate.swift ├── Base.lproj │ └── Main.storyboard ├── CharactericsViewController.swift ├── DiscoverAccessoriesViewController.swift ├── DiscoveredAccessoryDetailsViewController.swift ├── HomeKitDemo.entitlements ├── Images.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── LaunchImage.launchimage │ │ └── Contents.json │ ├── first.imageset │ │ ├── Contents.json │ │ ├── first.png │ │ └── first@2x.png │ └── second.imageset │ │ ├── Contents.json │ │ ├── second.png │ │ └── second@2x.png ├── Info.plist ├── PrimaryHomeViewController.swift ├── RoomDetailsViewController.swift ├── RoomsViewController.swift ├── home@2x.png └── hueline@2x.png ├── HomeKitDemoTests ├── HomeKitDemoTests.swift └── Info.plist └── readme.md /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | *.pbxuser 3 | !default.pbxuser 4 | *.mode1v3 5 | !default.mode1v3 6 | *.mode2v3 7 | !default.mode2v3 8 | *.perspectivev3 9 | !default.perspectivev3 10 | xcuserdata 11 | *.xccheckout 12 | *.moved-aside 13 | DerivedData 14 | *.hmap 15 | *.ipa 16 | *.xcuserstate -------------------------------------------------------------------------------- /HomeKitDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 861980CC196BEC0100AFC619 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 861980CB196BEC0100AFC619 /* AppDelegate.swift */; }; 11 | 861980D0196BEC0100AFC619 /* PrimaryHomeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 861980CF196BEC0100AFC619 /* PrimaryHomeViewController.swift */; }; 12 | 861980D3196BEC0100AFC619 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 861980D1196BEC0100AFC619 /* Main.storyboard */; }; 13 | 861980D5196BEC0100AFC619 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 861980D4196BEC0100AFC619 /* Images.xcassets */; }; 14 | 861980E1196BEC0100AFC619 /* HomeKitDemoTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 861980E0196BEC0100AFC619 /* HomeKitDemoTests.swift */; }; 15 | 861980EB196BEC9A00AFC619 /* DiscoverAccessoriesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 861980EA196BEC9A00AFC619 /* DiscoverAccessoriesViewController.swift */; }; 16 | 861980ED196BF9B900AFC619 /* DiscoveredAccessoryDetailsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 861980EC196BF9B900AFC619 /* DiscoveredAccessoryDetailsViewController.swift */; }; 17 | 86825311196FD41D00A71150 /* home@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 86825310196FD41D00A71150 /* home@2x.png */; }; 18 | 86825315196FEB1900A71150 /* hueline@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 86825314196FEB1900A71150 /* hueline@2x.png */; }; 19 | 869BEDC9196D719100E51962 /* CharactericsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 869BEDC8196D719100E51962 /* CharactericsViewController.swift */; }; 20 | 86C0E4AF196C49660069367F /* RoomsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 86C0E4AE196C49660069367F /* RoomsViewController.swift */; }; 21 | 86C0E4B1196C4E640069367F /* RoomDetailsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 86C0E4B0196C4E640069367F /* RoomDetailsViewController.swift */; }; 22 | 86C0E4B3196D33EB0069367F /* HomeKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 86C0E4B2196D33EB0069367F /* HomeKit.framework */; }; 23 | 86C0E4B5196D42910069367F /* AccessoriesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 86C0E4B4196D42910069367F /* AccessoriesViewController.swift */; }; 24 | 86C0E4BA196D48D50069367F /* AccessoryDetailsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 86C0E4B9196D48D50069367F /* AccessoryDetailsViewController.swift */; }; 25 | /* End PBXBuildFile section */ 26 | 27 | /* Begin PBXContainerItemProxy section */ 28 | 861980DB196BEC0100AFC619 /* PBXContainerItemProxy */ = { 29 | isa = PBXContainerItemProxy; 30 | containerPortal = 861980BE196BEC0100AFC619 /* Project object */; 31 | proxyType = 1; 32 | remoteGlobalIDString = 861980C5196BEC0100AFC619; 33 | remoteInfo = HomeKitDemo; 34 | }; 35 | /* End PBXContainerItemProxy section */ 36 | 37 | /* Begin PBXFileReference section */ 38 | 861980C6196BEC0100AFC619 /* HomeKitDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HomeKitDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 39 | 861980CA196BEC0100AFC619 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 40 | 861980CB196BEC0100AFC619 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 41 | 861980CF196BEC0100AFC619 /* PrimaryHomeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrimaryHomeViewController.swift; sourceTree = ""; }; 42 | 861980D2196BEC0100AFC619 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 43 | 861980D4196BEC0100AFC619 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 44 | 861980DA196BEC0100AFC619 /* HomeKitDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = HomeKitDemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 45 | 861980DF196BEC0100AFC619 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 46 | 861980E0196BEC0100AFC619 /* HomeKitDemoTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeKitDemoTests.swift; sourceTree = ""; }; 47 | 861980EA196BEC9A00AFC619 /* DiscoverAccessoriesViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiscoverAccessoriesViewController.swift; sourceTree = ""; }; 48 | 861980EC196BF9B900AFC619 /* DiscoveredAccessoryDetailsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiscoveredAccessoryDetailsViewController.swift; sourceTree = ""; }; 49 | 8682530E196E75C200A71150 /* HomeKitDemo.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = HomeKitDemo.entitlements; sourceTree = ""; }; 50 | 86825310196FD41D00A71150 /* home@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "home@2x.png"; sourceTree = ""; }; 51 | 86825314196FEB1900A71150 /* hueline@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "hueline@2x.png"; sourceTree = ""; }; 52 | 869BEDC8196D719100E51962 /* CharactericsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CharactericsViewController.swift; sourceTree = ""; }; 53 | 86C0E4AE196C49660069367F /* RoomsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RoomsViewController.swift; sourceTree = ""; }; 54 | 86C0E4B0196C4E640069367F /* RoomDetailsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RoomDetailsViewController.swift; sourceTree = ""; }; 55 | 86C0E4B2196D33EB0069367F /* HomeKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = HomeKit.framework; path = System/Library/Frameworks/HomeKit.framework; sourceTree = SDKROOT; }; 56 | 86C0E4B4196D42910069367F /* AccessoriesViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AccessoriesViewController.swift; sourceTree = ""; }; 57 | 86C0E4B9196D48D50069367F /* AccessoryDetailsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AccessoryDetailsViewController.swift; sourceTree = ""; }; 58 | /* End PBXFileReference section */ 59 | 60 | /* Begin PBXFrameworksBuildPhase section */ 61 | 861980C3196BEC0100AFC619 /* Frameworks */ = { 62 | isa = PBXFrameworksBuildPhase; 63 | buildActionMask = 2147483647; 64 | files = ( 65 | 86C0E4B3196D33EB0069367F /* HomeKit.framework in Frameworks */, 66 | ); 67 | runOnlyForDeploymentPostprocessing = 0; 68 | }; 69 | 861980D7196BEC0100AFC619 /* Frameworks */ = { 70 | isa = PBXFrameworksBuildPhase; 71 | buildActionMask = 2147483647; 72 | files = ( 73 | ); 74 | runOnlyForDeploymentPostprocessing = 0; 75 | }; 76 | /* End PBXFrameworksBuildPhase section */ 77 | 78 | /* Begin PBXGroup section */ 79 | 861980BD196BEC0100AFC619 = { 80 | isa = PBXGroup; 81 | children = ( 82 | 86C0E4B2196D33EB0069367F /* HomeKit.framework */, 83 | 861980C8196BEC0100AFC619 /* HomeKitDemo */, 84 | 861980DD196BEC0100AFC619 /* HomeKitDemoTests */, 85 | 861980C7196BEC0100AFC619 /* Products */, 86 | ); 87 | sourceTree = ""; 88 | }; 89 | 861980C7196BEC0100AFC619 /* Products */ = { 90 | isa = PBXGroup; 91 | children = ( 92 | 861980C6196BEC0100AFC619 /* HomeKitDemo.app */, 93 | 861980DA196BEC0100AFC619 /* HomeKitDemoTests.xctest */, 94 | ); 95 | name = Products; 96 | sourceTree = ""; 97 | }; 98 | 861980C8196BEC0100AFC619 /* HomeKitDemo */ = { 99 | isa = PBXGroup; 100 | children = ( 101 | 8682530E196E75C200A71150 /* HomeKitDemo.entitlements */, 102 | 861980CB196BEC0100AFC619 /* AppDelegate.swift */, 103 | 8682530F196E7D2B00A71150 /* primaryHome */, 104 | 86C0E4B6196D42C60069367F /* rooms */, 105 | 86C0E4B8196D42D70069367F /* accessories */, 106 | 861980D1196BEC0100AFC619 /* Main.storyboard */, 107 | 86C0E4B7196D42CE0069367F /* new-accessories */, 108 | 861980D4196BEC0100AFC619 /* Images.xcassets */, 109 | 861980C9196BEC0100AFC619 /* Supporting Files */, 110 | ); 111 | path = HomeKitDemo; 112 | sourceTree = ""; 113 | }; 114 | 861980C9196BEC0100AFC619 /* Supporting Files */ = { 115 | isa = PBXGroup; 116 | children = ( 117 | 86825314196FEB1900A71150 /* hueline@2x.png */, 118 | 86825310196FD41D00A71150 /* home@2x.png */, 119 | 861980CA196BEC0100AFC619 /* Info.plist */, 120 | ); 121 | name = "Supporting Files"; 122 | sourceTree = ""; 123 | }; 124 | 861980DD196BEC0100AFC619 /* HomeKitDemoTests */ = { 125 | isa = PBXGroup; 126 | children = ( 127 | 861980E0196BEC0100AFC619 /* HomeKitDemoTests.swift */, 128 | 861980DE196BEC0100AFC619 /* Supporting Files */, 129 | ); 130 | path = HomeKitDemoTests; 131 | sourceTree = ""; 132 | }; 133 | 861980DE196BEC0100AFC619 /* Supporting Files */ = { 134 | isa = PBXGroup; 135 | children = ( 136 | 861980DF196BEC0100AFC619 /* Info.plist */, 137 | ); 138 | name = "Supporting Files"; 139 | sourceTree = ""; 140 | }; 141 | 8682530F196E7D2B00A71150 /* primaryHome */ = { 142 | isa = PBXGroup; 143 | children = ( 144 | 861980CF196BEC0100AFC619 /* PrimaryHomeViewController.swift */, 145 | ); 146 | name = primaryHome; 147 | sourceTree = ""; 148 | }; 149 | 86C0E4B6196D42C60069367F /* rooms */ = { 150 | isa = PBXGroup; 151 | children = ( 152 | 86C0E4AE196C49660069367F /* RoomsViewController.swift */, 153 | 86C0E4B0196C4E640069367F /* RoomDetailsViewController.swift */, 154 | ); 155 | name = rooms; 156 | sourceTree = ""; 157 | }; 158 | 86C0E4B7196D42CE0069367F /* new-accessories */ = { 159 | isa = PBXGroup; 160 | children = ( 161 | 861980EA196BEC9A00AFC619 /* DiscoverAccessoriesViewController.swift */, 162 | 861980EC196BF9B900AFC619 /* DiscoveredAccessoryDetailsViewController.swift */, 163 | ); 164 | name = "new-accessories"; 165 | sourceTree = ""; 166 | }; 167 | 86C0E4B8196D42D70069367F /* accessories */ = { 168 | isa = PBXGroup; 169 | children = ( 170 | 86C0E4B4196D42910069367F /* AccessoriesViewController.swift */, 171 | 86C0E4B9196D48D50069367F /* AccessoryDetailsViewController.swift */, 172 | 869BEDC8196D719100E51962 /* CharactericsViewController.swift */, 173 | ); 174 | name = accessories; 175 | sourceTree = ""; 176 | }; 177 | /* End PBXGroup section */ 178 | 179 | /* Begin PBXNativeTarget section */ 180 | 861980C5196BEC0100AFC619 /* HomeKitDemo */ = { 181 | isa = PBXNativeTarget; 182 | buildConfigurationList = 861980E4196BEC0100AFC619 /* Build configuration list for PBXNativeTarget "HomeKitDemo" */; 183 | buildPhases = ( 184 | 861980C2196BEC0100AFC619 /* Sources */, 185 | 861980C3196BEC0100AFC619 /* Frameworks */, 186 | 861980C4196BEC0100AFC619 /* Resources */, 187 | ); 188 | buildRules = ( 189 | ); 190 | dependencies = ( 191 | ); 192 | name = HomeKitDemo; 193 | productName = HomeKitDemo; 194 | productReference = 861980C6196BEC0100AFC619 /* HomeKitDemo.app */; 195 | productType = "com.apple.product-type.application"; 196 | }; 197 | 861980D9196BEC0100AFC619 /* HomeKitDemoTests */ = { 198 | isa = PBXNativeTarget; 199 | buildConfigurationList = 861980E7196BEC0100AFC619 /* Build configuration list for PBXNativeTarget "HomeKitDemoTests" */; 200 | buildPhases = ( 201 | 861980D6196BEC0100AFC619 /* Sources */, 202 | 861980D7196BEC0100AFC619 /* Frameworks */, 203 | 861980D8196BEC0100AFC619 /* Resources */, 204 | ); 205 | buildRules = ( 206 | ); 207 | dependencies = ( 208 | 861980DC196BEC0100AFC619 /* PBXTargetDependency */, 209 | ); 210 | name = HomeKitDemoTests; 211 | productName = HomeKitDemoTests; 212 | productReference = 861980DA196BEC0100AFC619 /* HomeKitDemoTests.xctest */; 213 | productType = "com.apple.product-type.bundle.unit-test"; 214 | }; 215 | /* End PBXNativeTarget section */ 216 | 217 | /* Begin PBXProject section */ 218 | 861980BE196BEC0100AFC619 /* Project object */ = { 219 | isa = PBXProject; 220 | attributes = { 221 | LastUpgradeCheck = 0600; 222 | ORGANIZATIONNAME = "Marcel Falliere"; 223 | TargetAttributes = { 224 | 861980C5196BEC0100AFC619 = { 225 | CreatedOnToolsVersion = 6.0; 226 | DevelopmentTeam = 4923C4JVFN; 227 | }; 228 | 861980D9196BEC0100AFC619 = { 229 | CreatedOnToolsVersion = 6.0; 230 | TestTargetID = 861980C5196BEC0100AFC619; 231 | }; 232 | }; 233 | }; 234 | buildConfigurationList = 861980C1196BEC0100AFC619 /* Build configuration list for PBXProject "HomeKitDemo" */; 235 | compatibilityVersion = "Xcode 3.2"; 236 | developmentRegion = English; 237 | hasScannedForEncodings = 0; 238 | knownRegions = ( 239 | en, 240 | Base, 241 | ); 242 | mainGroup = 861980BD196BEC0100AFC619; 243 | productRefGroup = 861980C7196BEC0100AFC619 /* Products */; 244 | projectDirPath = ""; 245 | projectRoot = ""; 246 | targets = ( 247 | 861980C5196BEC0100AFC619 /* HomeKitDemo */, 248 | 861980D9196BEC0100AFC619 /* HomeKitDemoTests */, 249 | ); 250 | }; 251 | /* End PBXProject section */ 252 | 253 | /* Begin PBXResourcesBuildPhase section */ 254 | 861980C4196BEC0100AFC619 /* Resources */ = { 255 | isa = PBXResourcesBuildPhase; 256 | buildActionMask = 2147483647; 257 | files = ( 258 | 861980D3196BEC0100AFC619 /* Main.storyboard in Resources */, 259 | 86825315196FEB1900A71150 /* hueline@2x.png in Resources */, 260 | 861980D5196BEC0100AFC619 /* Images.xcassets in Resources */, 261 | 86825311196FD41D00A71150 /* home@2x.png in Resources */, 262 | ); 263 | runOnlyForDeploymentPostprocessing = 0; 264 | }; 265 | 861980D8196BEC0100AFC619 /* Resources */ = { 266 | isa = PBXResourcesBuildPhase; 267 | buildActionMask = 2147483647; 268 | files = ( 269 | ); 270 | runOnlyForDeploymentPostprocessing = 0; 271 | }; 272 | /* End PBXResourcesBuildPhase section */ 273 | 274 | /* Begin PBXSourcesBuildPhase section */ 275 | 861980C2196BEC0100AFC619 /* Sources */ = { 276 | isa = PBXSourcesBuildPhase; 277 | buildActionMask = 2147483647; 278 | files = ( 279 | 861980ED196BF9B900AFC619 /* DiscoveredAccessoryDetailsViewController.swift in Sources */, 280 | 861980EB196BEC9A00AFC619 /* DiscoverAccessoriesViewController.swift in Sources */, 281 | 86C0E4B1196C4E640069367F /* RoomDetailsViewController.swift in Sources */, 282 | 86C0E4AF196C49660069367F /* RoomsViewController.swift in Sources */, 283 | 869BEDC9196D719100E51962 /* CharactericsViewController.swift in Sources */, 284 | 86C0E4BA196D48D50069367F /* AccessoryDetailsViewController.swift in Sources */, 285 | 861980D0196BEC0100AFC619 /* PrimaryHomeViewController.swift in Sources */, 286 | 861980CC196BEC0100AFC619 /* AppDelegate.swift in Sources */, 287 | 86C0E4B5196D42910069367F /* AccessoriesViewController.swift in Sources */, 288 | ); 289 | runOnlyForDeploymentPostprocessing = 0; 290 | }; 291 | 861980D6196BEC0100AFC619 /* Sources */ = { 292 | isa = PBXSourcesBuildPhase; 293 | buildActionMask = 2147483647; 294 | files = ( 295 | 861980E1196BEC0100AFC619 /* HomeKitDemoTests.swift in Sources */, 296 | ); 297 | runOnlyForDeploymentPostprocessing = 0; 298 | }; 299 | /* End PBXSourcesBuildPhase section */ 300 | 301 | /* Begin PBXTargetDependency section */ 302 | 861980DC196BEC0100AFC619 /* PBXTargetDependency */ = { 303 | isa = PBXTargetDependency; 304 | target = 861980C5196BEC0100AFC619 /* HomeKitDemo */; 305 | targetProxy = 861980DB196BEC0100AFC619 /* PBXContainerItemProxy */; 306 | }; 307 | /* End PBXTargetDependency section */ 308 | 309 | /* Begin PBXVariantGroup section */ 310 | 861980D1196BEC0100AFC619 /* Main.storyboard */ = { 311 | isa = PBXVariantGroup; 312 | children = ( 313 | 861980D2196BEC0100AFC619 /* Base */, 314 | ); 315 | name = Main.storyboard; 316 | sourceTree = ""; 317 | }; 318 | /* End PBXVariantGroup section */ 319 | 320 | /* Begin XCBuildConfiguration section */ 321 | 861980E2196BEC0100AFC619 /* Debug */ = { 322 | isa = XCBuildConfiguration; 323 | buildSettings = { 324 | ALWAYS_SEARCH_USER_PATHS = NO; 325 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 326 | CLANG_CXX_LIBRARY = "libc++"; 327 | CLANG_ENABLE_MODULES = YES; 328 | CLANG_ENABLE_OBJC_ARC = YES; 329 | CLANG_WARN_BOOL_CONVERSION = YES; 330 | CLANG_WARN_CONSTANT_CONVERSION = YES; 331 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 332 | CLANG_WARN_EMPTY_BODY = YES; 333 | CLANG_WARN_ENUM_CONVERSION = YES; 334 | CLANG_WARN_INT_CONVERSION = YES; 335 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 336 | CLANG_WARN_UNREACHABLE_CODE = YES; 337 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 338 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 339 | COPY_PHASE_STRIP = NO; 340 | ENABLE_STRICT_OBJC_MSGSEND = YES; 341 | GCC_C_LANGUAGE_STANDARD = gnu99; 342 | GCC_DYNAMIC_NO_PIC = NO; 343 | GCC_OPTIMIZATION_LEVEL = 0; 344 | GCC_PREPROCESSOR_DEFINITIONS = ( 345 | "DEBUG=1", 346 | "$(inherited)", 347 | ); 348 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 349 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 350 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 351 | GCC_WARN_UNDECLARED_SELECTOR = YES; 352 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 353 | GCC_WARN_UNUSED_FUNCTION = YES; 354 | GCC_WARN_UNUSED_VARIABLE = YES; 355 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 356 | MTL_ENABLE_DEBUG_INFO = YES; 357 | ONLY_ACTIVE_ARCH = YES; 358 | SDKROOT = iphoneos; 359 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 360 | }; 361 | name = Debug; 362 | }; 363 | 861980E3196BEC0100AFC619 /* Release */ = { 364 | isa = XCBuildConfiguration; 365 | buildSettings = { 366 | ALWAYS_SEARCH_USER_PATHS = NO; 367 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 368 | CLANG_CXX_LIBRARY = "libc++"; 369 | CLANG_ENABLE_MODULES = YES; 370 | CLANG_ENABLE_OBJC_ARC = YES; 371 | CLANG_WARN_BOOL_CONVERSION = YES; 372 | CLANG_WARN_CONSTANT_CONVERSION = YES; 373 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 374 | CLANG_WARN_EMPTY_BODY = YES; 375 | CLANG_WARN_ENUM_CONVERSION = YES; 376 | CLANG_WARN_INT_CONVERSION = YES; 377 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 378 | CLANG_WARN_UNREACHABLE_CODE = YES; 379 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 380 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 381 | COPY_PHASE_STRIP = YES; 382 | ENABLE_NS_ASSERTIONS = NO; 383 | ENABLE_STRICT_OBJC_MSGSEND = YES; 384 | GCC_C_LANGUAGE_STANDARD = gnu99; 385 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 386 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 387 | GCC_WARN_UNDECLARED_SELECTOR = YES; 388 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 389 | GCC_WARN_UNUSED_FUNCTION = YES; 390 | GCC_WARN_UNUSED_VARIABLE = YES; 391 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 392 | MTL_ENABLE_DEBUG_INFO = NO; 393 | SDKROOT = iphoneos; 394 | VALIDATE_PRODUCT = YES; 395 | }; 396 | name = Release; 397 | }; 398 | 861980E5196BEC0100AFC619 /* Debug */ = { 399 | isa = XCBuildConfiguration; 400 | buildSettings = { 401 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 402 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 403 | CODE_SIGN_ENTITLEMENTS = HomeKitDemo/HomeKitDemo.entitlements; 404 | CODE_SIGN_IDENTITY = "iPhone Developer"; 405 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 406 | INFOPLIST_FILE = HomeKitDemo/Info.plist; 407 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 408 | PRODUCT_NAME = "$(TARGET_NAME)"; 409 | PROVISIONING_PROFILE = ""; 410 | }; 411 | name = Debug; 412 | }; 413 | 861980E6196BEC0100AFC619 /* Release */ = { 414 | isa = XCBuildConfiguration; 415 | buildSettings = { 416 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 417 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 418 | CODE_SIGN_ENTITLEMENTS = HomeKitDemo/HomeKitDemo.entitlements; 419 | CODE_SIGN_IDENTITY = "iPhone Developer"; 420 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 421 | INFOPLIST_FILE = HomeKitDemo/Info.plist; 422 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 423 | PRODUCT_NAME = "$(TARGET_NAME)"; 424 | PROVISIONING_PROFILE = ""; 425 | }; 426 | name = Release; 427 | }; 428 | 861980E8196BEC0100AFC619 /* Debug */ = { 429 | isa = XCBuildConfiguration; 430 | buildSettings = { 431 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/HomeKitDemo.app/HomeKitDemo"; 432 | FRAMEWORK_SEARCH_PATHS = ( 433 | "$(SDKROOT)/Developer/Library/Frameworks", 434 | "$(inherited)", 435 | ); 436 | GCC_PREPROCESSOR_DEFINITIONS = ( 437 | "DEBUG=1", 438 | "$(inherited)", 439 | ); 440 | INFOPLIST_FILE = HomeKitDemoTests/Info.plist; 441 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 442 | PRODUCT_NAME = "$(TARGET_NAME)"; 443 | TEST_HOST = "$(BUNDLE_LOADER)"; 444 | }; 445 | name = Debug; 446 | }; 447 | 861980E9196BEC0100AFC619 /* Release */ = { 448 | isa = XCBuildConfiguration; 449 | buildSettings = { 450 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/HomeKitDemo.app/HomeKitDemo"; 451 | FRAMEWORK_SEARCH_PATHS = ( 452 | "$(SDKROOT)/Developer/Library/Frameworks", 453 | "$(inherited)", 454 | ); 455 | INFOPLIST_FILE = HomeKitDemoTests/Info.plist; 456 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 457 | PRODUCT_NAME = "$(TARGET_NAME)"; 458 | TEST_HOST = "$(BUNDLE_LOADER)"; 459 | }; 460 | name = Release; 461 | }; 462 | /* End XCBuildConfiguration section */ 463 | 464 | /* Begin XCConfigurationList section */ 465 | 861980C1196BEC0100AFC619 /* Build configuration list for PBXProject "HomeKitDemo" */ = { 466 | isa = XCConfigurationList; 467 | buildConfigurations = ( 468 | 861980E2196BEC0100AFC619 /* Debug */, 469 | 861980E3196BEC0100AFC619 /* Release */, 470 | ); 471 | defaultConfigurationIsVisible = 0; 472 | defaultConfigurationName = Release; 473 | }; 474 | 861980E4196BEC0100AFC619 /* Build configuration list for PBXNativeTarget "HomeKitDemo" */ = { 475 | isa = XCConfigurationList; 476 | buildConfigurations = ( 477 | 861980E5196BEC0100AFC619 /* Debug */, 478 | 861980E6196BEC0100AFC619 /* Release */, 479 | ); 480 | defaultConfigurationIsVisible = 0; 481 | defaultConfigurationName = Release; 482 | }; 483 | 861980E7196BEC0100AFC619 /* Build configuration list for PBXNativeTarget "HomeKitDemoTests" */ = { 484 | isa = XCConfigurationList; 485 | buildConfigurations = ( 486 | 861980E8196BEC0100AFC619 /* Debug */, 487 | 861980E9196BEC0100AFC619 /* Release */, 488 | ); 489 | defaultConfigurationIsVisible = 0; 490 | defaultConfigurationName = Release; 491 | }; 492 | /* End XCConfigurationList section */ 493 | }; 494 | rootObject = 861980BE196BEC0100AFC619 /* Project object */; 495 | } 496 | -------------------------------------------------------------------------------- /HomeKitDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /HomeKitDemo/AccessoriesViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AccessoriesViewController.swift 3 | // HomeKitDemo 4 | // 5 | // Created by Frédéric Falliere on 09/07/2014. 6 | // Copyright (c) 2014 Marcel Falliere. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import HomeKit 11 | 12 | class AccessoriesViewController : UITableViewController, UITableViewDataSource, UITableViewDelegate { 13 | 14 | var home :HMHome? 15 | 16 | override func viewWillAppear(animated: Bool) { 17 | title = "Accessories" 18 | self.tableView.reloadData() 19 | } 20 | 21 | 22 | override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) { 23 | if segue.identifier == "details" { 24 | if let dest = segue.destinationViewController as? AccessoryDetailsViewController { 25 | dest.accessory = sender as? HMAccessory 26 | dest.home = self.home 27 | } 28 | 29 | } 30 | } 31 | 32 | } 33 | 34 | 35 | // pragma mark UITableViewDataSource, UITableViewDelegate 36 | 37 | extension AccessoriesViewController { 38 | 39 | override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int 40 | { 41 | if let accessories = home?.accessories { 42 | return accessories.count 43 | } 44 | return 0 45 | } 46 | 47 | override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell 48 | { 49 | let cell:UITableViewCell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as UITableViewCell 50 | if let accessories = home?.accessories { 51 | 52 | let accessory = accessories[indexPath.row] as HMAccessory 53 | 54 | cell.textLabel?.text = accessory.name 55 | cell.detailTextLabel?.text = "\(accessory.room.name)" 56 | 57 | } 58 | 59 | return cell 60 | } 61 | 62 | override func tableView(tableView: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath) { 63 | performSegueWithIdentifier("details", sender: home?.accessories[indexPath.row]) 64 | } 65 | 66 | 67 | 68 | } -------------------------------------------------------------------------------- /HomeKitDemo/AccessoryDetailsViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AccessoryDetailViewController.swift 3 | // HomeKitDemo 4 | // 5 | // Created by Frédéric Falliere on 09/07/2014. 6 | // Copyright (c) 2014 Marcel Falliere. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import HomeKit 11 | 12 | class AccessoryDetailsViewController : UIViewController, UITableViewDelegate, UITableViewDataSource, HMAccessoryDelegate { 13 | 14 | @IBOutlet var accessoryName :UILabel? 15 | 16 | @IBOutlet var roomName :UILabel? 17 | 18 | @IBOutlet var reachable :UILabel? 19 | 20 | @IBOutlet var tableView :UITableView? 21 | 22 | var accessory :HMAccessory? 23 | var home :HMHome? 24 | 25 | override func viewWillAppear(animated: Bool) { 26 | title = accessory?.name; 27 | 28 | render() 29 | 30 | if let mAccessory = self.accessory { 31 | mAccessory.delegate = self 32 | } 33 | } 34 | 35 | @IBAction func changeName(sender: AnyObject!) { 36 | var alert = UIAlertController(title: "Change name", message: "Input a new name for this accessory", preferredStyle: UIAlertControllerStyle.Alert) 37 | let action = UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default, handler: ({(alertAction: UIAlertAction!) in 38 | 39 | if let textFields:[AnyObject]! = alert.textFields as [AnyObject]! { 40 | 41 | for textField in textFields { 42 | if let input = textField as? UITextField { 43 | if input.tag == 1 { 44 | self.accessory?.updateName(input.text, completionHandler:({(error:NSError!) in 45 | if (error != nil) { 46 | NSLog("error updating acccessory name. error:\(error)") 47 | } else { 48 | NSLog("name update !") 49 | self.render() 50 | } 51 | })) 52 | } 53 | } 54 | } 55 | 56 | } 57 | 58 | })) 59 | alert.addAction(action) 60 | alert.addTextFieldWithConfigurationHandler({(textField: UITextField!) in 61 | textField.placeholder = "Accessory name" 62 | textField.secureTextEntry = false 63 | textField.tag = 1 64 | }) 65 | self.presentViewController(alert, animated: true, completion: nil) 66 | } 67 | 68 | func render() { 69 | NSLog("render !") 70 | 71 | accessoryName?.text = accessory?.name 72 | roomName?.text = accessory?.room.name 73 | reachable?.text = accessory?.reachable == true ? "Reachable !" : "Accessory not reachable" 74 | } 75 | 76 | 77 | override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) { 78 | if segue.identifier == "characteristics" { 79 | if let dest = segue.destinationViewController as? CharacteristicsViewController { 80 | dest.service = sender as? HMService 81 | } 82 | 83 | } else if segue.identifier == "pickRoom" { 84 | if let dest = segue.destinationViewController as? RoomsViewController { 85 | dest.home = self.home 86 | dest.pickerMode = true 87 | dest.accessoryViewController = self 88 | } 89 | 90 | } 91 | } 92 | 93 | 94 | func setPickedRoom(room: HMRoom) { 95 | NSLog("room has been picked") 96 | 97 | 98 | home?.assignAccessory(accessory, toRoom: room, completionHandler: ({(error:NSError!) in 99 | if (error != nil) { 100 | var popup = UIAlertView(title:"Error", message:"Error when assigning the accessory to the picked room (error is : \(error)", delegate: nil, cancelButtonTitle:"Ok :(") 101 | popup.show() 102 | } else { 103 | var popup = UIAlertView(title:"Ok", message:"Accessory added to room \(room.name) with success!", delegate: nil, cancelButtonTitle:"Ok") 104 | popup.show() 105 | 106 | } 107 | })) 108 | 109 | } 110 | 111 | 112 | } 113 | 114 | 115 | // pragma mark HMAccessoryDelegate 116 | extension AccessoryDetailsViewController { 117 | 118 | func accessoryDidUpdateName(accessory: HMAccessory!) { 119 | render() 120 | } 121 | 122 | func accessoryDidUpdateReachability(accessory: HMAccessory!) { 123 | render() 124 | } 125 | 126 | func accessoryDidUpdateServices(accessory: HMAccessory!) { 127 | tableView?.reloadData() 128 | } 129 | 130 | 131 | } 132 | 133 | 134 | // pragma mark UITableViewDataSource, UITableViewDelegate 135 | 136 | extension AccessoryDetailsViewController { 137 | 138 | func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int 139 | { 140 | if let services = accessory?.services { 141 | return services.count 142 | } 143 | return 0 144 | } 145 | 146 | func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell 147 | { 148 | let cell:UITableViewCell = tableView.dequeueReusableCellWithIdentifier("service-cell", forIndexPath: indexPath) as UITableViewCell 149 | 150 | if let services = accessory?.services { 151 | 152 | let service = services[indexPath.row] as HMService 153 | 154 | cell.textLabel?.text = "\(service.name)" 155 | cell.detailTextLabel?.text = "\(service.characteristics.count) characteristics" 156 | 157 | } 158 | 159 | return cell 160 | } 161 | 162 | func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { 163 | performSegueWithIdentifier("characteristics", sender: accessory?.services[indexPath.row]) 164 | 165 | } 166 | 167 | 168 | } -------------------------------------------------------------------------------- /HomeKitDemo/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // HomeKitDemo 4 | // 5 | // Created by Frédéric Falliere on 08/07/2014. 6 | // Copyright (c) 2014 Marcel Falliere. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(application: UIApplication!, didFinishLaunchingWithOptions launchOptions: NSDictionary!) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(application: UIApplication!) { 23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(application: UIApplication!) { 28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(application: UIApplication!) { 33 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(application: UIApplication!) { 37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 38 | } 39 | 40 | func applicationWillTerminate(application: UIApplication!) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /HomeKitDemo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 64 | 70 | 76 | 82 | 88 | 94 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 143 | 149 | 155 | 161 | 170 | 179 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 232 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 275 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 316 | 322 | 328 | 334 | 340 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 365 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 389 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 435 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 458 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | 537 | 538 | 539 | 540 | 541 | 542 | 543 | 544 | 545 | 546 | 547 | 548 | 549 | 550 | 551 | 552 | 553 | 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | -------------------------------------------------------------------------------- /HomeKitDemo/CharactericsViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CharactericsViewController.swift 3 | // HomeKitDemo 4 | // 5 | // Created by Frédéric Falliere on 09/07/2014. 6 | // Copyright (c) 2014 Marcel Falliere. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import HomeKit 11 | 12 | class CharacteristicsViewController : UITableViewController, UITableViewDelegate, UITableViewDataSource { 13 | 14 | 15 | var service :HMService? 16 | 17 | override func viewWillAppear(animated: Bool) { 18 | title = service?.name 19 | 20 | var i = 0 21 | while i < service?.characteristics.count { 22 | let ch :HMCharacteristic = self.service?.characteristics[i] as HMCharacteristic 23 | NSLog("charact type : \(ch.characteristicType) ; value->\(ch.value)") 24 | i++ 25 | } 26 | } 27 | } 28 | 29 | extension CharacteristicsViewController { 30 | override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int 31 | { 32 | if let characteristics = service?.characteristics { 33 | NSLog("rows : \(characteristics.count)") 34 | return characteristics.count 35 | } 36 | return 0 37 | } 38 | 39 | override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell 40 | { 41 | let ch :HMCharacteristic = self.service?.characteristics[indexPath.row] as HMCharacteristic 42 | 43 | if ch.characteristicType == HMCharacteristicTypePowerState { 44 | let cell:UITableViewCell = tableView.dequeueReusableCellWithIdentifier("public.hap.characteristic.on", forIndexPath: indexPath) as UITableViewCell 45 | 46 | // ... 47 | 48 | let button:UIButton = cell.viewWithTag(10) as UIButton 49 | button.addTarget(self, action:"cellButtonTapped:", forControlEvents:UIControlEvents.TouchUpInside) 50 | 51 | return cell 52 | 53 | } else if ch.characteristicType == HMCharacteristicTypeSaturation || ch.characteristicType == HMCharacteristicTypeBrightness { 54 | 55 | let cell:UITableViewCell = tableView.dequeueReusableCellWithIdentifier("slider100percent", forIndexPath: indexPath) as UITableViewCell 56 | 57 | let name:UILabel = cell.viewWithTag(10) as UILabel 58 | name.text = ch.characteristicType 59 | let slider:UISlider = cell.viewWithTag(20) as UISlider 60 | slider.addTarget(self, action:"slider100percentValueChanged:", forControlEvents:UIControlEvents.ValueChanged) 61 | 62 | return cell 63 | 64 | 65 | 66 | } else if ch.characteristicType == HMCharacteristicTypeHue { 67 | 68 | let cell:UITableViewCell = tableView.dequeueReusableCellWithIdentifier("hueCell", forIndexPath: indexPath) as UITableViewCell 69 | 70 | let name:UILabel = cell.viewWithTag(10) as UILabel 71 | name.text = ch.characteristicType 72 | let slider:UISlider = cell.viewWithTag(20) as UISlider 73 | slider.addTarget(self, action:"slider100percentValueChanged:", forControlEvents:UIControlEvents.ValueChanged) 74 | 75 | return cell 76 | 77 | } else { 78 | let cell:UITableViewCell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as UITableViewCell 79 | 80 | let name:UILabel = cell.viewWithTag(10) as UILabel 81 | name.text = ch.characteristicType 82 | let value:UILabel = cell.viewWithTag(20) as UILabel 83 | value.text = "\(ch.value)" 84 | 85 | return cell 86 | 87 | } 88 | } 89 | 90 | override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { 91 | return 60; 92 | } 93 | 94 | func cellButtonTapped(sender :AnyObject!) { 95 | let buttonPosition :CGPoint = sender.convertPoint(CGPointZero, toView: self.tableView) 96 | let indexPath :NSIndexPath = self.tableView.indexPathForRowAtPoint(buttonPosition)! 97 | let ch :HMCharacteristic = self.service?.characteristics[indexPath.row] as HMCharacteristic 98 | 99 | if ch.characteristicType == HMCharacteristicTypePowerState { 100 | let value :Bool = ch.value as Bool! 101 | ch.writeValue(!value , completionHandler: ({(error :NSError!) in 102 | NSLog("Ok, error:\(error)") 103 | })) 104 | } 105 | 106 | } 107 | 108 | func slider100percentValueChanged(sender :AnyObject!) { 109 | let buttonPosition :CGPoint = sender.convertPoint(CGPointZero, toView: self.tableView) 110 | let indexPath :NSIndexPath = self.tableView.indexPathForRowAtPoint(buttonPosition)! 111 | let ch :HMCharacteristic = self.service?.characteristics[indexPath.row] as HMCharacteristic 112 | 113 | let slider :UISlider = sender as UISlider 114 | 115 | ch.writeValue(Int(slider.value), completionHandler: ({(error :NSError!) in 116 | NSLog("Ok, error:\(error)") 117 | })) 118 | 119 | } 120 | 121 | 122 | } 123 | -------------------------------------------------------------------------------- /HomeKitDemo/DiscoverAccessoriesViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DiscoverAccessoriesViewController.swift 3 | // HomeKitDemo 4 | // 5 | // Created by Frédéric Falliere on 08/07/2014. 6 | // Copyright (c) 2014 Marcel Falliere. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import HomeKit 11 | 12 | class DiscoverAccessoriesViewController : UITableViewController, UITableViewDataSource,UITableViewDelegate, HMAccessoryBrowserDelegate { 13 | 14 | let accessoryBrowser = HMAccessoryBrowser() 15 | let homeManager = HMHomeManager() 16 | var accessories: [HMAccessory] = [] 17 | 18 | override func viewDidLoad() { 19 | tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "cell") 20 | } 21 | 22 | override func viewDidAppear(animated: Bool) { 23 | accessoryBrowser.delegate = self 24 | accessoryBrowser.startSearchingForNewAccessories() 25 | } 26 | 27 | override func viewDidDisappear(animated: Bool) { 28 | accessoryBrowser.stopSearchingForNewAccessories() 29 | } 30 | 31 | override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) { 32 | /*if let dest = segue.destinationViewController as? AccessoryDetailsViewController { 33 | dest.accessory = sender as HMAccessory 34 | }*/ 35 | 36 | } 37 | 38 | func localAccessoriesContains(discoveredAccessory: HMAccessory!) -> Bool { 39 | for accessory in accessories { 40 | let aid:String = accessory.identifier.UUIDString 41 | let daid:String = discoveredAccessory.identifier.UUIDString 42 | NSLog("comparing \(aid) and \(daid)") 43 | if accessory.identifier.UUIDString == discoveredAccessory.identifier.UUIDString || accessory.name == discoveredAccessory.name { 44 | return true 45 | } 46 | } 47 | return false 48 | } 49 | 50 | func removeFromLocalAccessories(accessoryToRemove: HMAccessory!) { 51 | var indexToRemove = -1 52 | for (index,accessory) in enumerate(accessories) { 53 | if accessory.identifier.UUIDString == accessoryToRemove.identifier.UUIDString || accessory.name == accessoryToRemove.name { 54 | indexToRemove = index 55 | } 56 | } 57 | if indexToRemove >= 0 { 58 | accessories.removeAtIndex(indexToRemove) 59 | } 60 | } 61 | 62 | } 63 | 64 | // pragma mark HMAccessoryBrowserDelegate 65 | 66 | extension DiscoverAccessoriesViewController { 67 | 68 | func accessoryBrowser(browser: HMAccessoryBrowser!, didFindNewAccessory accessory: HMAccessory!) { 69 | if !localAccessoriesContains(accessory) { 70 | accessories.append(accessory); 71 | tableView.reloadData() 72 | NSLog("new accessory found") 73 | }; 74 | 75 | } 76 | 77 | func accessoryBrowser(browser: HMAccessoryBrowser!, didRemoveNewAccessory accessory: HMAccessory!) { 78 | removeFromLocalAccessories(accessory) 79 | tableView.reloadData() 80 | } 81 | 82 | } 83 | 84 | // pragma mark UITableViewDataSource, UITableViewDelegate 85 | 86 | extension DiscoverAccessoriesViewController { 87 | 88 | override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int 89 | { 90 | return accessories.count; 91 | } 92 | 93 | override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 94 | let cell:UITableViewCell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as UITableViewCell 95 | cell.textLabel?.text = accessories[indexPath.row].name 96 | 97 | return cell 98 | } 99 | 100 | override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { 101 | homeManager.primaryHome.addAccessory(accessories[indexPath.row] as HMAccessory, completionHandler: ({(error:NSError!) in 102 | if ( error != nil) { 103 | var popup = UIAlertView(title:"Error", message:"Error when adding accessory to primary home (error is : \(error)", delegate: nil, cancelButtonTitle:"Ok :(") 104 | popup.show() 105 | 106 | NSLog("error: \(error)") 107 | } else { 108 | 109 | var popup = UIAlertView(title:"Success!", message:"Accessory added with success ! Now go to your home and assign it a room", delegate: nil, cancelButtonTitle:"Ok !!!") 110 | popup.show() 111 | 112 | } 113 | })) 114 | } 115 | 116 | } -------------------------------------------------------------------------------- /HomeKitDemo/DiscoveredAccessoryDetailsViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AccessoryDetailsViewController.swift 3 | // HomeKitDemo 4 | // 5 | // Created by Frédéric Falliere on 08/07/2014. 6 | // Copyright (c) 2014 Marcel Falliere. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import HomeKit 11 | 12 | class DiscoveredAccessoryDetailsViewController : UIViewController { 13 | 14 | let homeManager = HMHomeManager() 15 | 16 | var accessory :HMAccessory? 17 | 18 | @IBOutlet var labelName :UILabel? 19 | @IBOutlet var reachable :UILabel? 20 | @IBOutlet var roomName :UILabel? 21 | 22 | override func viewWillAppear(animated: Bool) { 23 | labelName?.text = accessory?.name 24 | 25 | if let room = accessory?.room { 26 | roomName?.text = accessory?.room.name 27 | } else { 28 | roomName?.text = "room not set" 29 | } 30 | 31 | if accessory?.reachable == true { 32 | reachable?.text = "Accessory reachable !" 33 | } else { 34 | reachable?.text = "This accessory is out of range, turned off, etc" 35 | } 36 | 37 | } 38 | 39 | @IBAction func buttonTapped(sender : AnyObject) { 40 | var home = homeManager.primaryHome 41 | if (homeManager.homes.count > 0) { 42 | home = homeManager.homes[0] as HMHome 43 | } 44 | 45 | NSLog("accessory : \(accessory)") 46 | NSLog("home : \(home)") 47 | 48 | if (home != nil) { 49 | home.addAccessory(accessory, completionHandler: ({(error:NSError!) in 50 | if (error != nil) { 51 | var popup = UIAlertView(title:"Error", message:"Error when adding accessory to primary home (error is : \(error)", delegate: nil, cancelButtonTitle:"Ok :(") 52 | popup.show() 53 | 54 | NSLog("error: \(error)") 55 | } else { 56 | 57 | var popup = UIAlertView(title:"Ok", message:"Accessory had been added to your primary home", delegate: nil, cancelButtonTitle:"Ok :(") 58 | popup.show() 59 | } 60 | })) 61 | } else { 62 | let error = UIAlertView(title: "Can't do !", message: "You did not set up your primary home", delegate: nil, cancelButtonTitle:"Ok") 63 | error.show() 64 | 65 | } 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /HomeKitDemo/HomeKitDemo.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.developer.homekit 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /HomeKitDemo/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "40x40", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "60x60", 16 | "scale" : "2x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /HomeKitDemo/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "7.0", 8 | "scale" : "2x" 9 | }, 10 | { 11 | "orientation" : "portrait", 12 | "idiom" : "iphone", 13 | "subtype" : "retina4", 14 | "extent" : "full-screen", 15 | "minimum-system-version" : "7.0", 16 | "scale" : "2x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /HomeKitDemo/Images.xcassets/first.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal" 5 | }, 6 | { 7 | "idiom" : "universal", 8 | "scale" : "1x", 9 | "filename" : "first.png" 10 | }, 11 | { 12 | "idiom" : "universal", 13 | "scale" : "2x", 14 | "filename" : "first@2x.png" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /HomeKitDemo/Images.xcassets/first.imageset/first.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fredericfalliere/HomeKit/d1d09f084b723cd29f93ffdc9e8cc84ddc9fd435/HomeKitDemo/Images.xcassets/first.imageset/first.png -------------------------------------------------------------------------------- /HomeKitDemo/Images.xcassets/first.imageset/first@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fredericfalliere/HomeKit/d1d09f084b723cd29f93ffdc9e8cc84ddc9fd435/HomeKitDemo/Images.xcassets/first.imageset/first@2x.png -------------------------------------------------------------------------------- /HomeKitDemo/Images.xcassets/second.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal" 5 | }, 6 | { 7 | "idiom" : "universal", 8 | "scale" : "1x", 9 | "filename" : "second.png" 10 | }, 11 | { 12 | "idiom" : "universal", 13 | "scale" : "2x", 14 | "filename" : "second@2x.png" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /HomeKitDemo/Images.xcassets/second.imageset/second.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fredericfalliere/HomeKit/d1d09f084b723cd29f93ffdc9e8cc84ddc9fd435/HomeKitDemo/Images.xcassets/second.imageset/second.png -------------------------------------------------------------------------------- /HomeKitDemo/Images.xcassets/second.imageset/second@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fredericfalliere/HomeKit/d1d09f084b723cd29f93ffdc9e8cc84ddc9fd435/HomeKitDemo/Images.xcassets/second.imageset/second@2x.png -------------------------------------------------------------------------------- /HomeKitDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | fr.fmf.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UIStatusBarTintParameters 32 | 33 | UINavigationBar 34 | 35 | Style 36 | UIBarStyleDefault 37 | Translucent 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /HomeKitDemo/PrimaryHomeViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SecondViewController.swift 3 | // HomeKitDemo 4 | // 5 | // Created by Frédéric Falliere on 08/07/2014. 6 | // Copyright (c) 2014 Marcel Falliere. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import HomeKit 11 | 12 | class PrimaryHomeViewController: UIViewController { 13 | 14 | let homeManager = HMHomeManager() 15 | 16 | @IBOutlet var mainHomeName :UILabel? 17 | @IBOutlet var numberOfRooms :UILabel? 18 | @IBOutlet var numberOfAccessories :UILabel? 19 | 20 | @IBOutlet var listOfRoomsButton :UIButton? 21 | @IBOutlet var listOfAccessoriesButton :UIButton? 22 | 23 | override func viewWillAppear(animated: Bool) { 24 | updateUi() 25 | } 26 | 27 | func updateUi() { 28 | NSLog("primary home : \(homeManager.primaryHome) count:\(homeManager.homes.count)") 29 | if ((homeManager.primaryHome) != nil) { 30 | mainHomeName?.text = homeManager.primaryHome.name 31 | 32 | numberOfRooms?.text = "\(homeManager.primaryHome.rooms.count) rooms" 33 | listOfRoomsButton?.enabled = homeManager.primaryHome.rooms.count > 0 34 | 35 | numberOfAccessories?.text = "\(homeManager.primaryHome.accessories.count) accessories" 36 | listOfAccessoriesButton?.enabled = homeManager.primaryHome.accessories.count > 0 37 | } else { 38 | mainHomeName?.text = "n/a" 39 | self.presentPrimaryHomePromp() 40 | } 41 | } 42 | 43 | func setOrUpdatePrimaryHomeName(name:String!) { 44 | NSLog("primary home : \(homeManager.primaryHome)") 45 | if ((homeManager.primaryHome) != nil) { 46 | homeManager.primaryHome.updateName(name, completionHandler:({(error:NSError!) in 47 | if (error != nil) { 48 | NSLog("error updating home: \(error)") 49 | } else { 50 | NSLog("no error, home name updated") 51 | self.updateUi() 52 | } 53 | })) 54 | 55 | } else { 56 | homeManager.addHomeWithName(name, completionHandler:({(home:HMHome!, error:NSError!) in 57 | if (error != nil) { 58 | NSLog("error creating home: \(error)") 59 | } else { 60 | 61 | NSLog("no error, home created") 62 | 63 | self.homeManager.updatePrimaryHome(home, completionHandler:({(error:NSError!) in 64 | NSLog("primary home set ! ") 65 | self.updateUi() 66 | })) 67 | 68 | 69 | 70 | } 71 | })) 72 | } 73 | 74 | } 75 | 76 | func saveNewRoomToPrimaryHome(name:String!) { 77 | homeManager.primaryHome.addRoomWithName(name, completionHandler: ({(room:HMRoom!, error:NSError!) in 78 | if (error != nil) { 79 | NSLog("error creating room: \(error)") 80 | } else { 81 | NSLog("no error, home created") 82 | self.updateUi() 83 | } 84 | })) 85 | 86 | } 87 | 88 | override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) { 89 | if segue.identifier == "rooms" { 90 | if let dest = segue.destinationViewController as? RoomsViewController { 91 | dest.home = homeManager.primaryHome 92 | dest.pickerMode = false 93 | } 94 | } 95 | 96 | if segue.identifier == "accessories" { 97 | if let dest = segue.destinationViewController as? AccessoriesViewController { 98 | dest.home = homeManager.primaryHome 99 | } 100 | } 101 | 102 | } 103 | 104 | func presentPrimaryHomePromp() { 105 | var alert = UIAlertController(title: "Primary Home", message: "Pick a name for your primary home ! (Yes, with iOS8, having a home is as simple as picking a name >.<)", preferredStyle: UIAlertControllerStyle.Alert) 106 | let action = UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default, handler: ({(alertAction: UIAlertAction!) in 107 | 108 | if let textFields:[AnyObject]! = alert.textFields as [AnyObject]! { 109 | 110 | for textField in textFields { 111 | if let input = textField as? UITextField { 112 | if input.tag == 1 { 113 | self.setOrUpdatePrimaryHomeName(input.text) 114 | } 115 | } 116 | } 117 | 118 | } 119 | 120 | 121 | })) 122 | alert.addAction(action) 123 | alert.addTextFieldWithConfigurationHandler({(textField: UITextField!) in 124 | textField.placeholder = "Home name" 125 | textField.secureTextEntry = false 126 | textField.tag = 1 127 | }) 128 | self.presentViewController(alert, animated: true, completion: nil) 129 | } 130 | 131 | 132 | @IBAction func changeName(sender : AnyObject) { 133 | presentPrimaryHomePromp() 134 | } 135 | 136 | @IBAction func addRoom(sender : AnyObject) { 137 | var alert = UIAlertController(title: "Add a room", message: "Pick a name for yournew room.", preferredStyle: UIAlertControllerStyle.Alert) 138 | let action = UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default, handler: ({(alertAction: UIAlertAction!) in 139 | 140 | 141 | if let textFields:[AnyObject]! = alert.textFields as [AnyObject]! { 142 | 143 | for textField in textFields { 144 | if let input = textField as? UITextField { 145 | if input.tag == 1 { 146 | self.saveNewRoomToPrimaryHome(input.text) 147 | 148 | } 149 | } 150 | } 151 | 152 | } 153 | 154 | 155 | })) 156 | alert.addAction(action) 157 | alert.addTextFieldWithConfigurationHandler({(textField: UITextField!) in 158 | textField.placeholder = "Room name" 159 | textField.secureTextEntry = false 160 | textField.tag = 1 161 | }) 162 | self.presentViewController(alert, animated: true, completion: nil) 163 | } 164 | 165 | } 166 | 167 | -------------------------------------------------------------------------------- /HomeKitDemo/RoomDetailsViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RoomDetailsViewController.swift 3 | // HomeKitDemo 4 | // 5 | // Created by Frédéric Falliere on 08/07/2014. 6 | // Copyright (c) 2014 Marcel Falliere. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import HomeKit 11 | 12 | class RoomDetailsViewController : UITableViewController, UITableViewDelegate, UITableViewDataSource { 13 | 14 | @IBOutlet var mainHomeName :UILabel? 15 | 16 | var room :HMRoom? 17 | var home :HMHome? 18 | 19 | override func viewDidLoad() { 20 | tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "cell") 21 | } 22 | 23 | override func viewWillAppear(animated: Bool) { 24 | title = room?.name 25 | } 26 | 27 | override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) { 28 | if segue.identifier == "details" { 29 | 30 | if let dest = segue.destinationViewController as? AccessoryDetailsViewController { 31 | dest.accessory = sender as? HMAccessory 32 | dest.home = home 33 | } 34 | 35 | } 36 | } 37 | 38 | } 39 | 40 | 41 | 42 | // pragma mark UITableViewDataSource, UITableViewDelegate 43 | 44 | extension RoomDetailsViewController { 45 | 46 | override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int 47 | { 48 | if let accessories = room?.accessories { 49 | return accessories.count 50 | } 51 | return 0 52 | } 53 | 54 | override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell 55 | { 56 | let cell:UITableViewCell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as UITableViewCell 57 | if let accessories = room?.accessories { 58 | 59 | let accessory = accessories[indexPath.row] as HMAccessory 60 | 61 | cell.textLabel?.text = accessory.name 62 | } 63 | 64 | return cell 65 | } 66 | 67 | 68 | override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { 69 | performSegueWithIdentifier("details", sender: room?.accessories[indexPath.row]) 70 | } 71 | 72 | } -------------------------------------------------------------------------------- /HomeKitDemo/RoomsViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RoomsViewController.swift 3 | // HomeKitDemo 4 | // 5 | // Created by Frédéric Falliere on 08/07/2014. 6 | // Copyright (c) 2014 Marcel Falliere. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import HomeKit 11 | 12 | class RoomsViewController : UITableViewController, UITableViewDataSource, UITableViewDelegate { 13 | 14 | var home :HMHome? 15 | var pickerMode = false 16 | var accessoryViewController :AccessoryDetailsViewController? 17 | 18 | 19 | override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) { 20 | if let dest = segue.destinationViewController as? RoomDetailsViewController { 21 | dest.room = sender as? HMRoom 22 | dest.home = home 23 | } 24 | } 25 | } 26 | 27 | 28 | // pragma mark UITableViewDataSource, UITableViewDelegate 29 | 30 | extension RoomsViewController { 31 | 32 | override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int 33 | { 34 | if let rooms = home?.rooms { 35 | return rooms.count 36 | } 37 | return 0 38 | } 39 | 40 | override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 41 | let cell:UITableViewCell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as UITableViewCell 42 | if let rooms = home?.rooms { 43 | 44 | let room = rooms[indexPath.row] as HMRoom 45 | 46 | cell.textLabel?.text = room.name 47 | 48 | if let accessoriesOfCurrentRoom :[AnyObject] = room.accessories { 49 | cell.detailTextLabel?.text = "Number of accessories : \(accessoriesOfCurrentRoom.count)" 50 | } else { 51 | cell.detailTextLabel?.text = "No accessories :(" 52 | } 53 | 54 | } 55 | 56 | return cell 57 | } 58 | 59 | override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { 60 | if pickerMode { 61 | accessoryViewController?.setPickedRoom(home?.rooms[indexPath.row] as HMRoom) 62 | dismissViewControllerAnimated(true, completion: nil) 63 | 64 | } else { 65 | performSegueWithIdentifier("details", sender: home?.rooms[indexPath.row]) 66 | } 67 | 68 | } 69 | 70 | 71 | 72 | 73 | } -------------------------------------------------------------------------------- /HomeKitDemo/home@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fredericfalliere/HomeKit/d1d09f084b723cd29f93ffdc9e8cc84ddc9fd435/HomeKitDemo/home@2x.png -------------------------------------------------------------------------------- /HomeKitDemo/hueline@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fredericfalliere/HomeKit/d1d09f084b723cd29f93ffdc9e8cc84ddc9fd435/HomeKitDemo/hueline@2x.png -------------------------------------------------------------------------------- /HomeKitDemoTests/HomeKitDemoTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HomeKitDemoTests.swift 3 | // HomeKitDemoTests 4 | // 5 | // Created by Frédéric Falliere on 08/07/2014. 6 | // Copyright (c) 2014 Marcel Falliere. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import XCTest 11 | 12 | class HomeKitDemoTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | XCTAssert(true, "Pass") 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measureBlock() { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /HomeKitDemoTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | fr.fmf.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | HomeKit 2 | --- 3 | 4 | Feature list : 5 | 6 | - **New:** works with Xcode6 Beta7 7 | - discover devices and add them to your primary home 8 | - manage your primary home 9 | - add a room to your primary home 10 | - change the name of your primary home 11 | - add an accessory to your primary home 12 | - see the list of services of a accessory 13 | - see the list of characteristics of a service 14 | - change the values of these characteristics : power, hue, saturation 15 | 16 | To do : 17 | 18 | - implement UI to change the values of other kinds of characteristics 19 | - action sets and triggers (currently) 20 | 21 | How to play with this demo 22 | === 23 | 24 | - `git clone` this repo 25 | - open the `.xcodeproj` with Xcode 6 (I uses beta 2 and 3) 26 | - in Xcode, go to `XCode` -> `Open Developers Tools` -> `HomeKit Accessory Simulator` and create at least one accessory with a lamp service 27 | - run on simulator, but first go to the second tab to configure your primary home 28 | - if you run on a device, **Siri works** --------------------------------------------------------------------------------