Skip to content

Commit

Permalink
Merge pull request #6 from ChaosCoder/feature/triggersAndActionSets
Browse files Browse the repository at this point in the history
Add methods for action sets and triggers
  • Loading branch information
mxcl authored Nov 7, 2019
2 parents 6860f19 + c428e5f commit 668abe7
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 4 deletions.
12 changes: 12 additions & 0 deletions PMKHomeKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

/* Begin PBXBuildFile section */
63C7FFF71D5C020D003BAE60 /* PMKHomeKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 63C7FFA71D5BEE09003BAE60 /* PMKHomeKit.framework */; };
7D619865235E333E001E0F2E /* HMActionSet+Promise.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D619864235E333E001E0F2E /* HMActionSet+Promise.swift */; };
7D619867235E33AC001E0F2E /* HMTrigger+Promise.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D619866235E33AC001E0F2E /* HMTrigger+Promise.swift */; };
7D619869235E3401001E0F2E /* HMEventTrigger+Promise.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D619868235E3401001E0F2E /* HMEventTrigger+Promise.swift */; };
8312EA1521096DF000A47DDF /* HMAccessoryBrowserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8312EA1421096DF000A47DDF /* HMAccessoryBrowserTests.swift */; };
8312EA19210974F600A47DDF /* UtilsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8312EA18210974F600A47DDF /* UtilsTests.swift */; };
838C29D32103FB9700CE5309 /* HMAcessoryBrowser+Promise.swift in Sources */ = {isa = PBXBuildFile; fileRef = 838C29CE2103FB9600CE5309 /* HMAcessoryBrowser+Promise.swift */; };
Expand All @@ -33,6 +36,9 @@
63C7FFF21D5C020D003BAE60 /* PMKHKTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PMKHKTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
63CCF8121D5C0C4E00503216 /* Cartfile */ = {isa = PBXFileReference; lastKnownFileType = text; path = Cartfile; sourceTree = "<group>"; };
63CCF8171D5C11B500503216 /* Carthage.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Carthage.xcconfig; sourceTree = "<group>"; };
7D619864235E333E001E0F2E /* HMActionSet+Promise.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "HMActionSet+Promise.swift"; sourceTree = "<group>"; };
7D619866235E33AC001E0F2E /* HMTrigger+Promise.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "HMTrigger+Promise.swift"; sourceTree = "<group>"; };
7D619868235E3401001E0F2E /* HMEventTrigger+Promise.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "HMEventTrigger+Promise.swift"; sourceTree = "<group>"; };
8312EA1421096DF000A47DDF /* HMAccessoryBrowserTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HMAccessoryBrowserTests.swift; sourceTree = "<group>"; };
8312EA18210974F600A47DDF /* UtilsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UtilsTests.swift; sourceTree = "<group>"; };
838C29CE2103FB9600CE5309 /* HMAcessoryBrowser+Promise.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "HMAcessoryBrowser+Promise.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -87,8 +93,11 @@
children = (
838C29D02103FB9700CE5309 /* HMCharacteristic+Promise.swift */,
838C29CE2103FB9600CE5309 /* HMAcessoryBrowser+Promise.swift */,
7D619864235E333E001E0F2E /* HMActionSet+Promise.swift */,
7D619868235E3401001E0F2E /* HMEventTrigger+Promise.swift */,
838C29CF2103FB9700CE5309 /* HMHome+Promise.swift */,
838C29D12103FB9700CE5309 /* HMHomeManager+Promise.swift */,
7D619866235E33AC001E0F2E /* HMTrigger+Promise.swift */,
838C29D22103FB9700CE5309 /* Utils.swift */,
);
path = Sources;
Expand Down Expand Up @@ -216,8 +225,11 @@
buildActionMask = 2147483647;
files = (
838C29D62103FB9700CE5309 /* HMHomeManager+Promise.swift in Sources */,
7D619865235E333E001E0F2E /* HMActionSet+Promise.swift in Sources */,
838C29D52103FB9700CE5309 /* HMCharacteristic+Promise.swift in Sources */,
838C29D42103FB9700CE5309 /* HMHome+Promise.swift in Sources */,
7D619869235E3401001E0F2E /* HMEventTrigger+Promise.swift in Sources */,
7D619867235E33AC001E0F2E /* HMTrigger+Promise.swift in Sources */,
838C29D32103FB9700CE5309 /* HMAcessoryBrowser+Promise.swift in Sources */,
838C29D72103FB9700CE5309 /* Utils.swift in Sources */,
);
Expand Down
26 changes: 26 additions & 0 deletions Sources/HMActionSet+Promise.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import Foundation
import HomeKit
#if !PMKCocoaPods
import PromiseKit
#endif

