maximkulkin / esp-homekit

Apple HomeKit accessory server library for ESP-OPEN-RTOS
MIT License
1.11k stars 170 forks source link

homekit_characteristic_t Not Changing #63

Closed AustinRobinson closed 5 years ago

AustinRobinson commented 5 years ago

If I call homekit_characteristic_t current = HOMEKIT_CHARACTERISTIC_(CURRENT_DOOR_STATE, 0); and then call printf("Current: %d\n", current.value.int_value); it outputs "Current: 0" as expected. But when I call homekit_characteristic_notify(&current, HOMEKIT_UINT8(3)); it still outputs "Current: 0"

renssies commented 5 years ago

As far as I know you have to set the value yourself and then send the notification. It is built this way because things like buttons only send notifications, they don’t change values.

AustinRobinson commented 5 years ago

What do you mean by set the value yourself and then send the notification?

renssies commented 5 years ago

See “button_callback” here: https://github.com/maximkulkin/esp-homekit-demo/blob/master/examples/sonoff_basic/main.c

I set the value of the characteristic first, then I send the notification.

AustinRobinson commented 5 years ago

Never mind, I figured it out. have to do current.value = HOMEKIT_UINT8(3); and then call homekit_characteristic_notify(&current, current.value); Thanks for your help.

AustinRobinson commented 5 years ago

Even though current.value is 1, and my phone gets the "Default Room Garage Door Was Closed" it says opening in the Home App.

renssies commented 5 years ago

The home app keeps saying opening... or closing... until obstruction detected is false and the current position matches the target position. So check the value of target door state.

AustinRobinson commented 5 years ago

Ok I get it now, thanks.