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