Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the 8th device is always "Not Supported" #97

Closed
gerardbos opened this issue Nov 8, 2017 · 13 comments
Closed

the 8th device is always "Not Supported" #97

gerardbos opened this issue Nov 8, 2017 · 13 comments

Comments

@gerardbos
Copy link

gerardbos commented Nov 8, 2017

Hi Matthias,

I'm using your library for a home project, and I see that if I add more than 7 devices, the 8th device is always broken (It gives an error while adding the accessory to Home) and in Home, it shows up as "Not Supported" with a Home Icon.

The code to reproduce it is shown in this gist: https://gist.github.com/gerardbos/df971f24eef9a8a41b5fccc86d87d7bf

17-11-08 11-11-35 0503

@Mfk759853063
Copy link

me too. why ?

@timoschilling
Copy link
Contributor

I have a very similar implementation and can't reproduce your issue.
https://github.com/timoschilling/dashbridge/blob/master/dashbridge.go

The only main difference is that I use an explicit bridge accessory.
https://github.com/timoschilling/dashbridge/blob/master/dashbridge.go#L38
https://github.com/timoschilling/dashbridge/blob/master/bridge.go

Maybe that will help you.

@Mfk759853063
Copy link

@timoschilling thanks, this is my code,Your method is not useful to me, I still have this problem.
default

@timoschilling
Copy link
Contributor

timoschilling commented Nov 29, 2017

I think the problem is in iOS if you use a normal accessory (a switch for example) as a bright.
I be able to fix @gerardbos's gist in two ways, first using a real bright accessory, second using iOS10.
So this looks like a iOS bug for me.

@brutella
Copy link
Owner

brutella commented Nov 30, 2017

Note: Running @gerardbos's example and adding the accessory to the Home app in the iOS simulator raises an exception in the HomeUIService process. Also the 7th device gets blocked, for no good reason.

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Items must always return a valid future from -updateWithOptions, but this item returned nil: <HFTransformItem: 0x60400028bc70, (null)>'
abort() called
CoreSimulator 494.32 - Device: iPhone 8 - Runtime: iOS 11.1 (15B87) - DeviceType: iPhone 8
terminating with uncaught exception of type NSException

