objc2_home_kit/generated/
HMHome.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10/// [Apple's documentation](https://developer.apple.com/documentation/homekit/hmhomehubstate?language=objc)
11// NS_ENUM
12#[repr(transparent)]
13#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
14pub struct HMHomeHubState(pub NSUInteger);
15impl HMHomeHubState {
16    #[doc(alias = "HMHomeHubStateNotAvailable")]
17    pub const NotAvailable: Self = Self(0);
18    #[doc(alias = "HMHomeHubStateConnected")]
19    pub const Connected: Self = Self(1);
20    #[doc(alias = "HMHomeHubStateDisconnected")]
21    pub const Disconnected: Self = Self(2);
22}
23
24unsafe impl Encode for HMHomeHubState {
25    const ENCODING: Encoding = NSUInteger::ENCODING;
26}
27
28unsafe impl RefEncode for HMHomeHubState {
29    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
30}
31
32extern_class!(
33    /// Represents a home.
34    ///
35    ///
36    /// This class represents a home and is the entry point to communicate and
37    /// configure different accessories in the home. This is also used to manage
38    /// all the rooms, zones, service groups, users, triggers, and action sets in
39    /// the home.
40    ///
41    /// See also [Apple's documentation](https://developer.apple.com/documentation/homekit/hmhome?language=objc)
42    #[unsafe(super(NSObject))]
43    #[derive(Debug, PartialEq, Eq, Hash)]
44    pub struct HMHome;
45);
46
47unsafe impl Send for HMHome {}
48
49unsafe impl Sync for HMHome {}
50
51unsafe impl NSObjectProtocol for HMHome {}
52
53impl HMHome {
54    extern_methods!(
55        #[unsafe(method(init))]
56        #[unsafe(method_family = init)]
57        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
58
59        /// Delegate that receives updates on the state of the home.
60        #[unsafe(method(delegate))]
61        #[unsafe(method_family = none)]
62        pub unsafe fn delegate(&self) -> Option<Retained<ProtocolObject<dyn HMHomeDelegate>>>;
63
64        /// This is a [weak property][objc2::topics::weak_property].
65        /// Setter for [`delegate`][Self::delegate].
66        #[unsafe(method(setDelegate:))]
67        #[unsafe(method_family = none)]
68        pub unsafe fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn HMHomeDelegate>>);
69
70        /// The name of the home.
71        #[unsafe(method(name))]
72        #[unsafe(method_family = none)]
73        pub unsafe fn name(&self) -> Retained<NSString>;
74
75        /// Specifies whether this home is the primary home.
76        #[unsafe(method(isPrimary))]
77        #[unsafe(method_family = none)]
78        pub unsafe fn isPrimary(&self) -> bool;
79
80        /// Specifies the state of the home hub.
81        #[unsafe(method(homeHubState))]
82        #[unsafe(method_family = none)]
83        pub unsafe fn homeHubState(&self) -> HMHomeHubState;
84
85        /// A unique identifier for the home.
86        #[unsafe(method(uniqueIdentifier))]
87        #[unsafe(method_family = none)]
88        pub unsafe fn uniqueIdentifier(&self) -> Retained<NSUUID>;
89
90        #[cfg(feature = "block2")]
91        /// This method is used to change the name of the home.
92        ///
93        ///
94        /// Parameter `name`: New name for the home.
95        ///
96        ///
97        /// Parameter `completion`: Block that is invoked once the request is processed.
98        /// The NSError provides more information on the status of the request, error
99        /// will be nil on success.
100        #[unsafe(method(updateName:completionHandler:))]
101        #[unsafe(method_family = none)]
102        pub unsafe fn updateName_completionHandler(
103            &self,
104            name: &NSString,
105            completion: &block2::Block<dyn Fn(*mut NSError)>,
106        );
107    );
108}
109
110/// Methods declared on superclass `NSObject`.
111impl HMHome {
112    extern_methods!(
113        #[unsafe(method(new))]
114        #[unsafe(method_family = new)]
115        pub unsafe fn new() -> Retained<Self>;
116    );
117}
118
119/// HMAccessory.
120impl HMHome {
121    extern_methods!(
122        #[cfg(feature = "HMAccessory")]
123        /// Array of HMAccessory objects that represents all accessories added to the home.
124        #[unsafe(method(accessories))]
125        #[unsafe(method_family = none)]
126        pub unsafe fn accessories(&self) -> Retained<NSArray<HMAccessory>>;
127
128        #[cfg(all(feature = "HMAccessory", feature = "block2"))]
129        /// Adds a new accessory to the home.
130        ///
131        ///
132        /// Parameter `accessory`: Accessory to add to the home.
133        ///
134        ///
135        /// Parameter `completion`: Block that is invoked once the request is processed.
136        /// The NSError provides more information on the status of the request, error
137        /// will be nil on success.
138        #[unsafe(method(addAccessory:completionHandler:))]
139        #[unsafe(method_family = none)]
140        pub unsafe fn addAccessory_completionHandler(
141            &self,
142            accessory: &HMAccessory,
143            completion: &block2::Block<dyn Fn(*mut NSError)>,
144        );
145
146        #[cfg(all(feature = "HMAccessory", feature = "block2"))]
147        /// Removes an accessory from the home.
148        ///
149        ///
150        /// Parameter `accessory`: Accessory to remove from the home.
151        ///
152        ///
153        /// Parameter `completion`: Block that is invoked once the request is processed.
154        /// The NSError provides more information on the status of the request, error
155        /// will be nil on success.
156        #[unsafe(method(removeAccessory:completionHandler:))]
157        #[unsafe(method_family = none)]
158        pub unsafe fn removeAccessory_completionHandler(
159            &self,
160            accessory: &HMAccessory,
161            completion: &block2::Block<dyn Fn(*mut NSError)>,
162        );
163
164        #[cfg(all(feature = "HMAccessory", feature = "HMRoom", feature = "block2"))]
165        /// Assigns a new room for the accessory.
166        ///
167        ///
168        /// When an accessory is added to a home, it is automatically assigned the room corresponding to
169        /// + [HMHome roomForEntireHome]. This method is used to change the room assigned to an accessory.
170        ///
171        ///
172        /// Parameter `accessory`: Accessory whose rooms needs to modified
173        ///
174        ///
175        /// Parameter `room`: New room for the accessory.
176        ///
177        ///
178        /// Parameter `completion`: Block that is invoked once the request is processed.
179        /// The NSError provides more information on the status of the request, error
180        /// will be nil on success.
181        #[unsafe(method(assignAccessory:toRoom:completionHandler:))]
182        #[unsafe(method_family = none)]
183        pub unsafe fn assignAccessory_toRoom_completionHandler(
184            &self,
185            accessory: &HMAccessory,
186            room: &HMRoom,
187            completion: &block2::Block<dyn Fn(*mut NSError)>,
188        );
189
190        #[cfg(feature = "HMService")]
191        /// Queries all services that match the specified types.
192        ///
193        ///
194        /// Parameter `serviceTypes`: Array of NSString objects that specifies the service types to match.
195        ///
196        ///
197        /// Returns: Array of HMService objects that match the specified service types,
198        /// nil if no matching services were found.
199        #[unsafe(method(servicesWithTypes:))]
200        #[unsafe(method_family = none)]
201        pub unsafe fn servicesWithTypes(
202            &self,
203            service_types: &NSArray<NSString>,
204        ) -> Option<Retained<NSArray<HMService>>>;
205
206        #[cfg(all(feature = "HMAccessory", feature = "block2"))]
207        /// unblock a blocked accessory.
208        ///
209        ///
210        /// A misbehaving accessory will automatically be blocked.  After that all requests to
211        /// the accessory will fail.  This API must be used to explicitly unblock the accessory
212        ///
213        ///
214        /// Parameter `accessory`: accessory to be unblocked
215        ///
216        ///
217        /// Parameter `completion`: Block that is invoked once the request is processed.
218        /// The NSError provides more information on the status of the request, error
219        /// will be nil on success.
220        #[unsafe(method(unblockAccessory:completionHandler:))]
221        #[unsafe(method_family = none)]
222        pub unsafe fn unblockAccessory_completionHandler(
223            &self,
224            accessory: &HMAccessory,
225            completion: &block2::Block<dyn Fn(*mut NSError)>,
226        );
227
228        #[cfg(feature = "block2")]
229        /// Find nearby accessories and add them to the home. During this process, each of the accessories added
230        /// to the home is assigned to a room and its services are configured.
231        ///
232        ///
233        /// Parameter `completion`: Block that is invoked once the request is processed.
234        /// The NSError provides more information on the status of the request, error
235        /// will be nil on success.
236        #[deprecated = "Use -[HMAccessorySetupManager performAccessorySetupUsingRequest:completionHandler:] instead"]
237        #[unsafe(method(addAndSetupAccessoriesWithCompletionHandler:))]
238        #[unsafe(method_family = none)]
239        pub unsafe fn addAndSetupAccessoriesWithCompletionHandler(
240            &self,
241            completion: &block2::Block<dyn Fn(*mut NSError)>,
242        );
243
244        #[cfg(all(
245            feature = "HMAccessory",
246            feature = "HMAccessorySetupPayload",
247            feature = "block2"
248        ))]
249        /// Add accessory with the given setup payload to the home.
250        ///
251        /// Note: This SPI requires entitlement: com.apple.developer.homekit.allow-setup-payload
252        ///
253        ///
254        /// Parameter `completion`: Block that is invoked once the request is processed.
255        /// Accessories provides the list of added accessories.
256        /// The NSError provides more information on the status of the request, error
257        /// will be nil on success.
258        #[deprecated = "Use -[HMAccessorySetupManager performAccessorySetupUsingRequest:completionHandler:] instead"]
259        #[unsafe(method(addAndSetupAccessoriesWithPayload:completionHandler:))]
260        #[unsafe(method_family = none)]
261        pub unsafe fn addAndSetupAccessoriesWithPayload_completionHandler(
262            &self,
263            payload: &HMAccessorySetupPayload,
264            completion: &block2::Block<dyn Fn(*mut NSArray<HMAccessory>, *mut NSError)>,
265        );
266
267        /// True if this home supports all of the requirements for adding a network router.
268        #[unsafe(method(supportsAddingNetworkRouter))]
269        #[unsafe(method_family = none)]
270        pub unsafe fn supportsAddingNetworkRouter(&self) -> bool;
271    );
272}
273
274/// HMUser.
275impl HMHome {
276    extern_methods!(
277        #[cfg(feature = "HMUser")]
278        /// HMUser object representing the current user of the home.
279        #[unsafe(method(currentUser))]
280        #[unsafe(method_family = none)]
281        pub unsafe fn currentUser(&self) -> Retained<HMUser>;
282
283        #[cfg(feature = "HMUser")]
284        /// Array of HMUser objects that represent all users associated with the home.
285        #[deprecated = "No longer supported."]
286        #[unsafe(method(users))]
287        #[unsafe(method_family = none)]
288        pub unsafe fn users(&self) -> Retained<NSArray<HMUser>>;
289
290        #[cfg(feature = "block2")]
291        /// Presents a view controller to manage users of the home.
292        ///
293        ///
294        /// This API is available only for users that have administrator access to the home.
295        ///
296        ///
297        /// Parameter `completion`: Block that is invoked once user management is completed.
298        /// The completion block is fired to allow clients to know when the user has dismissed the view.
299        /// The NSError provides more information on the status of the request, error
300        /// will be nil on success. If the user does not have administrator privileges the error code will be set to
301        /// HMErrorCodeInsufficientPrivileges.
302        #[unsafe(method(manageUsersWithCompletionHandler:))]
303        #[unsafe(method_family = none)]
304        pub unsafe fn manageUsersWithCompletionHandler(
305            &self,
306            completion: &block2::Block<dyn Fn(*mut NSError)>,
307        );
308
309        #[cfg(all(feature = "HMUser", feature = "block2"))]
310        /// Adds a user to the home.
311        ///
312        ///
313        /// Parameter `completion`: Block that is invoked once the request is processed.
314        /// The HMUser object provides a reference to the user that was added to the home.
315        /// The NSError provides more information on the status of the request, error
316        /// will be nil on success. The userInfo dictionary will contain the HMUserFailedAccessoriesKey which provides
317        /// more details on the accessories that failed to add the user.
318        #[deprecated]
319        #[unsafe(method(addUserWithCompletionHandler:))]
320        #[unsafe(method_family = none)]
321        pub unsafe fn addUserWithCompletionHandler(
322            &self,
323            completion: &block2::Block<dyn Fn(*mut HMUser, *mut NSError)>,
324        );
325
326        #[cfg(all(feature = "HMUser", feature = "block2"))]
327        /// Removes a user from the home.
328        ///
329        ///
330        /// Parameter `user`: HMUser whose access is being revoked.
331        ///
332        ///
333        /// Parameter `completion`: Block that is invoked once the request is processed.
334        /// The NSError provides more information on the status of the request, error
335        /// will be nil on success. The userInfo dictionary will contain the HMUserFailedAccessoriesKey which provides
336        /// more details on the accessories that failed to remove the user.
337        #[deprecated]
338        #[unsafe(method(removeUser:completionHandler:))]
339        #[unsafe(method_family = none)]
340        pub unsafe fn removeUser_completionHandler(
341            &self,
342            user: &HMUser,
343            completion: &block2::Block<dyn Fn(*mut NSError)>,
344        );
345
346        #[cfg(all(
347            feature = "HMAccessControl",
348            feature = "HMHomeAccessControl",
349            feature = "HMUser"
350        ))]
351        /// Retrieve the access level of the user associated with the home.
352        #[unsafe(method(homeAccessControlForUser:))]
353        #[unsafe(method_family = none)]
354        pub unsafe fn homeAccessControlForUser(
355            &self,
356            user: &HMUser,
357        ) -> Retained<HMHomeAccessControl>;
358    );
359}
360
361/// HMRoom.
362impl HMHome {
363    extern_methods!(
364        #[cfg(feature = "HMRoom")]
365        /// Array of HMRoom objects that represents all rooms in the home.
366        #[unsafe(method(rooms))]
367        #[unsafe(method_family = none)]
368        pub unsafe fn rooms(&self) -> Retained<NSArray<HMRoom>>;
369
370        #[cfg(all(feature = "HMRoom", feature = "block2"))]
371        /// Adds a room to the home.
372        ///
373        ///
374        /// Parameter `roomName`: Name of the room to add to the home.
375        ///
376        ///
377        /// Parameter `completion`: Block that is invoked once the request is processed.
378        /// The HMRoom is the new room added to the home.
379        /// The NSError provides more information on the status of the request, error
380        /// will be nil on success.
381        #[unsafe(method(addRoomWithName:completionHandler:))]
382        #[unsafe(method_family = none)]
383        pub unsafe fn addRoomWithName_completionHandler(
384            &self,
385            room_name: &NSString,
386            completion: &block2::Block<dyn Fn(*mut HMRoom, *mut NSError)>,
387        );
388
389        #[cfg(all(feature = "HMRoom", feature = "block2"))]
390        /// Removes a room from the home.
391        ///
392        /// Any references to this room will be removed from all properties
393        /// of the home. For example, the room will be removed from the zone.
394        /// Any accessories associated contained by this room will be moved to
395        /// the room provided by - [HMHome roomForEntireHome].
396        ///
397        ///
398        /// Parameter `room`: Room to remove from the home.
399        ///
400        ///
401        /// Parameter `completion`: Block that is invoked once the request is processed.
402        /// The NSError provides more information on the status of the request, error
403        /// will be nil on success.
404        #[unsafe(method(removeRoom:completionHandler:))]
405        #[unsafe(method_family = none)]
406        pub unsafe fn removeRoom_completionHandler(
407            &self,
408            room: &HMRoom,
409            completion: &block2::Block<dyn Fn(*mut NSError)>,
410        );
411
412        #[cfg(feature = "HMRoom")]
413        /// This method returns a room that represents the entire home. This can be used to assign a room
414        /// to a service that is not necessarily located in one particular room.
415        ///
416        ///
417        /// Returns: HMRoom that represents the home.
418        #[unsafe(method(roomForEntireHome))]
419        #[unsafe(method_family = none)]
420        pub unsafe fn roomForEntireHome(&self) -> Retained<HMRoom>;
421    );
422}
423
424/// HMZone.
425impl HMHome {
426    extern_methods!(
427        #[cfg(feature = "HMZone")]
428        /// Array of HMZone objects that represents all the zones in the home.
429        #[unsafe(method(zones))]
430        #[unsafe(method_family = none)]
431        pub unsafe fn zones(&self) -> Retained<NSArray<HMZone>>;
432
433        #[cfg(all(feature = "HMZone", feature = "block2"))]
434        /// Adds a zone to the home.
435        ///
436        ///
437        /// Parameter `zoneName`: Name of the zone to add to the home.
438        ///
439        ///
440        /// Parameter `completion`: Block that is invoked once the request is processed.
441        /// The HMZone is the new zone added to the home.
442        /// The NSError provides more information on the status of the request, error
443        /// will be nil on success.
444        #[unsafe(method(addZoneWithName:completionHandler:))]
445        #[unsafe(method_family = none)]
446        pub unsafe fn addZoneWithName_completionHandler(
447            &self,
448            zone_name: &NSString,
449            completion: &block2::Block<dyn Fn(*mut HMZone, *mut NSError)>,
450        );
451
452        #[cfg(all(feature = "HMZone", feature = "block2"))]
453        /// Removes a zone from the home.
454        ///
455        ///
456        /// Parameter `zone`: Zone to remove from the home.
457        ///
458        ///
459        /// Parameter `completion`: Block that is invoked once the request is processed.
460        /// The NSError provides more information on the status of the request, error
461        /// will be nil on success.
462        #[unsafe(method(removeZone:completionHandler:))]
463        #[unsafe(method_family = none)]
464        pub unsafe fn removeZone_completionHandler(
465            &self,
466            zone: &HMZone,
467            completion: &block2::Block<dyn Fn(*mut NSError)>,
468        );
469    );
470}
471
472/// HMServiceGroup.
473impl HMHome {
474    extern_methods!(
475        #[cfg(feature = "HMServiceGroup")]
476        /// Array of HMServiceGroup objects that represents all service groups in the home.
477        #[unsafe(method(serviceGroups))]
478        #[unsafe(method_family = none)]
479        pub unsafe fn serviceGroups(&self) -> Retained<NSArray<HMServiceGroup>>;
480
481        #[cfg(all(feature = "HMServiceGroup", feature = "block2"))]
482        /// Adds a service group to the home.
483        ///
484        ///
485        /// Parameter `serviceGroupName`: Name of the service group to add to the home.
486        ///
487        ///
488        /// Parameter `completion`: Block that is invoked once the request is processed.
489        /// The HMServiceGroup is the new service group added to the home.
490        /// The NSError provides more information on the status of the request, error
491        /// will be nil on success.
492        #[unsafe(method(addServiceGroupWithName:completionHandler:))]
493        #[unsafe(method_family = none)]
494        pub unsafe fn addServiceGroupWithName_completionHandler(
495            &self,
496            service_group_name: &NSString,
497            completion: &block2::Block<dyn Fn(*mut HMServiceGroup, *mut NSError)>,
498        );
499
500        #[cfg(all(feature = "HMServiceGroup", feature = "block2"))]
501        /// Removes a service group from the home.
502        ///
503        ///
504        /// Parameter `group`: Service group to remove from the home.
505        ///
506        ///
507        /// Parameter `completion`: Block that is invoked once the request is processed.
508        /// The NSError provides more information on the status of the request, error
509        /// will be nil on success.
510        #[unsafe(method(removeServiceGroup:completionHandler:))]
511        #[unsafe(method_family = none)]
512        pub unsafe fn removeServiceGroup_completionHandler(
513            &self,
514            group: &HMServiceGroup,
515            completion: &block2::Block<dyn Fn(*mut NSError)>,
516        );
517    );
518}
519
520/// HMActionSet.
521impl HMHome {
522    extern_methods!(
523        #[cfg(feature = "HMActionSet")]
524        /// Array of HMActionSet objects that represents all the action sets in the home.
525        #[unsafe(method(actionSets))]
526        #[unsafe(method_family = none)]
527        pub unsafe fn actionSets(&self) -> Retained<NSArray<HMActionSet>>;
528
529        #[cfg(all(feature = "HMActionSet", feature = "block2"))]
530        /// Adds a new action set to the home.
531        ///
532        ///
533        /// Parameter `actionSetName`: Name of the action set to add to the home.
534        ///
535        ///
536        /// Parameter `completion`: Block that is invoked once the request is processed.
537        /// The HMActionSet parameter is the new action set added to the home.
538        /// The NSError provides more information on the status of the request, error
539        /// will be nil on success.
540        #[unsafe(method(addActionSetWithName:completionHandler:))]
541        #[unsafe(method_family = none)]
542        pub unsafe fn addActionSetWithName_completionHandler(
543            &self,
544            action_set_name: &NSString,
545            completion: &block2::Block<dyn Fn(*mut HMActionSet, *mut NSError)>,
546        );
547
548        #[cfg(all(feature = "HMActionSet", feature = "block2"))]
549        /// Removes an existing action set from the home.
550        ///
551        ///
552        /// Parameter `actionSet`: Action set to remove from the home. A builtin action set cannot be removed.
553        ///
554        ///
555        /// Parameter `completion`: Block that is invoked once the request is processed.
556        /// The NSError provides more information on the status of the request, error
557        /// will be nil on success.
558        #[unsafe(method(removeActionSet:completionHandler:))]
559        #[unsafe(method_family = none)]
560        pub unsafe fn removeActionSet_completionHandler(
561            &self,
562            action_set: &HMActionSet,
563            completion: &block2::Block<dyn Fn(*mut NSError)>,
564        );
565
566        #[cfg(all(feature = "HMActionSet", feature = "block2"))]
567        /// Executes all the actions within an action set.
568        ///
569        ///
570        /// Parameter `actionSet`: Action set to execute.
571        ///
572        ///
573        /// Parameter `completion`: Block that is invoked once the request is processed.
574        /// The NSError provides more information on the status of the request, error
575        /// will be nil on success.
576        #[unsafe(method(executeActionSet:completionHandler:))]
577        #[unsafe(method_family = none)]
578        pub unsafe fn executeActionSet_completionHandler(
579            &self,
580            action_set: &HMActionSet,
581            completion: &block2::Block<dyn Fn(*mut NSError)>,
582        );
583
584        #[cfg(feature = "HMActionSet")]
585        /// Retrieve a built-in action set for the home.
586        ///
587        ///
588        /// Parameter `actionSetType`: Type of the builtin action set. Supported action set types are HMActionSetTypeWakeUp,
589        /// HMActionSetTypeSleep, HMActionSetTypeHomeDeparture and HMActionSetTypeHomeArrival.
590        ///
591        ///
592        /// Returns: Reference to the built-in action set corresponding to type argument,
593        /// nil if no matching action set is found.
594        #[unsafe(method(builtinActionSetOfType:))]
595        #[unsafe(method_family = none)]
596        pub unsafe fn builtinActionSetOfType(
597            &self,
598            action_set_type: &NSString,
599        ) -> Option<Retained<HMActionSet>>;
600    );
601}
602
603/// HMTrigger.
604impl HMHome {
605    extern_methods!(
606        #[cfg(feature = "HMTrigger")]
607        /// Array of HMTrigger objects that represents all the triggers in the home.
608        #[unsafe(method(triggers))]
609        #[unsafe(method_family = none)]
610        pub unsafe fn triggers(&self) -> Retained<NSArray<HMTrigger>>;
611
612        #[cfg(all(feature = "HMTrigger", feature = "block2"))]
613        /// Adds a trigger to the home. Unless the trigger object is added to the home, it cannot be
614        /// activated. Throws error and will not be added to home if there is no Home Hub associated with the home
615        ///
616        ///
617        /// Triggers are specific to an iOS device and are not synced across multiple devices to
618        /// ensure that the action sets are executed only once.
619        ///
620        ///
621        /// Parameter `trigger`: Trigger to add to the home.
622        ///
623        ///
624        /// Parameter `completion`: Block that is invoked once the request is processed.
625        /// The HMTrigger parameter is the new trigger added to the home.
626        /// The NSError provides more information on the status of the request, error
627        /// will be nil on success.
628        /// Errors when no Home Hub is associated with the home
629        #[unsafe(method(addTrigger:completionHandler:))]
630        #[unsafe(method_family = none)]
631        pub unsafe fn addTrigger_completionHandler(
632            &self,
633            trigger: &HMTrigger,
634            completion: &block2::Block<dyn Fn(*mut NSError)>,
635        );
636
637        #[cfg(all(feature = "HMTrigger", feature = "block2"))]
638        /// Removes a trigger from the home. If the trigger is active, they are automatically deactivated.
639        ///
640        ///
641        /// Parameter `trigger`: Trigger to remove from the home.
642        ///
643        ///
644        /// Parameter `completion`: Block that is invoked once the request is processed.
645        /// The NSError provides more information on the status of the request, error
646        /// will be nil on success.
647        #[unsafe(method(removeTrigger:completionHandler:))]
648        #[unsafe(method_family = none)]
649        pub unsafe fn removeTrigger_completionHandler(
650            &self,
651            trigger: &HMTrigger,
652            completion: &block2::Block<dyn Fn(*mut NSError)>,
653        );
654    );
655}
656
657/// Matter.
658impl HMHome {
659    extern_methods!(
660        /// Identifier of the Matter controller associated with this home.
661        /// This property can be passed as the first argument to +[MTRDeviceController sharedControllerWithId:xpcConnectBlock:] method
662        /// to get a MTRDeviceController object.
663        #[unsafe(method(matterControllerID))]
664        #[unsafe(method_family = none)]
665        pub unsafe fn matterControllerID(&self) -> Retained<NSString>;
666
667        #[cfg(feature = "block2")]
668        /// Block generating XPC connection on demand through which to access the Matter controller associated with this home.
669        /// This property can be passed as the second argument to +[MTRDeviceController sharedControllerWithId:xpcConnectBlock:] method
670        /// to get a MTRDeviceController object.
671        #[unsafe(method(matterControllerXPCConnectBlock))]
672        #[unsafe(method_family = none)]
673        pub unsafe fn matterControllerXPCConnectBlock(
674            &self,
675        ) -> NonNull<block2::Block<dyn Fn() -> NonNull<NSXPCConnection>>>;
676
677        #[cfg(feature = "block2")]
678        /// Block generating XPC connection on demand through which to access the Matter controller associated with this home.
679        /// This property can be passed as part of an MTRXPCDeviceControllerParameters to create an MTRDeviceController that will have access to the Apple Home Fabric.
680        #[unsafe(method(matterStartupParametersXPCConnectBlock))]
681        #[unsafe(method_family = none)]
682        pub unsafe fn matterStartupParametersXPCConnectBlock(
683            &self,
684        ) -> NonNull<block2::Block<dyn Fn() -> NonNull<NSXPCConnection>>>;
685    );
686}
687
688extern_protocol!(
689    /// This delegate receives update on the various accessories, action sets, groups and triggers
690    /// managed in the home.
691    ///
692    /// See also [Apple's documentation](https://developer.apple.com/documentation/homekit/hmhomedelegate?language=objc)
693    pub unsafe trait HMHomeDelegate: NSObjectProtocol {
694        /// Informs the delegate of a change in the name of a home.
695        ///
696        ///
697        /// Parameter `home`: Sender of this message.
698        #[optional]
699        #[unsafe(method(homeDidUpdateName:))]
700        #[unsafe(method_family = none)]
701        unsafe fn homeDidUpdateName(&self, home: &HMHome);
702
703        /// Informs the delegate when the access control for current user has been updated.
704        ///
705        ///
706        /// Parameter `home`: Sender of the message.
707        #[optional]
708        #[unsafe(method(homeDidUpdateAccessControlForCurrentUser:))]
709        #[unsafe(method_family = none)]
710        unsafe fn homeDidUpdateAccessControlForCurrentUser(&self, home: &HMHome);
711
712        #[cfg(feature = "HMAccessory")]
713        /// Informs the delegate of addition of an accessory to the home.
714        ///
715        ///
716        /// Parameter `home`: Sender of the message.
717        ///
718        ///
719        /// Parameter `accessory`: Accessory that was added to the home.
720        #[optional]
721        #[unsafe(method(home:didAddAccessory:))]
722        #[unsafe(method_family = none)]
723        unsafe fn home_didAddAccessory(&self, home: &HMHome, accessory: &HMAccessory);
724
725        #[cfg(feature = "HMAccessory")]
726        /// Informs the delegate of removal of an accessory from the home.
727        ///
728        ///
729        /// Parameter `home`: Sender of the message.
730        ///
731        ///
732        /// Parameter `accessory`: Accessory that was removed from the home.
733        #[optional]
734        #[unsafe(method(home:didRemoveAccessory:))]
735        #[unsafe(method_family = none)]
736        unsafe fn home_didRemoveAccessory(&self, home: &HMHome, accessory: &HMAccessory);
737
738        #[cfg(feature = "HMUser")]
739        /// Informs the delegate that a user was added to the home.
740        ///
741        ///
742        /// Parameter `home`: Sender of this message.
743        ///
744        ///
745        /// Parameter `user`: User who was granted access to the home.
746        #[optional]
747        #[unsafe(method(home:didAddUser:))]
748        #[unsafe(method_family = none)]
749        unsafe fn home_didAddUser(&self, home: &HMHome, user: &HMUser);
750
751        #[cfg(feature = "HMUser")]
752        /// Informs the delegate that a user was removed from the home.
753        ///
754        ///
755        /// Parameter `home`: Sender of this message.
756        ///
757        ///
758        /// Parameter `user`: User whose access was revoked from the home.
759        #[optional]
760        #[unsafe(method(home:didRemoveUser:))]
761        #[unsafe(method_family = none)]
762        unsafe fn home_didRemoveUser(&self, home: &HMHome, user: &HMUser);
763
764        #[cfg(all(feature = "HMAccessory", feature = "HMRoom"))]
765        /// Informs the delegate when a new room is assigned to an accessory
766        ///
767        ///
768        /// Parameter `home`: Sender of the message.
769        ///
770        ///
771        /// Parameter `room`: New room for the accessory.
772        ///
773        ///
774        /// Parameter `accessory`: Accessory that was assigned a new room.
775        #[optional]
776        #[unsafe(method(home:didUpdateRoom:forAccessory:))]
777        #[unsafe(method_family = none)]
778        unsafe fn home_didUpdateRoom_forAccessory(
779            &self,
780            home: &HMHome,
781            room: &HMRoom,
782            accessory: &HMAccessory,
783        );
784
785        #[cfg(feature = "HMRoom")]
786        /// Informs the delegate of addition of a room to the home.
787        ///
788        ///
789        /// Parameter `home`: Sender of the message.
790        ///
791        ///
792        /// Parameter `room`: Room that was added to the home.
793        #[optional]
794        #[unsafe(method(home:didAddRoom:))]
795        #[unsafe(method_family = none)]
796        unsafe fn home_didAddRoom(&self, home: &HMHome, room: &HMRoom);
797
798        #[cfg(feature = "HMRoom")]
799        /// Informs the delegate of removal of a room from the home.
800        ///
801        ///
802        /// Parameter `home`: Sender of the message.
803        ///
804        ///
805        /// Parameter `room`: Room that was removed from the home.
806        #[optional]
807        #[unsafe(method(home:didRemoveRoom:))]
808        #[unsafe(method_family = none)]
809        unsafe fn home_didRemoveRoom(&self, home: &HMHome, room: &HMRoom);
810
811        #[cfg(feature = "HMRoom")]
812        /// Informs the delegate that the name of a room was modified
813        ///
814        ///
815        /// Parameter `home`: Sender of this message.
816        ///
817        ///
818        /// Parameter `room`: Room that was modified.
819        #[optional]
820        #[unsafe(method(home:didUpdateNameForRoom:))]
821        #[unsafe(method_family = none)]
822        unsafe fn home_didUpdateNameForRoom(&self, home: &HMHome, room: &HMRoom);
823
824        #[cfg(feature = "HMZone")]
825        /// Informs the delegate of addition of a zone to the home.
826        ///
827        ///
828        /// Parameter `home`: Sender of the message.
829        ///
830        ///
831        /// Parameter `zone`: Zone that was added to the home.
832        #[optional]
833        #[unsafe(method(home:didAddZone:))]
834        #[unsafe(method_family = none)]
835        unsafe fn home_didAddZone(&self, home: &HMHome, zone: &HMZone);
836
837        #[cfg(feature = "HMZone")]
838        /// Informs the delegate of removal of a zone from the home.
839        ///
840        ///
841        /// Parameter `home`: Sender of the message.
842        ///
843        ///
844        /// Parameter `zone`: Zone that was removed from the home.
845        #[optional]
846        #[unsafe(method(home:didRemoveZone:))]
847        #[unsafe(method_family = none)]
848        unsafe fn home_didRemoveZone(&self, home: &HMHome, zone: &HMZone);
849
850        #[cfg(feature = "HMZone")]
851        /// Informs the delegate that the name of a zone was modified.
852        ///
853        ///
854        /// Parameter `home`: Sender of this message.
855        ///
856        ///
857        /// Parameter `zone`: Zone that was modified.
858        #[optional]
859        #[unsafe(method(home:didUpdateNameForZone:))]
860        #[unsafe(method_family = none)]
861        unsafe fn home_didUpdateNameForZone(&self, home: &HMHome, zone: &HMZone);
862
863        #[cfg(all(feature = "HMRoom", feature = "HMZone"))]
864        /// Informs the delegate that the room was added to a zone.
865        ///
866        ///
867        /// Parameter `home`: Sender of this message.
868        ///
869        ///
870        /// Parameter `room`: Room that was added to the zone.
871        ///
872        ///
873        /// Parameter `zone`: Zone that was modified.
874        #[optional]
875        #[unsafe(method(home:didAddRoom:toZone:))]
876        #[unsafe(method_family = none)]
877        unsafe fn home_didAddRoom_toZone(&self, home: &HMHome, room: &HMRoom, zone: &HMZone);
878
879        #[cfg(all(feature = "HMRoom", feature = "HMZone"))]
880        /// Informs the delegate that the room was removed from a zone.
881        ///
882        ///
883        /// Parameter `home`: Sender of this message.
884        ///
885        ///
886        /// Parameter `room`: Room that was removed from the zone.
887        ///
888        ///
889        /// Parameter `zone`: Zone that was modified.
890        #[optional]
891        #[unsafe(method(home:didRemoveRoom:fromZone:))]
892        #[unsafe(method_family = none)]
893        unsafe fn home_didRemoveRoom_fromZone(&self, home: &HMHome, room: &HMRoom, zone: &HMZone);
894
895        #[cfg(feature = "HMServiceGroup")]
896        /// Informs the delegate that a service group was added to the home.
897        ///
898        ///
899        /// Parameter `home`: Sender of the message.
900        ///
901        ///
902        /// Parameter `group`: Service group that was added to the home.
903        #[optional]
904        #[unsafe(method(home:didAddServiceGroup:))]
905        #[unsafe(method_family = none)]
906        unsafe fn home_didAddServiceGroup(&self, home: &HMHome, group: &HMServiceGroup);
907
908        #[cfg(feature = "HMServiceGroup")]
909        /// Informs the delegate that a service group was removed from the home.
910        ///
911        ///
912        /// Parameter `home`: Sender of the message.
913        ///
914        ///
915        /// Parameter `group`: Service group that was removed from the home.
916        #[optional]
917        #[unsafe(method(home:didRemoveServiceGroup:))]
918        #[unsafe(method_family = none)]
919        unsafe fn home_didRemoveServiceGroup(&self, home: &HMHome, group: &HMServiceGroup);
920
921        #[cfg(feature = "HMServiceGroup")]
922        /// Informs the delegate that the name of a service group was modified.
923        ///
924        ///
925        /// Parameter `home`: Sender of this message.
926        ///
927        ///
928        /// Parameter `group`: The service group that was modified.
929        #[optional]
930        #[unsafe(method(home:didUpdateNameForServiceGroup:))]
931        #[unsafe(method_family = none)]
932        unsafe fn home_didUpdateNameForServiceGroup(&self, home: &HMHome, group: &HMServiceGroup);
933
934        #[cfg(all(feature = "HMService", feature = "HMServiceGroup"))]
935        /// Informs the delegate that a service was added to a service group.
936        ///
937        ///
938        /// Parameter `home`: Sender of this message.
939        ///
940        ///
941        /// Parameter `service`: Service that was added to the service group.
942        ///
943        ///
944        /// Parameter `group`: Service group that was modified.
945        #[optional]
946        #[unsafe(method(home:didAddService:toServiceGroup:))]
947        #[unsafe(method_family = none)]
948        unsafe fn home_didAddService_toServiceGroup(
949            &self,
950            home: &HMHome,
951            service: &HMService,
952            group: &HMServiceGroup,
953        );
954
955        #[cfg(all(feature = "HMService", feature = "HMServiceGroup"))]
956        /// Informs the delegate that a service was removed from a service group.
957        ///
958        ///
959        /// Parameter `home`: Sender of this message.
960        ///
961        ///
962        /// Parameter `service`: Service that was removed from the service group.
963        ///
964        ///
965        /// Parameter `group`: Service group that was modified.
966        #[optional]
967        #[unsafe(method(home:didRemoveService:fromServiceGroup:))]
968        #[unsafe(method_family = none)]
969        unsafe fn home_didRemoveService_fromServiceGroup(
970            &self,
971            home: &HMHome,
972            service: &HMService,
973            group: &HMServiceGroup,
974        );
975
976        #[cfg(feature = "HMActionSet")]
977        /// Informs the delegate that an action set was added to the home.
978        ///
979        ///
980        /// Parameter `home`: Sender of this message.
981        ///
982        ///
983        /// Parameter `actionSet`: Action set that was added to the home.
984        #[optional]
985        #[unsafe(method(home:didAddActionSet:))]
986        #[unsafe(method_family = none)]
987        unsafe fn home_didAddActionSet(&self, home: &HMHome, action_set: &HMActionSet);
988
989        #[cfg(feature = "HMActionSet")]
990        /// Informs the delegate that an action set was removed from the home.
991        ///
992        ///
993        /// Parameter `home`: Sender of this message.
994        ///
995        ///
996        /// Parameter `actionSet`: Action set that was removed from the home.
997        #[optional]
998        #[unsafe(method(home:didRemoveActionSet:))]
999        #[unsafe(method_family = none)]
1000        unsafe fn home_didRemoveActionSet(&self, home: &HMHome, action_set: &HMActionSet);
1001
1002        #[cfg(feature = "HMActionSet")]
1003        /// Informs the delegate that the name of an action set was modified.
1004        ///
1005        ///
1006        /// Parameter `home`: Sender of this message.
1007        ///
1008        ///
1009        /// Parameter `actionSet`: Action set that was modified.
1010        #[optional]
1011        #[unsafe(method(home:didUpdateNameForActionSet:))]
1012        #[unsafe(method_family = none)]
1013        unsafe fn home_didUpdateNameForActionSet(&self, home: &HMHome, action_set: &HMActionSet);
1014
1015        #[cfg(feature = "HMActionSet")]
1016        /// Informs the delegate that the actions of an action set was modified.
1017        /// This indicates that an action was added/removed or modified (value replaced)
1018        ///
1019        ///
1020        /// Parameter `home`: Sender of this message.
1021        ///
1022        ///
1023        /// Parameter `actionSet`: Action set that was modified.
1024        #[optional]
1025        #[unsafe(method(home:didUpdateActionsForActionSet:))]
1026        #[unsafe(method_family = none)]
1027        unsafe fn home_didUpdateActionsForActionSet(&self, home: &HMHome, action_set: &HMActionSet);
1028
1029        #[cfg(feature = "HMTrigger")]
1030        /// Informs the delegate of the addition of a trigger to the home.
1031        ///
1032        ///
1033        /// Parameter `home`: Sender of the message.
1034        ///
1035        ///
1036        /// Parameter `trigger`: Trigger that was added to the home.
1037        #[optional]
1038        #[unsafe(method(home:didAddTrigger:))]
1039        #[unsafe(method_family = none)]
1040        unsafe fn home_didAddTrigger(&self, home: &HMHome, trigger: &HMTrigger);
1041
1042        #[cfg(feature = "HMTrigger")]
1043        /// Informs the delegate of removal of a trigger from the home.
1044        ///
1045        ///
1046        /// Parameter `home`: Sender of the message.
1047        ///
1048        ///
1049        /// Parameter `trigger`: Trigger that was removed from the home.
1050        #[optional]
1051        #[unsafe(method(home:didRemoveTrigger:))]
1052        #[unsafe(method_family = none)]
1053        unsafe fn home_didRemoveTrigger(&self, home: &HMHome, trigger: &HMTrigger);
1054
1055        #[cfg(feature = "HMTrigger")]
1056        /// Informs the delegate that the name of the trigger was modified.
1057        ///
1058        ///
1059        /// Parameter `home`: Sender of this message.
1060        ///
1061        ///
1062        /// Parameter `trigger`: Trigger that was modified.
1063        #[optional]
1064        #[unsafe(method(home:didUpdateNameForTrigger:))]
1065        #[unsafe(method_family = none)]
1066        unsafe fn home_didUpdateNameForTrigger(&self, home: &HMHome, trigger: &HMTrigger);
1067
1068        #[cfg(feature = "HMTrigger")]
1069        /// Informs the delegate whenever a trigger is updated. For example, this method may be
1070        /// invoked when a trigger is activated, when a trigger fires, or when the action sets
1071        /// associated with a trigger are modified.
1072        ///
1073        ///
1074        /// Parameter `home`: Sender of this message.
1075        ///
1076        ///
1077        /// Parameter `trigger`: The trigger that was updated.
1078        #[optional]
1079        #[unsafe(method(home:didUpdateTrigger:))]
1080        #[unsafe(method_family = none)]
1081        unsafe fn home_didUpdateTrigger(&self, home: &HMHome, trigger: &HMTrigger);
1082
1083        #[cfg(feature = "HMAccessory")]
1084        /// Informs the delegate that an accessory has been unblocked
1085        ///
1086        ///
1087        /// Parameter `home`: Sender of this message.
1088        ///
1089        ///
1090        /// Parameter `accessory`: Accessory that was unblocked
1091        #[optional]
1092        #[unsafe(method(home:didUnblockAccessory:))]
1093        #[unsafe(method_family = none)]
1094        unsafe fn home_didUnblockAccessory(&self, home: &HMHome, accessory: &HMAccessory);
1095
1096        #[cfg(feature = "HMAccessory")]
1097        /// Informs the delegate that a configured accessory encountered an error. The
1098        /// delegate should check the blocked state of the accessory
1099        ///
1100        ///
1101        /// Parameter `home`: Sender of this message.
1102        ///
1103        ///
1104        /// Parameter `error`: Error encountered by accessory.
1105        ///
1106        ///
1107        /// Parameter `accessory`: Accessory that encountered the error
1108        #[optional]
1109        #[unsafe(method(home:didEncounterError:forAccessory:))]
1110        #[unsafe(method_family = none)]
1111        unsafe fn home_didEncounterError_forAccessory(
1112            &self,
1113            home: &HMHome,
1114            error: &NSError,
1115            accessory: &HMAccessory,
1116        );
1117
1118        /// Informs the delegate when state of the home hub changes.
1119        ///
1120        ///
1121        /// Parameter `home`: Sender of the message.
1122        ///
1123        ///
1124        /// Parameter `homeHubState`: The new home hub state.
1125        #[optional]
1126        #[unsafe(method(home:didUpdateHomeHubState:))]
1127        #[unsafe(method_family = none)]
1128        unsafe fn home_didUpdateHomeHubState(&self, home: &HMHome, home_hub_state: HMHomeHubState);
1129
1130        /// Informs the delegate when the supported features of this home changes.
1131        ///
1132        /// The supported features covered by this are currently:
1133        /// - supportsAddingNetworkRouter
1134        ///
1135        ///
1136        /// Parameter `home`: Sender of the message.
1137        #[optional]
1138        #[unsafe(method(homeDidUpdateSupportedFeatures:))]
1139        #[unsafe(method_family = none)]
1140        unsafe fn homeDidUpdateSupportedFeatures(&self, home: &HMHome);
1141    }
1142);
1143
1144extern "C" {
1145    /// Key that provides more details on the accessories that failed during an
1146    /// addUser:completionHandler: or removeUser:completionHandler: call.
1147    ///
1148    ///
1149    /// The value associated with this key is an NSArray of NSDictionary objects. Each dictionary
1150    /// contains the UUID of the accessory that failed to the added/removed and the value
1151    /// corresponding to the dictionary key is an NSError that provides more details on the
1152    /// underlying error for that accessory.
1153    ///
1154    /// See also [Apple's documentation](https://developer.apple.com/documentation/homekit/hmuserfailedaccessorieskey?language=objc)
1155    pub static HMUserFailedAccessoriesKey: &'static NSString;
1156}