Mixiaoxiao / Arduino-HomeKit-ESP8266

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

homekit_accessory_category_faucet #224

Open vikingY opened 1 year ago

vikingY commented 1 year ago

hi,

I used the flowing code in order to get faucet status (open / close) from some reason in HomeKit its appeared as updating please advise :-) Thanks in advanced.

my.accessory.c

include <homekit/homekit.h>

include <homekit/characteristics.h>

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

homekit_characteristic_t cha_faucet = HOMEKITCHARACTERISTIC(ACTIVE, false);

homekit_accessory_t accessories[] = { // Faucet 29 HOMEKIT_ACCESSORY(.id=29, .category=homekit_accessory_category_faucet, .services=(homekit_service_t[]) { HOMEKIT_SERVICE(ACCESSORY_INFORMATION, .characteristics=(homekit_characteristic_t[]) { HOMEKIT_CHARACTERISTIC(NAME, "Water Flow Sensor"), HOMEKIT_CHARACTERISTIC(MANUFACTURER, "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[]) { //HOMEKIT_CHARACTERISTIC(NAME, "Faucet"), &cha_faucet, NULL }), NULL }), NULL };

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

Faucet.ino

extern "C" homekit_server_config_t config; extern "C" homekit_characteristic_t cha_faucet;

void my_homekit_report() { cha_faucet.value.uint8_value = sensorVal; // read from Input set as int homekit_characteristic_notify(&cha_faucet, cha_faucet.value); }

AGRO666 commented 1 year ago

sensorVal = 0 (inactive) or 1 (active). Other values cannot be used and replace homekit_characteristic_t cha_faucet = HOMEKITCHARACTERISTIC(ACTIVE, 0);

vikingY commented 1 year ago

hi, that for your answering and help, unfortuntly I'm still getting No Response upon peering to HomeKit.

attch the code, what i'm doing wrong?

THX :-)

WaterSensor.zip

PimV5755 commented 1 year ago

Archive.zip

Here is my example. Have a look. The getters and setters are important to avoid "updating" or "opening"