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