[HomeKit] Connect your Photon to HomeKit without homebridge

photon
Tags: #<Tag:0x00007f1ca8b50ba0>

#21

I am sorry i will not provide full solution to your problem, at first i don’t have that time, at second it won’t be fun for you :slight_smile: I don’t know how familiar you are with C/C++ development, but fairly to say, your project can be easily done.

I will provide some checklist:

  1. Get the PDF docs of Homekit - look into my repo for HAP-Specification-Non-Commercial-Version.pdf file. You don’t have to read it all, but you have to be familiar with terms: Accessory, Service, Characteristics and types of Accessories and types of Characteristics and its values.
  2. After that you will understand implementation of initAccessory method in my code.
  3. Basically I am creating a virtual lightbulb accessory, but you will need a Sensor accessory, or Programable Switch.
  4. I would totally recommend to dig into my Xcode sample (in example folder), so you can debug whole accessory with full stack debugger.
  5. For such small project i would recommend to “merge” Accessory.cpp into your *.ino file, so all the variables and methods will be in one scope, and you don’t have to deal with header files.

I am working on stability of homekit, so once again sorry i will not help with integration. Have a lot of work for my job and this is just a hobby thing for me and my wife not happy about it :smiley:

Lukas


#22

No problem Lucas!
I’m sure this community can build on your work and create some other applications.

Can you provide us with some links to the essential documents you refer to?

Thanks!
:clap::slight_smile:


#23

Get my latest update from my repository, you can find the document in there - it’s confidental Apple document, but you can easily google it.


#24

Also in the latest version of example I’ve introduced LED color control (hue, saturation). Just for inspiration and made more complex example.


#25

OK, thanks! I found the interesting Apple document on Homekit.
But obviously, it’s written for professional programmers, which i’m not… :disappointed_relieved:

If I can find how to compile your example, I will try it out.

I made a screenshot of the files in your repository:

Using your main application is easy enough:

  • Load “particle-hap.ino” in the src folder and compile for the Photon, using ParticleDev.
  • Then pair the Photon with Homekit on an Apple Device.
  • From then you can use the button to turn the RGB led on the Photon ON/OFF.

For the “LED color control” example, I am not sure where to start…
I can’t find an “.ino” file to start with…

Could you please give me a hint how to combine the files in your repository in order to compile your RGB control example for a Photon? And how do we control the RGB values?

Thanks on beforehand!


#26

Hey @ljezny, great work here!
I’ve flashed the latest version and have control over both hue and intensity. I do notice that hue can jump a bit when changing values quickly (possible to increase the refresh rate?).
Brightness jumps wildly when scrolling through, it seems to keep going through 4-5 steps of brightness.
All in all, really nice!


#27

Hi guys, instead of reporting issues, any PR are welcomed. I know about the brightness problem, but my goal is integration with Dalibor Farny’s Nixie Clock, then i want to control my windows shutters from Homekit. Led control is just a simple example, how to build your own HAP. I believe that for a skilled C/C++ developer should be this sample enough. My idea of sharing the project is working a crypto (srp, eliptic curves …).
Feel free to use it, but i wont provide any much support…


#28

Hi FiDel, always get the latest version of my repository. Pair it with Homekit, long touch on the LightBulb and there should be a color settings available. Look at Accessory.cpp - there’s a handling of LED


#29

Ok, I did not know about the ‘long touch’ trick, thanks!
I downloaded this morning and indeed I can change the intensity and the hue.

Success!


#30

Hi Lukas, great and courageous project. I am happy to help testing but would not be able to contribute on the coding side, unfortunately.

Will this code also run on Argon? Has anyone tried?

Thanks!


#31

HI, i really don’t know if it will work on Argon, don’t have one. So if you have one, you can try it. Thanks


#32

I have an Argon and will try it in the coming days.:grinning:


#33

Hi Lukas, thanks for sharing, this is a great example!
I was wondering how to “customize” and configure the code for our own projects, in other words how to specify which pins to use on the photon e.g. as an “output” when you want to use it as a “lightbulb” accessory, or which pin to use for a “motion sensor accessory”.
Would I need to hard-code it like going to the “Particle-HAP/src/MotionSensorAccessory.h” file and modify line 20 “int motionInputPin = D4;” for my specific need? or can the input/output pins to be used on the photon be specified in the actual .ino file when initialising the project?


#34

Hi,
MotionSensorAccessory is just an example how to properly create and setup a homekit accessory. Of course you can setup your own wiring.
Actually you should not include classes in src folder to your project. Homekit as a library is included in ‘homekit’ subfolder. Everything above ‘homekit’ subfolder is just a sample application. In .ino file you can find a snippet how to properly initialize my library.


#35

Hi, did you tried it on Argon?