Class

HMEventTrigger

A trigger to activate an action set based on a set of events and optional conditions.

Declaration

@interface HMEventTrigger : HMTrigger

Overview

Use an HMEventTrigger object to trigger the execution of a scene when a combination of characteristic or location events and conditions occur. To create an event trigger, first create one or more event objects that fire an event when the specified trigger values are met. For example, you might create an HMCharacteristicEvent that fires when the front door is open. Then, you can use HMEventTrigger convenience methods to create optional predicates that specify conditions that must be met before a scene is executed. For example, you might create a condition that ensures the scene is executed only after sunset.

Topics

Creating an Event Trigger

- initWithName:events:predicate:

Creates a new event trigger with the specified name, events, and predicate.

- initWithName:events:endEvents:recurrences:predicate:

Creates a new event trigger with the specified name, events, end events, recurrences, and predicate.

Querying Trigger Activation State

triggerActivationState

The current activation state of the trigger.

HMEventTriggerActivationState

The activation state of an event trigger.

Setting Trigger Events

events

The events that activate the trigger.

- updateEvents:completionHandler:

Updates the set of trigger events.

Location Events

Events that represent the user's movement among regions.

Time Events

Events based on time, significant occurrences, and time durations.

Characteristic Events

Events based on the capabilities or characteristics of accessories.

Presence Events

Events based on the user's presence in a home.

HMEvent

The abstract base class for a HomeKit event.

Restoring the Previous Scene After an Event

endEvents

The events associated with the end of scene represented by this trigger.

- updateEndEvents:completionHandler:

Updates the set of end events associated with the event trigger.

Controlling Recurrence

recurrences

Specifies the days on which the trigger can execute.

- updateRecurrences:completionHandler:

Updates the days of the week the trigger can repeat.

executeOnce

A Boolean that can execute the trigger many times.

- updateExecuteOnce:completionHandler:

Updates the repetition status of the event trigger.

Adding a Trigger Condition

predicate

The predicate to evaluate before executing the scene associated with the event trigger.

- updatePredicate:completionHandler:

Replaces the predicate used to evaluate execution of the scene associated with the event trigger.

Creating Predicates

+ predicateForEvaluatingTriggerOccurringBeforeSignificantEvent:

Creates a predicate that evaluates whether the event occurred before a significant event.

+ predicateForEvaluatingTriggerOccurringAfterSignificantEvent:

Creates a predicate that evaluates whether the event occurred after a significant event.

+ predicateForEvaluatingTriggerOccurringBetweenSignificantEvent:secondSignificantEvent:

Creates a predicate that evaluates whether the event occurred between two significant events.

+ predicateForEvaluatingTriggerOccurringBeforeDateWithComponents:

Creates a predicate that evaluates whether the event occurred before the specified time.

+ predicateForEvaluatingTriggerOccurringOnDateWithComponents:

Creates a predicate that evaluates whether the event occurred at the specified time.

+ predicateForEvaluatingTriggerOccurringAfterDateWithComponents:

Creates a predicate that evaluates whether the event occurred at or after the specified time.

+ predicateForEvaluatingTriggerOccurringBetweenDateWithComponents:secondDateWithComponents:

Creates a predicate that evaluates whether the event occurred between the specified times.

+ predicateForEvaluatingTriggerWithCharacteristic:relatedBy:toValue:

Creates a predicate that evaluates whether a characteristic value relates to the specified value.

+ predicateForEvaluatingTriggerWithPresence:

Creates a predicate that evaluates the current user presence against that specified in the presence event.

HMCharacteristicKeyPath

Specifies the key path for a characteristic in an NSPredicate.

HMCharacteristicValueKeyPath

Specifies the key path for a characteristic value in an NSPredicate.

HMPresenceKeyPath

Specifies the key path for a presence event in an NSPredicate.

Deprecated Symbols

- addEvent:completionHandler:

Adds a new event to the event trigger.

Deprecated
- removeEvent:completionHandler:

Removes the specified event from the event trigger.

Deprecated
+ predicateForEvaluatingTriggerOccurringBeforeSignificantEvent:applyingOffset:

Creates a predicate that evaluates whether the event occurred before a significant event.

Deprecated
+ predicateForEvaluatingTriggerOccurringAfterSignificantEvent:applyingOffset:

Creates a predicate that evaluates whether the event occurred before a significant event.

Deprecated

Relationships

Inherits From

See Also

Action Sets

HMActionSet

A collection of actions that you trigger as a group.

HMTimerTrigger

A trigger to activate an action set based on a periodic timer.