Yurik72 / ESPHap

ESP32/ESP8266 Arduino library for native Apple Homekit Accessory Protocol (HAP)
MIT License
265 stars 60 forks source link

Regarding initial value #92

Open beckmx opened 3 years ago

beckmx commented 3 years ago

Hello, I was wondering how to set the initial value for the bulb type, I noticed a method: hap_setinitial_characteristic_bool_value

But when testing, appears a message about not being correctly set: !!! HomeKit: Wrong default value

and How I created my service and default value:

hapservice_1= hap_add_lightbulb_service(prefs.getString("btn1_string").c_str(),relay_callback_1,(void*)&BUTTON_1);
hap_setinitial_characteristic_bool_value(hapservice_1,HOMEKIT_CHARACTERISTIC_ON,false);
rauberdaniel commented 3 years ago

Try using hap_set_initial_characteristic_bool_value (mind the underscore between set and initial. Looks like there is a bug which falsely rewrites the bool function to an int function instead of the corresponding bool function: https://github.com/Yurik72/ESPHap/blob/c1b2f30f9e759b3948d9a171ad55c40b220d4682/homeintegration.c#L1254