Posts

Post not yet marked as solved
6 Replies
2.2k Views
Hello,I have a class CLightBulb and it is defined as a accessory delegate:class CLightBulb: NSObject, HMAccessoryDelegateIn the “init?()” I set self as the delegate:m_lightBulb.delegate = selfAnd I override the “didUpdateValueFor” method as follows, but it is never invoked when I turn a lightbulb on or off from the Homekit app on another device (other than the one I am testing on) //_______________________________ // AccessoryDelegate: Update Characteristic Value // // //_____ func accessory(_ accessory: HMAccessory, service: HMService, didUpdateValueFor characteristic: HMCharacteristic) { var results: CResults print("******------> CLightBulb AccessoryDelegate: Update Characteristic View") results = CResults() if ((accessory == m_lightBulb) && (service == m_lightBulbService)) { switch characteristic.characteristicType { case HMCharacteristicTypePowerState: results = GetThePowerStateFromTheLightBulb(workComplete: { () in let delegate = self.m_delegate if (results.GetResultCode() != CResults.code.success) { // NOTE: The attribute value is incorrect for Philips HUE bulbs so we have to check the error description // to see if the reason for the error is that its unreachable. It's not really an error if its unreachable if (self.m_isReachable == false) { delegate?.lightBulbReachablilityChanged!(device: self, newState: self.m_isReachable) } else { delegate?.lightBulbEncounteredError(device: self, opResults: results) } } else { delegate?.lightBulbPowerStateChanged!(device: self, newState: self.m_powerState) } }) default: print("CLightBulb: Encountered unexpected service type in accessory characteristic update.") } } }But when I test my app on my phone, it doesn’t get called when I, say, turn the light bulb off from the Homekit app on my iPad. Do you know what I’m missing?
Posted Last updated
.
Post not yet marked as solved
0 Replies
799 Views
Does anyone know when a HomeKit accessory's uniqueidentifier changes? I thought they were constant, but I've noticed that they change.Thanks,Scott
Posted Last updated
.
Post not yet marked as solved
1 Replies
1.3k Views
Hello,When my app attempts to read the battery level or the low power characteristics it always gets an error. (HMErrorDomain error 12.) It happens with an Elgato Degree as well as with a Samsung motion sensor (the only accessories we have with battery services). The app can read the temperature and the status of the motion sensor, but it always fails when doing a "ReadValue" on the HMCharacteristicTypeBatteryLevel or ...BatteryLow characteristiccs.Apple's HomeKit app doesn't have the problem as I can see the battery level in the accessory details.Any ideas?Thanks!
Posted Last updated
.
Post not yet marked as solved
4 Replies
2.3k Views
I’m doing something rather simple, but the execution doesn’t stop at the “wait”, it just continues so the data is incorrect. In the output I see the “After wait” message before the “Read the power….” message, and when the method returns it has the initialization value instead of the correct one. Can you tell me what I’m missing? let dispatchGroup = DispatchGroup() dispatchGroup.enter()characteristic.readValue(completionHandler: { (error) in if error != nil { print(error!.localizedDescription) } else { powerState = characteristic.value as! Int print("CLightBulb: -->Read the power state. It is \(powerState) at " + Date().description(with: Locale.current)) } })dispatchGroup.leave()dispatchGroup.wait()print("CLightBulb: (After wait) The power value is \(powerState) at " + Date().description(with: Locale.current))
Posted Last updated
.
Post marked as solved
21 Replies
4.0k Views
Hello,I have a pretty simple setup... each row in my Collectionview has a slider and "percent" label below it. When the user adjusts the slider I want to update the percent label. The problem is that adjusting the slider doesn't select the row so I can't get the indexPath. Without the index path I can't get the item so I can't access the label.I have seen two suggestions repeatedly... one tries to use "superview", but that won't work because the type casting doesn't line up. The other has multiple iterations of trying to use the coordinates of the tap, but I can't get any of them to work.Thank you!
Posted Last updated
.
Post marked as solved
1 Replies
2.0k Views
I am completely new to apple development. I want to create an HomeKit app and I'm following the guide on the Apple support site. I created an app and it builds, but when I click on the Capabilities tab there is nothing there. (Note to Apple... Always give some information, a blank page is not very helpful)
Posted Last updated
.