[HomeKit] Connect your Photon to HomeKit without homebridge

Tags: #<Tag:0x00007fe2264f20f8>


Hi, can you explain more briefly, how to do that? In repo, there’s example folder, which shows several usages…


Sure! If you’d rename your example folder to examples (notice the ‘s’), and place your examples into separate folders, they should show up as examples on the Web IDE.
The docs on the structure are here, if that helps: https://docs.particle.io/tutorials/device-os/libraries/#overview-1


It’s done


Thanks, that should help a fair bit!


I got it working with the library (did had to add the separate files myself from the GitHub folder to the tabs in the Web IDE). But very nice that it runs entirely on the Photon!

I do have one question: is it possible to have two accessories (simulated/running) on one Photon? And if so, what would be the best approach to reach this.


Hi, thanks for feedback.

Yep actually you can do that with two different ways (composite accessory or bridge). I would recoomend to look at the pdf document. But basically every Accessory is described by Services and every Service has several Characteristics. Apple defines these services and characteristics.
I.E. a Fan Accessory can have two Services - a Fan service and Lightbulb service. i.e Lightbulb service must have defined On/Off characteristics and optionally can have a Colour characteristics. All the Services, Characteristics and their constrains are describe in that document.

Also there’s special Accessory called Bridge, which is just a set of Accessories. i.e. one bridge can handle several lightbulbs in different rooms.

For Accessory with several Services, i’ve created HAPCompositeAccessory (composition of services). Look at [HomeStation] - It is my home Photon which controls 3 Windows Shutter and 2 Relays controlled using RF 433mhz.

But there’s a limitation, it’s the length of SHARED_RESPONSE_BUFFER, buffer for JSON response. It seems around 5 accessories is the current limit - depends on count of services and characteristics.

Also about the issue you’ve had, can you please create a pull request which fixes it?


Thank you for your extensive respons, I got your HomeStation example working and I will try to adjust it to my own needs! Thanks for the help. :smiley:

Also about the issue you’ve had, can you please create a pull request which fixes it?

If you mean the fact that I had to add the separate files myself: I think (not sure, not a very experienced user)

  1. That the individual example folders should only contain one single .ino file with all the customization also in that file and the .cpp and .h files in src. (I assume this because the .cpp and .h in the examples folders will not be added automatic now in the web IDE)
  2. When you add the library this will be added to the code:
// This #include statement was automatically added by the Particle IDE.
#include <particle-hap.h>

But there is no particle-hap.h file (which then gives an error when compiling), you (the user who just added the library) can of course remove those lines after adding the library, but maybe you could add an empty particle-hap.h file to the folder to make the library more easy to use?

I would like to help you with this but I am afraid that my knowledge / experience doesn’t really is sufficient :sweat_smile: I hope someone with more library knowledge / experience can support you with this, because it is a beautiful library to have available! :relaxed:


Oki, it seems i’ve fixed that particle-hap.h problem.


I was finally able to get something working. I tried Workbench but could not get the code to compile. I probably need more exercise with Workbench.

Then I tried the particle-hap library with the lightbulb example and could get it working on a Photon, but the photon is very unstable. The Home app is losing the connection very regularly, so that doesn’t work well yet. The library is a huge improvement but I still had to include some of the libraries in the example manually.

I then tried the same code but with a different accessory name (but the same connection code) with an Argon. The Home app responded with “wrong connection code”. I then removed the Photon device and tried the Argon device again. Success! The Argon seems very stable so far!

I have several Argons and Photons that I would like to add to Homekit. How would I avoid the “wrong connection code” problem? And how can I avoid the instability issues encountered with the Photon? Any ideas welcome.

I will now proceed to experiment with the code and try dimming.


It is impossible to quantify or qualify this statement and as such no one can possibly help unless you post your code?



last week i’ve fixed the “wrong code” for Photon issue. It was due to new Photon OS and homekit pairing failed due to low memory conditions - cryptography failed due to out of memory, which resulted in invalid cryptographic response to homekit, which failed into Wrong code problem.

Please make sure, you are using latest version of my library - 1.0.13
Also please try my RelaySwitch example, which has a logging enabled. If this example fails, please provide a Serial console output, so i can investigate.

Currently i am successfully using my homekit accessories with 1.4 DeviceOS on Photon.