Domain=HMErrorDomain Code=80 "Missing entitlement for API."

A similar discussion here:

https://forums.developer.apple.com/message/73484#73484


I'm controlling an Ecobee 3 thermostat and a couple of switched outlets with my app (called AirCompare and in the store) using HomeKit. It works well and I've been running it continuously for over a year. The thermostat responds more slowly than the switches and sporadically I get the rare error shown in the title. The user sees only a red dot indicating an error but the text of the error prints to my log file. The error can usually be cleared by the user by taking any of a number of actions in the app that will call the Home Manager again.


I thought this occasional error might have something to do with the thermostat's slow response causing something to time out, but the text of the error suggests someting else is screwy.


I'm lost as to where to begin. I'd like to make this error even more rare. I'm thinking of adding another call of HM if the error is produced but this feels kludgy and I'd have to protect against an endless loop if the error persisted.

Error Domain=HMErrorDomain Code=54 "Network or other communication failure occurred."


I've since discovered that this error is the more frequent one that leads to a failure in setting my thermostat.


By comparison, I also have two Homekit wall plugs (the iHome SmartPlug and a Koogeek P1) and never encounter the communications error that I see with my Ecobee 3 thermostat.


I have found a post at Ecobee hinting that the thermostat reacts badly if too many commands are received in a short period of time. In my app's logic, setting the target temperature is the very last thing to occur, it happens after reading the temp and humidity, setting the seasonal mode (summer versus winter) and so on. So it's believeable that it would be the most prone to a "command overload" problem.

I see this too occasionally when updating my Ecobee thermostat. What's really strange is that my app get a notification for the motion sensor shortly after but the characteristic.value is an NSNumber rather than a Bool.

Any news on this issue? It's still an ogoing problem for me. I NEVER have trouble with my HomeKit switches but the Ecobee throws the error as described, or this one:


Error Domain=HMErrorDomain Code=80 "Missing entitlement for API."


Whatever is wrong, it works fine most of the time, I'd guestimate 3/4 or more. I'd sure like to get rid of these errors.


[UPDATE]


>> I have found a post at Ecobee hinting that the thermostat reacts badly if too many commands are received in a short period of time.


I added a delay of 0.5 seconds between repeated calls to read Service characteristics from the Ecobee, and this seems to have eliminated the errors. It hasn't been running long so I'll need to keep an eye on it, but so far so good. I may try to reduce that a little since 0.2 seconds is much less noticeable to the user than 0.5 seconds is.

This entry is a year old, so this may not be helpful at this point, but the "Missing entitlement for API" error most commonly happens when trying to communicate with a device when the app is in the background, which unfortunately is not allowed (I would love it to be allowed, even in some limited way -- Apple, please?). Is this when you're seeing it, or is it happening while the App is in the foreground?
Domain=HMErrorDomain Code=80 "Missing entitlement for API."
 
 
Q