Application Specific Backtrace 1:
0   CoreFoundation                      0x000000010efe81ab __exceptionPreprocess + 171
1   libobjc.A.dylib                     0x000000010e67df41 objc_exception_throw + 48
2   CoreFoundation                      0x000000010efed372 +[NSException raise:format:arguments:] + 98
3   Foundation                          0x000000010e122089 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
4   Home                                0x000000010acb544d -[HFItemManager _performUpdateForItem:withContext:isInternal:isChild:] + 1016
5   Home                                0x000000010acb3d10 __75-[HFItemManager _updateResultsForItems:removedItems:context:allowDelaying:]_block_invoke.700 + 69
6   NetAppsUtilities                    0x000000010a92f77a -[NSArray(NAAdditions) na_map:] + 266
7   Home                                0x000000010acb3032 -[HFItemManager _updateResultsForItems:removedItems:context:allowDelaying:] + 2889
8   Home                                0x000000010acb3b6d __75-[HFItemManager _updateResultsForItems:removedItems:context:allowDelaying:]_block_invoke.683 + 54
9   NetAppsUtilities                    0x000000010a92c056 __28-[NAFuture addSuccessBlock:]_block_invoke + 37
10  NetAppsUtilities                    0x000000010a92c2db -[NAFuture addCompletionBlock:] + 366
11  NetAppsUtilities                    0x000000010a92c000 -[NAFuture addSuccessBlock:] + 116
12  Home                                0x000000010acb2b1c -[HFItemManager _updateResultsForItems:removedItems:context:allowDelaying:] + 1587
13  Home                                0x000000010acb0db0 __127-[HFItemManager _reloadItemProviders:updateItems:shouldUpdateExistingItems:senderSelector:readPolicy:fastInitialUpdatePromise:]_block_invoke_2 + 1923
14  NetAppsUtilities                    0x000000010a92cc0b __20-[NAFuture flatMap:]_block_invoke + 60
15  NetAppsUtilities                    0x000000010a92c056 __28-[NAFuture addSuccessBlock:]_block_invoke + 37
16  NetAppsUtilities                    0x000000010a92c2db -[NAFuture addCompletionBlock:] + 366
17  NetAppsUtilities                    0x000000010a92c000 -[NAFuture addSuccessBlock:] + 116
18  NetAppsUtilities                    0x000000010a92cb02 -[NAFuture flatMap:] + 297
19  Home                                0x000000010acb03bb -[HFItemManager _reloadItemProviders:updateItems:shouldUpdateExistingItems:senderSelector:readPolicy:fastInitialUpdatePromise:] + 1821
20  Home                                0x000000010acaf302 -[HFItemManager _reloadAllItemProvidersFromSenderSelector:] + 372
21  Home                                0x000000010acaf040 __59-[HFItemManager reloadAndUpdateAllItemsFromSenderSelector:]_block_invoke + 407
22  NetAppsUtilities                    0x000000010a92cc0b __20-[NAFuture flatMap:]_block_invoke + 60
23  NetAppsUtilities                    0x000000010a92c056 __28-[NAFuture addSuccessBlock:]_block_invoke + 37
24  NetAppsUtilities                    0x000000010a92c2db -[NAFuture addCompletionBlock:] + 366
25  NetAppsUtilities                    0x000000010a92c000 -[NAFuture addSuccessBlock:] + 116
26  NetAppsUtilities                    0x000000010a92cb02 -[NAFuture flatMap:] + 297
27  Home                                0x000000010acaed2f -[HFItemManager reloadAndUpdateAllItemsFromSenderSelector:] + 257
28  Home                                0x000000010acadad7 -[HFItemManager _updateExternalUpdatesEnabled:reloadItems:] + 245
29  Home                                0x000000010acade70 -[HFItemManager endDisableExternalUpdatesWithReason:] + 400
30  HomeUI                              0x000000010b075661 -[HUItemTableViewController hu_preloadContent] + 200
31  HomeUI                              0x000000010af9d667 _HUPreloadViewController + 125
32  HomeUI                              0x000000010af9e11a -[UINavigationController(HUPreloadingNavigationPresentation) hu_pushPreloadableViewController:animated:] + 127
33  HomeUIService                       0x0000000109ea0920 HomeUIService + 145696
34  HomeUIService                       0x0000000109e9e777 HomeUIService + 137079
35  HomeUIService                       0x0000000109e9d68f HomeUIService + 132751
36  HomeUIService                       0x0000000109ea7772 HomeUIService + 173938
37  NetAppsUtilities                    0x000000010a92c056 __28-[NAFuture addSuccessBlock:]_block_invoke + 37
38  NetAppsUtilities                    0x000000010a92c78d -[NAFuture _flushCompletionBlocks] + 528
39  NetAppsUtilities                    0x000000010a92bbe6 -[NAFuture finishWithResult:error:] + 254
40  NetAppsUtilities                    0x000000010a92c056 __28-[NAFuture addSuccessBlock:]_block_invoke + 37
41  NetAppsUtilities                    0x000000010a92c78d -[NAFuture _flushCompletionBlocks] + 528
42  NetAppsUtilities                    0x000000010a92bbe6 -[NAFuture finishWithResult:error:] + 254
43  NetAppsUtilities                    0x000000010a92c056 __28-[NAFuture addSuccessBlock:]_block_invoke + 37
44  NetAppsUtilities                    0x000000010a92c78d -[NAFuture _flushCompletionBlocks] + 528
45  NetAppsUtilities                    0x000000010a92bbe6 -[NAFuture finishWithResult:error:] + 254
46  NetAppsUtilities                    0x000000010a92c056 __28-[NAFuture addSuccessBlock:]_block_invoke + 37
47  NetAppsUtilities                    0x000000010a92c78d -[NAFuture _flushCompletionBlocks] + 528
48  NetAppsUtilities                    0x000000010a92bbe6 -[NAFuture finishWithResult:error:] + 254
49  NetAppsUtilities                    0x000000010a92c056 __28-[NAFuture addSuccessBlock:]_block_invoke + 37
50  NetAppsUtilities                    0x000000010a92c78d -[NAFuture _flushCompletionBlocks] + 528
51  NetAppsUtilities                    0x000000010a92bbe6 -[NAFuture finishWithResult:error:] + 254
52  NetAppsUtilities                    0x000000010a92c056 __28-[NAFuture addSuccessBlock:]_block_invoke + 37
53  NetAppsUtilities                    0x000000010a92c78d -[NAFuture _flushCompletionBlocks] + 528
54  NetAppsUtilities                    0x000000010a92bbe6 -[NAFuture finishWithResult:error:] + 254
55  NetAppsUtilities                    0x000000010a92c056 __28-[NAFuture addSuccessBlock:]_block_invoke + 37
56  NetAppsUtilities                    0x000000010a92c78d -[NAFuture _flushCompletionBlocks] + 528
57  NetAppsUtilities                    0x000000010a92bbe6 -[NAFuture finishWithResult:error:] + 254
58  NetAppsUtilities                    0x000000010a92c056 __28-[NAFuture addSuccessBlock:]_block_invoke + 37
59  NetAppsUtilities                    0x000000010a92c2db -[NAFuture addCompletionBlock:] + 366
60  NetAppsUtilities                    0x000000010a92c000 -[NAFuture addSuccessBlock:] + 116
61  NetAppsUtilities                    0x000000010a92cc8e __20-[NAFuture flatMap:]_block_invoke + 191
62  NetAppsUtilities                    0x000000010a92c056 __28-[NAFuture addSuccessBlock:]_block_invoke + 37
63  NetAppsUtilities                    0x000000010a92c78d -[NAFuture _flushCompletionBlocks] + 528
64  NetAppsUtilities                    0x000000010a92bbe6 -[NAFuture finishWithResult:error:] + 254
65  NetAppsUtilities                    0x000000010a92de28 -[NAPromise finishWithResult:error:] + 58
66  Home                                0x000000010ad13536 __42-[HFServiceBuilder _lazilyUpdateDateAdded]_block_invoke_2 + 340
67  NetAppsUtilities                    0x000000010a92c78d -[NAFuture _flushCompletionBlocks] + 528
68  NetAppsUtilities                    0x000000010a92bbe6 -[NAFuture finishWithResult:error:] + 254
69  NetAppsUtilities                    0x000000010a92bf5b __45-[NAFuture errorOnlyCompletionHandlerAdapter]_block_invoke + 102
70  HomeKit                             0x000000010a981611 __41-[HMDelegateCaller callCompletion:error:]_block_invoke + 60
71  libdispatch.dylib                   0x000000010fc94273 _dispatch_call_block_and_release + 12
72  libdispatch.dylib                   0x000000010fc952b5 _dispatch_client_callout + 8
73  libdispatch.dylib                   0x000000010fc9f496 _dispatch_main_queue_callback_4CF + 1260
74  CoreFoundation                      0x000000010efaaee9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
75  CoreFoundation                      0x000000010ef6f592 __CFRunLoopRun + 2402
76  CoreFoundation                      0x000000010ef6e9b9 CFRunLoopRunSpecific + 409
77  GraphicsServices                    0x000000010f4819c6 GSEventRunModal + 62
78  UIKit                               0x000000010bed95e8 UIApplicationMain + 159
79  HomeUIService                       0x0000000109eaa24e HomeUIService + 184910
80  libdyld.dylib                       0x000000010fd09d81 start + 1
81  ???                                 0x0000000000000001 0x0 + 1

