Skip to content

Home Kit integration

Yurik72 edited this page Jan 27, 2020 · 6 revisions

There are two way of integration

  1. Native integration with Apple Home by usage library ESPHap, this is only supports ESP32 platrofm
  2. Integration by MQTT usage

Native integration desciption can be found on description of ESPHap library

To switch which kind of integration will be used there are two defines in "config.h". #define ENABLE_HOMEBRIDGE enables integration with MQTT #define ENABLE_NATIVE_HAP enqables native integration with Apple Home Kit

For integration with MQTT usage you need to have ready bridge installed. In my case I have used:

How to setup and configure that is out of scope of current topic. Hovewer you can easily find this in Internet, for instance i have used this HomeBridge – Homekit 2 MQTT

All of that i have installed on my Raspberry pi 3 b+. Do not forget to change your config file config.json in case if during initial setup you didn't. See section Configuration ESP

Ok, now basic things.

There are two kind of messages handling:

  • Incoming <your_host_esp_name>/in
  • Outgoing <your_host_esp_name>/out

This is a basic, and on the real life each message has additional subtopic <you_service_name> , for instance if you have service type=RGBStripController with name RGBStrip messages format will be (see Configuration ESP )

  • <your_host_esp_name>/in/RGBStrip
  • <your_host_esp_name>/out/RGBStrip

That is mentioned innitially that you are able to wire several devices to the same ESP.

And finally messages ends with the device specific subject and payloads contains value for this subject. Current sketch uses following values


RelayController

Incoming <your_host_esp_name>/in/Relay/Set | payload= 0 -> off, 1-> 0n

Outgoing <your_host_esp_name>/out/Relay/Status | payload= 0 -> off, 1-> 0n

*where Relay is your service/device name

To setup this in your bridge (homekit2mqtt) you need to add following section into homekit2mqtt config file see Relay Config homekit2mqtt


RGBStripController

Incoming

  <your_host_esp_name>/in/RGBStrip/Set            | payload= 0 -> off, 1-> 0n

  <your_host_esp_name>/in/RGBStrip/Brightness     | payload= value of brigthness

  <your_host_esp_name>/in/RGBStrip/Hue            | payload= value of hue

  <your_host_esp_name>/in/RGBStrip/Saturation     | payload= value of saturation

Outgoing

  <your_host_esp_name>/out/RGBStrip/Status         | payload= 0 -> off, 1-> 0n

  <your_host_esp_name>/out/RGBStrip/Brightness     | payload= value of brigthness

  <your_host_esp_name>/out/RGBStrip/Hue            | payload= value of hue

  <your_host_esp_name>/out/RGBStrip/Saturation     | payload= value of saturation

see RGBStrip Config homekit2mqtt


LDRController

Has only outgoing message allows to measure lightness and display on your Home App

<your_host_esp_name>/out/LDR/Status

see example LDR Config homekit2mqtt

Clone this wiki locally