Yurik72 / ESPHap

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

Defining limits (min_value, max_value, min_step, unit, format, etc ...) #128

Closed simkard69 closed 1 year ago

simkard69 commented 1 year ago

>>>>> EDIT, please jump directly to this comment as I managed to get things better, but not enough yet <<<<<

Hello,

I'm actually creating an interface between my old A/C heatpump and HomeKit for my own use and I wanted to know how can we define the accessories details for this kind of scenario :

I could see that in file "characteristics.h" we have these code lines (related to "HOMEKIT_CHARACTERISTIC_TARGET_TEMPERATURE") :

define HOMEKIT_CHARACTERISTIC_TARGET_TEMPERATURE HOMEKIT_APPLE_UUID2("35")

define HOMEKIT_DECLARE_CHARACTERISTIC_TARGET_TEMPERATURE(_value, ...) \

.type = HOMEKIT_CHARACTERISTIC_TARGET_TEMPERATURE, \
.description = "Target Temperature", \
.format = homekit_format_float, \
.unit = homekit_unit_celsius, \
.permissions = homekit_permissions_paired_read \
             | homekit_permissions_paired_write \
             | homekit_permissions_notify, \
.min_value = (float[]) {10}, \      <<<<<<<< **How to modify this setting ?**
.max_value = (float[]) {38}, \      <<<<<<<< **How to modify this setting ?**
.min_step = (float[]) {0.1}, \       <<<<<<<< **How to modify this setting ?**
.value = HOMEKIT_FLOAT_(_value), \

Thanks

simkard69 commented 1 year ago

Is it just a matter of solving my problem using these lines ?

homekit_characteristic_t * ch_temp = homekit_service_characteristic_by_type(Thermostat, HOMEKIT_CHARACTERISTIC_CURRENT_TEMPERATURE); ch_temp->min_value.float_value=18.0; ch_temp->max_value.float_value=32.0; ch_temp->min_step.float_value=0.5;

I have a doubt regarding the ".float_value" ...

simkard69 commented 1 year ago

Found these lines in example "EspHap_HeaterControl.ino" :

Are these the ones I'm looking for ?

simkard69 commented 1 year ago

I managed to get something working in THERMOSTAT with HEAT or COOL modes :

But when defining these 2 for AUTO mode, they seem to avoid the pairing procedure in IOS :

Any idea ?

simkard69 commented 1 year ago

Manage to solve my problem using these lines :

INIT_CHARACHTERISTIC_VAL_BY_TYPE(int, HomeKit_Svc_1, HOMEKIT_CHARACTERISTIC_CURRENT_POSITION, 50);
INIT_CHARACHTERISTIC_VAL_BY_TYPE(int, HomeKit_Svc_1, HOMEKIT_CHARACTERISTIC_TARGET_POSITION, 50);
INIT_CHARACHTERISTIC_VAL_BY_TYPE(int, HomeKit_Svc_1, HOMEKIT_CHARACTERISTIC_POSITION_STATE, 2);