3
我在HMHome中實施HMLocatinEvent。我正在嘗試下面的代碼,但有一件事我沒有得到是我不知道如果我離開家時必須執行像incase這樣的功能必須關閉所有的燈。我沒有找到任何與動作組相關的方法。如果我錯了,請糾正我。HMLocationEvent示例
要求:如果我離開家,我想關閉所有HMA配件。
問題:
- 爲了達到要求,我需要使用HMLocationEvent和HMEventTrigger?或者是否有任何替代?
- 如果我必須使用HMLocationEvent和HMEventTrigger,那麼我該如何在指定區域進入/退出的操作中執行某些操作?
我是否需要實現CLLocationManager和委託方法來使用HMLocationEvent?
HMLocationEvent *locEvent = [[HMLocationEvent alloc] initWithRegion:region1];
region1.notifyOnEntry = YES;
region1.notifyOnExit = YES; CLRegion *region1 = [[CLCircularRegion alloc] initWithCenter:[selectedLoc coordinate] radius:5 identifier:@"Office"]; NSDateComponents *com = [[NSDateComponents alloc] init]; com.second = 1; HMEventTrigger *tr = [[HMEventTrigger alloc] initWithName:eventName.text events:[NSArray arrayWithObject:locEvent] predicate:[HMEventTrigger predicateForEvaluatingTriggerOccurringOnDateWithComponents:com]]; [selectedHome addTrigger:tr completionHandler:^(NSError *err) { }];
謝謝你的寶貴時間。
這是從HomeKit位置事件不同 – SRI