ESP32-HOMEKIT
Apple HomeKit Accessory Server Library for IDF V5.0. Developing apps and accessories for the home.Let people communicate with and control connected accessories in their home using your app. With the HomeKit or Matter framework, you can provide users the ability to configure accessories and create actions to control them. Group those actions together into powerful automations and trigger them using Siri. See esp32-homekit-demo for examples.
____________________________________________________________________________________________________________________________
PARTITION SETUP
You need to add a custom partition of type data and subtype "homekit" and at least 4KB (0x1000) in size for HomeKit data storage. Put this into partitions.csv
file in your project:
# ESP-IDF Partition Table
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x5000,
phy_init, data, phy, 0xe000, 0x1000,
homekit, data, homekit, 0xf000, 0x1000,
factory, app, factory, 0x10000, 1M,
Enable custom partitions in project configuration (sdkconfig):
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
____________________________________________________________________________________________________________________________
ACCESSORY SETUP
This chapter describes how the HomeKit setup payload information is generated, stored, displayed and delivered by the accessory to the controller for pairing purposes.
SETUP CODE
The Setup Code must conform to the format XXXXXXXX where each X is a 0-9 digit - for example, 10148005. For the purposes of generating accessory SRP verifier, the setup code must be formatted as XXX-XX-XXX (including dashes). In this example, the format of setup code used by the SRP verifier must be 101- 48-005.
SETUP ID
This identifier is an alphanumeric string of 4(0-9, A-Z) characters. This identifier is persistent across reboots and factory reset of the accessory. This identifier must be different than the DeviceID, serial number, model or accessory name and must be random for each accessory instance manufactured by an accessory manufacturer.
homekit_server_config_t config = {
.accessories = accessories,
.password = "123-45-678",
.setupId="1QJ8",
};
____________________________________________________________________________________________________________________________
QR CODE PREREQUISITES
Before you can generate the QR-Code for you HomeKit device you nee to install Python and some libraries
While OS X comes with a large number of Unix utilities, those familiar with Linux systems will notice one key component missing: a package manager. Homebrew fills this void. To install Homebrew, open Terminal or your favorite OS X terminal emulator and run
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
The script will explain what changes it will make and prompt you before the installation begins. Once you’ve installed Homebrew, insert the Homebrew directory at the top of your PATH environment variable. You can do this by adding the following line at the bottom of your ~/.profile file
export PATH="/usr/local/opt/python/libexec/bin:$PATH"
If you have OS X 10.12 (Sierra) or older use this line instead
export PATH=/usr/local/bin:/usr/local/sbin:$PATH
Now, we can install Python 3:
$ brew install python
This will take a minute or two.
Then install Pillow. The core image library is designed for fast access to data stored in a few basic pixel formats. It should provide a solid foundation for a general image processing tool.
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade Pillow
The the last library to generate te qrcode. A standard install uses pypng to generate PNG files and can also render QR codes directly to the console.
pip install qrcode
____________________________________________________________________________________________________________________________
GENERATE QR CODE
Then you need to generate QR code using supplied script:
tools/gen_qrcode 5 123-45-678 1QJ8 qrcode.png
HOW TO USE
Above you see the line that is used to generate the QR code. It's madeup from a few parts:
5
= HOMEKIT ACCESSORY CATEGORY (see table below)
123-45-678
= SETUP CODE (formatted as XXX-XX-XXX)
1QJ8
= SETUP ID (made from 4 random characters)
This wil give you this line:
tools/gen_qrcode 5
123-45-678
1QJ8
qrcode.png
Once you press enter the QR-code will be generated, and can be found in the TOOLS
folder as an .png image.
HOMEKIT ACCESSORY CATEGORY | NUMBER |
---|---|
Other | 1 |
Bridges | 2 |
Fans | 3 |
Garage door openers | 4 |
Lighting | 5 |
Locks | 6 |
Outlets | 7 |
Switches | 8 |
Thermostats | 9 |
Sensors | 10 |
Security systems | 11 |
Doors | 12 |
Windows | 13 |
Window coverings | 14 |
Programmable switches | 15 |
Range extenders | 16 |
IP cameras | 17 |
Video door bells | 18 |
Air purifiers | 19 |
Heaters | 20 |
Air conditioners | 21 |
Humidifiers | 22 |
Dehumidifiers | 23 |
Apple tv | 24 |
Speakers | 26 |
Airport | 27 |
Sprinklers | 28 |
Faucets | 29 |
Shower heads | 30 |
Televisions | 31 |
Target remotes | 32 |
-------------------------------------------------------------------------------------------------------------------------------------
WORKS WITH APPLE HOME BADGE
The Works with Apple Home badge can be used to visually communicate that your accessory is compatible with the Apple Home and Siri on Apple devices. If you plan to develop or manufacture a HomeKit accessory that will be distributed or sold, your company needs to be enrolled in the MFi Program.
____________________________________________________________________________________________________________________________
ORIGINAL PROJECT
MIT LICENCE
Copyright © 2017 Maxim Kulkin | ESP-Homekit-demo
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-------------------------------------------------------------------------------------------------------------------------------------
APPLE HOME
HomeKit Accessory Protocol (HAP) is Apple’s proprietary protocol that enables third-party accessories in the home (e.g., lights, thermostats and door locks) and Apple products to communicate with each other. HAP supports two transports, IP and Bluetooth LE. The information provided in the HomeKit Accessory Protocol Specification (Non-Commercial Version) describes how to implement HAP in an accessory that you create for non-commercial use and that will not be distributed or sold.
The HomeKit Accessory Protocol Specification (Non-Commercial Version) can be downloaded from the HomeKit Apple Developer page.
Copyright © 2019 Apple Inc. All rights reserved.