NN708 / ESP-Homekit-IRHub

A Homekit-enabled IR hub to control all your IR devices (air conditioners and TVs).
MIT License
11 stars 5 forks source link

how to setup for other accessories #11

Closed cab113 closed 4 years ago

cab113 commented 4 years ago

Hi, thank you for this project, would you please explain how i can create and add custom accessory, i want to make a remote Carrier heat pump?

NN708 commented 4 years ago

Hi, @cab113,

To add your own accessories, just do the following things:

  1. In ir_hub/accessories/, create a pair of .c/.h for your own accessory, for example, panasonic_ac.c and panasonic_ac.h. The only function you need to expose is the initialization function (panasonic_ac_init(homekit_accessory_t* accessory); in panasonic_ac). In the init function, you need to create services and characteristics for your device. Read Apple’s HomeKit Accessory Protocol Specification for more details. When you create the characteristics, you may need to create some callback functions, for example, to transmit some IR codes when turn on/off is received. Here’s some transmit functions in transmit.c, you can call them or write your own transmit function.

  2. Call your init function in homekit_task.c, like this:

    homekit_add_accessory(&homekit_server_config, NEW_HOMEKIT_ACCESSORY());
    panasonic_ac_init(homekit_server_config.accessories[1]);

You can make Pull Request if you would like to share your accessories with us.

NN708 commented 4 years ago

The issue is now closed. You can re-open it at any time if you still have the issue.