-
I am working on a project that has 11 contact sensors for doors or windows. So, I wrote a class for these contact sensors, and in I have read from the docs that if the first accessory doesn't have any service, it'll be shown as a bridge. However, that's not the case here. Here's my
The constructor of
Any idea what's going on here? Thanks. PS here's the full code for
|
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 4 replies
-
When I run your script, the Serial Monitor reports that there is no bridge, as expected. Note that a bridge accessory never shows up in the Home App itself, so you would not see it anywhere. If you are only seeing 10 Contact Sensors instead of 11 in your Room View, this suggests that one of the Sensors may have been allocated to another room, or (more typically) to the "Default Room". Please check to see if the 11th Contact Switch is in some other room. Devices do not control the room assignments - this is done all within the Home App. And based on my experience, it is a little buggy (regardless of whether using HomeSpan or a commercial device). Sometimes I find that right after pairing a new device, it shows up in the room I assigned, but then it moves to "Default Room" for no apparent reason. This doesn't happen often, maybe 5% of the time, but it is strange when it does. |
Beta Was this translation helpful? Give feedback.
-
Thanks for your response. I looked at the log in the serial monitor too and it looked completely normal: 11 contact sensors and no bridge:
No, the missing contact sensor was not assigned to another room. The Home App indeed thinks it's a bridge. After I tap on "add accessory", it asks me to choose a "Bridge Location". See the screenshot |
Beta Was this translation helpful? Give feedback.
-
And, after adding them, I went to the contact sensor's property sheet and clicked on "Bridge", this is what I saw. The first accessory "Front Door" is shown as a bridge. |
Beta Was this translation helpful? Give feedback.
-
Can you unpair the device from the Home App, type 'H' into the Serial Monitor, which causes HomeSpan to generate a new Device ID, and try re-pairing? If the issue still persists, can you try running Example 1 (though also make sure to type 'H' into the Serial Monitor to refresh the Device ID before changing to Example 1). Regarding your last screenshot, this is common even if you don't have a bridge accessory - starting around iOS 16 the HomeApp often creates an implicit bridge for a device that does not otherwise have a bridge. Also, even if you add a bridge from HomeSpan itself, there is no icon that itself identifies as a bridge. In fact, if you try to add a device that contains nothing but a bridge Accessory (no functional Services), it will fail during pairing. Where I have seen this type of issue before is when developing a sketch and changing it from bridge to non-bridge, or vice-versa. When a device is initially paired, the device ID (which is supposed to be unique across all HomeKit devices) is saved by the Home App and information is distributed to your Home Hubs. Certain changes to device in the future, such as adding a new Accessory, do not typically cause a problem. But fundamental changes, such a bridge->non-bridge, or vice-versa, can create some havoc since the latest state of the Device conflicts with what the Home App previously knew. Hence, the solution is to ensure the Home App thinks you are pairing a new, never-before-seen, device, by having HomeSpan generate a new device ID (using the 'H' CLI command). |
Beta Was this translation helpful? Give feedback.
-
I have always generated a new device ID using the "H" command, each time after changing the sketch. Example 1 (SimpleLightBulb) works completely fine. The light bulb is recognized as an un-bridged light bulb. And the minimum repro I've come up with so far is 4 accessories. If I add only 3 in |
Beta Was this translation helpful? Give feedback.
-
It may be that there is an undocumented HomeKit limit on the number of Accessories that can be in a single device without having a bridge. I don't think any of the HomeSpan examples have more than 3 Accessories without implementing a bridge as well, so this limit could have been present for quite some time, or it may be a recent addition by Apple. I'll do some experimenting and see why I can find. In any case @delingren, the solution for your sketch is to implement the first Accessory as a bridge, so all 11 sensors will show up correctly. Note that even if you implement as a bridge, you don't need to use the Bridge Category - you can choose any category you'd like. |
Beta Was this translation helpful? Give feedback.
-
Update: I have been able to reproduce using Lightbulb Accessories and can confirm that if you have 4 or more Accessories defined, HomeKit is going to interpret the first one as a bridge even if it has functional Services. I do not know if this is a new "feature" Apple introduced recently or if this has always been the case. I'll add a note about this in the HomeSpan documentation for reference. |
Beta Was this translation helpful? Give feedback.
It may be that there is an undocumented HomeKit limit on the number of Accessories that can be in a single device without having a bridge. I don't think any of the HomeSpan examples have more than 3 Accessories without implementing a bridge as well, so this limit could have been present for quite some time, or it may be a recent addition by Apple. I'll do some experimenting and see why I can find.
In any case @delingren, the solution for your sketch is to implement the first Accessory as a bridge, so all 11 sensors will show up correctly. Note that even if you implement as a bridge, you don't need to use the Bridge Category - you can choose any category you'd like.