Yurik72/ESPHap

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

Closed this issue · 4 comments

>>>>> 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 :

  • Minimum temperature : 18 °C
  • Maximum temperature : 32 °C
  • Steps : 0.5 °C

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

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" ...

Found these lines in example "EspHap_HeaterControl.ino" :

  • hap_set_charachteristic_validrange_by_type(heater,HOMEKIT_CHARACTERISTIC_CURRENT_TEMPERATURE,-20.0,110.0);
  • HAP_NOTIFY_CHANGES_WITHCONSTRAIN(float,ch_temp,DeviceData.temp,0.1);

Are these the ones I'm looking for ?

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

  • hap_set_charachteristic_validrange_by_type(HomeKit_Svc_HVAC, HOMEKIT_CHARACTERISTIC_TARGET_TEMPERATURE, 16.0, 31.0);

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

  • hap_set_charachteristic_validrange_by_type(HomeKit_Svc_HVAC, HOMEKIT_CHARACTERISTIC_HEATING_THRESHOLD_TEMPERATURE, 16.0, 31.0);
  • hap_set_charachteristic_validrange_by_type(HomeKit_Svc_HVAC, HOMEKIT_CHARACTERISTIC_COOLING_THRESHOLD_TEMPERATURE, 16.0, 31.0);

Any idea ?

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);