#if !os(tvOS) && !os(watchOS)

extension HMActionSet {

@available(iOS 8.0, *)
public func addAction(_ action: HMAction) -> Promise<Void> {
return Promise { seal in
self.addAction(action, completionHandler: seal.resolve)
}
}

@available(iOS 8.0, *)
public func updateName(_ name: String) -> Promise<Void> {
return Promise { seal in
self.updateName(name, completionHandler: seal.resolve)
}
}
}

#endif
21 changes: 21 additions & 0 deletions Sources/HMEventTrigger+Promise.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import Foundation
import HomeKit
#if !PMKCocoaPods
import PromiseKit
#endif

#if !os(tvOS) && !os(watchOS)

@available(iOS 9.0, *)
extension HMEventTrigger {

@available(iOS 11.0, *)
public func updateExecuteOnce(_ executeOnce: Bool) -> Promise<Void> {
return Promise { seal in
self.updateExecuteOnce(executeOnce, completionHandler: seal.resolve)
}
}

}

#endif
42 changes: 38 additions & 4 deletions Sources/HMHome+Promise.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ extension HMHome {
self.updateName(name, completionHandler: seal.resolve)
}
}


// MARK: Accessories

/// Add and setup a new HMAccessory. Displays it's own UI
@available(iOS 11.3, *)
public func addAndSetupAccessories(with payload: HMAccessorySetupPayload) -> Promise<[HMAccessory]> {
Expand Down Expand Up @@ -62,9 +64,8 @@ extension HMHome {
}
}

/**
Rooms
*/
// MARK: Rooms

@available(iOS 8.0, *)
public func addRoom(withName name: String) -> Promise<HMRoom> {
return Promise { seal in
Expand All @@ -78,5 +79,38 @@ extension HMHome {
self.removeRoom(room, completionHandler: seal.resolve)
}
}

// MARK: Action Sets

@available(iOS 8.0, *)
public func addActionSet(withName name: String) -> Promise<HMActionSet> {
return Promise { seal in
self.addActionSet(withName: name, completionHandler: seal.resolve)
}
}

@available(iOS 8.0, *)
public func removeActionSet(_ actionSet: HMActionSet) -> Promise<Void> {
return Promise { seal in
self.removeActionSet(actionSet, completionHandler: seal.resolve)
}
}

// MARK: Triggers

@available(iOS 8.0, *)
public func addTrigger(_ trigger: HMTrigger) -> Promise<Void> {
return Promise { seal in
self.addTrigger(trigger, completionHandler: seal.resolve)
}
}

@available(iOS 8.0, *)
public func removeTrigger(_ trigger: HMTrigger) -> Promise<Void> {
return Promise { seal in
self.removeTrigger(trigger, completionHandler: seal.resolve)
}
}
}

#endif
41 changes: 41 additions & 0 deletions Sources/HMTrigger+Promise.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import Foundation
import HomeKit
#if !PMKCocoaPods
import PromiseKit
#endif

#if !os(tvOS) && !os(watchOS)

extension HMTrigger {

@available(iOS 8.0, *)
public func updateName(_ name: String) -> Promise<Void> {
return Promise { seal in
self.updateName(name, completionHandler: seal.resolve)
}
}

@available(iOS 8.0, *)
public func enable(_ enabled: Bool) -> Promise<Void> {
return Promise { seal in
self.enable(enabled, completionHandler: seal.resolve)
}
}

@available(iOS 8.0, *)
public func addActionSet(_ actionSet: HMActionSet) -> Promise<Void> {
return Promise { seal in
self.addActionSet(actionSet, completionHandler: seal.resolve)
}
}

@available(iOS 8.0, *)
public func removeActionSet(_ actionSet: HMActionSet) -> Promise<Void> {
return Promise { seal in
self.removeActionSet(actionSet, completionHandler: seal.resolve)
}
}

}

#endif

0 comments on commit 668abe7

Please sign in to comment.