@brutella
Copy link
Owner

The official HAP documentation says

A bridge must not expose more than 100 HAP accessory objects.

Your bridge doesn't come even close to 100 accessories. I think this is an iOS HomeKit bug.

@brutella
Copy link
Owner

I've filed rdar://35770975.

@timoschilling
Copy link
Contributor

Maybe I found the problem. I have tried to add a bridge accessory to hc, during the test of the bridge I runed in the same issue. After some debugging I found this:

This bridge works:

package accessory

type Bridge struct {
  *Accessory
}

func NewBridge(info Info, identifier string) *Bridge {
  acc := Bridge{}
  acc.Accessory = New(info, TypeBridge)

  return &acc
}

This one has the "8th device Not Supported" problem:

package accessory

import (
  "github.com/brutella/hc/service"
)

type Bridge struct {
  *Accessory
  BridgingState *service.BridgingState
}

// NewBridge returns a bridge which implements model.Bridge.
func NewBridge(info Info, identifier string) *Bridge {
  acc := Bridge{}
  acc.Accessory = New(info, TypeBridge)
  acc.BridgingState = service.NewBridgingState()
  acc.BridgingState.Category.SetValue(1)
  acc.BridgingState.AccessoryIdentifier.SetValue(identifier)
  acc.BridgingState.Reachable.SetValue(true)
  acc.BridgingState.LinkQuality.SetValue(100)
  acc.AddService(acc.BridgingState.Service)

  return &acc
}

@tjbx
Copy link

tjbx commented Dec 1, 2017

I have a similar problem but mine is the 6th or 7th device (not sure how the numbering works). Mine shows as "No Response" in the official Home app and as Blocked in Brutella's Home app. My code is older though (based on edc1591/gohome) and perhaps needs refactoring but it works for the 31 other X10 devices.

@gerardbos
Copy link
Author

I'm now working around it by using @timoschilling 's solution (creating an explicit bridge for these devices). I haven't seen the problem since.

@Mfk759853063
Copy link

I fix this problem , @timoschilling Thank You

@timoschilling
Copy link
Contributor

I hope #101 will be merged to have a build in solution to fix this.

@brutella
Copy link
Owner

brutella commented Feb 6, 2018

This should be fixed with the merge of #101

@brutella brutella closed this as completed Feb 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants