Accessory can't be controlled in background - Error Domain=HMErrorDomain Code=80 "Missing entitlement for API." UserInfo={NSLocalizedDescription=Missing entitlement for API.}

I can successfully control my HomeKit accessory when the app is visible, but when it is running minimized, I get:

Error Domain=HMErrorDomain Code=80 "Missing entitlement for API." UserInfo={NSLocalizedDescription=Missing entitlement for API.}

1. The HomeKit framework is enabled

2. Project entitlements are properly set

3. Provisioning profiles also include support to HomeKit


Any idea(s)?

Thanks.

That's correct. We don't currently allow accessories to be controlled by apps in the background.


-Kevin

Is this still true?


My app performs background fetching and needs to control HomeKit accesories based on what it finds. For example suppose it checks the weather and decides that a HomeKit-enabled window should close because rain is forecasted.


What should I do to make that happen? Send the user a notification to wake up my app? Could I set a trigger in the background?

Looking for ideas.

The situation is still the same, the normal entitlement does not allow apps to modify HomeKit data in background. I think showing a notification might be the only solution here.


HomeKit does have a background entitltment but I'm not sure how you can request that to be added to your app id. If you really think it's necessary for your app to work in background, maybe try contact Apple Dev Relations via DTS and ask about the background entitlement application process for HomeKit.

Thanks for that. I'll see what I can learn from Developer Relations.


I understand the security issues associated with allowing HK actions in the background, but on the other hand I think it's a serious deficiency to not allow it somehow. My app involves adjusting HK-enabled HVAC systems to save energy costs. It won't work if I have to wake up the user during the middle of the night, so he can bring the app to the front.

Yeah, I'm 100% agree that not allowing background access to HomeKit really prevents developer from creating useful app to automate user's home. It would be nice if HomeKit offers optoinal permission like Core Location so HomeKit apps can get background access if user are willing to give.


Feel free to file a radar asking for enhancement in this area 🙂

I 100% disagree. This is completely against the paradigm of HomeKit.

your use case requires a kind of weather service to be used as a Trigger, but definitely not HomeKit background capabilities to be used by the developer.

So, you're saying an app on the user's iDevice to control the HVAC system is outside the HomeKit paradigm? You may be right but that seems to be a very serious limitation.


No single device (thermostat, window, fan, etc.) is going to be smart enough and programmable enough to make intelligent control choices.


You mentioned using a weather service to generate a Trigger. Were you referring to a HomeKit weather station, or some way to use external web information? I'd be interested in any way to implement the latter.

it sounds like you are talking about an automation.


IF there was a HomeKit compatible weather station that could generate a window close trigger, then I could see setting up that automation on your Home app and the automation would run on your hub (Apple TV or home iPad) and send you a notification.


Running the automations on the hub guarantees they will not be dependent on a remote device which be operable.

both. google "Homebridge". There are also plugins for Web based weather services.

Homebridge looks interesting, thanks for the tip. I need to read more about it but it looks like the user's home network (where the Homekit devices live) would need some device running locally as a Homebridge server and that's where the smarts of my app would also run. That server would be a Mac or linux box. Sound right? Do you actually have any experience with homebridge?

Accessory can't be controlled in background - Error Domain=HMErrorDomain Code=80 "Missing entitlement for API." UserInfo={NSLocalizedDescription=Missing entitlement for API.}
 
 
Q