Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

homekit_accessory_category_faucet #224

Open
vikingY opened this issue May 14, 2023 · 3 comments
Open

homekit_accessory_category_faucet #224

vikingY opened this issue May 14, 2023 · 3 comments

Comments

@vikingY
Copy link

vikingY commented May 14, 2023

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 = HOMEKIT_CHARACTERISTIC_(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
Copy link

AGRO666 commented May 17, 2023

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

@vikingY
Copy link
Author

vikingY commented May 18, 2023

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
Copy link

PimV5755 commented Jul 7, 2023

Archive.zip

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants