Mixiaoxiao / Arduino-HomeKit-ESP8266

Native Apple HomeKit accessory implementation for the ESP8266 Arduino core.
MIT License
1.48k stars 278 forks source link

homekit_accessory_category_faucet #205

Open gielk opened 1 year ago

gielk commented 1 year ago

Is there anyone on GitHub who has an example or can show the code for building an ESP8266 HomeKit faucet? I was able to make a switch, but I am having trouble understanding how to convert it to a faucet. I did see the 'homekit_accessory_category_faucet' category, but I am not sure how to proceed.

angel41671 commented 1 year ago

You should use the "ACTIVE" characteristic (uint8) instead of "ON" (bool). I improvised a configuration code for a faucet (didn't try it), it may be useful:

include <homekit/homekit.h>

include <homekit/characteristics.h>

void my_accessory_identify(homekit_value_t _value) { printf("accessory identify\n"); }

// FAUCET // required: ACTIVE // optional: NAME, STATUS_FAULT

// format: uint8; homekit_characteristic_t cha_faucet_active = HOMEKITCHARACTERISTIC(ACTIVE, false);

homekit_accessory_t accessories[] = { HOMEKIT_ACCESSORY(.id=1, .category=homekit_accessory_category_faucet, .services=(homekit_service_t[]) { HOMEKIT_SERVICE(ACCESSORY_INFORMATION, .characteristics=(homekit_characteristic_t[]) { HOMEKIT_CHARACTERISTIC(NAME, “Faucet”), HOMEKIT_CHARACTERISTIC(MANUFACTURER, "Arduino HomeKit"), HOMEKIT_CHARACTERISTIC(SERIAL_NUMBER, "0123456"), HOMEKIT_CHARACTERISTIC(MODEL, "ESP8266/ESP32"), HOMEKIT_CHARACTERISTIC(FIRMWARE_REVISION, "1.0"), HOMEKIT_CHARACTERISTIC(IDENTIFY, my_accessory_identify), NULL }), HOMEKIT_SERVICE(FAUCET, .primary=true, .characteristics=(homekit_characteristic_t[]){ &cha_faucet_active, NULL }), NULL }), NULL };

homekit_server_config_t config = { .accessories = accessories, .password = "111-11-111" };

gielk commented 1 year ago

Awesome I am going to try it when I have time.

pjmeijer commented 1 year ago

Hey, thanks for inspiring me. I wanted to do something similar and I got this to work with some tinkering.
https://github.com/pjmeijer/FaucetHomeKitESP8266

pjmeijer commented 1 year ago

However, looking at this I'm not sure I'm doing it correctly: https://github.com/apple/HomeKitADK/blob/master/HAP/HAPServiceTypes.h Here they are talking about valves associated with with another type.

Looking in Arduino-HomeKit_ESP8266 I find this and that's what I used:

define HOMEKIT_SERVICE_FAUCET HOMEKIT_APPLE_UUID2("D7")

/** Defines that the accessory supports the control of a irrigation system.

Required Characteristics:

PimV5755 commented 1 year ago

Hi, It is a whole range of irrigation stuff. This works as the simplest of faucet. I have a 220V valve from Ali that does the work. Archive.zip

Good luck