How to set fan speed step using ESP-Homekit-SDK?

astrofin
Posts: 1
Joined: Thu Aug 04, 2022 1:33 pm

How to set fan speed step using ESP-Homekit-SDK?

Postby astrofin » Thu Aug 04, 2022 3:31 pm

Sorry for this very basic question, and hopefully this is the correct place to post this question.

I've recently started to build Espressif devices. Until now I have been using Arduino IDE, but have just trying to learn ESP-IDF. For my first project, I am trying to experiment with the fan example from ESP-Homekit-SDK.

The Homekit specification describes the fan service as having a rotation speed characteristic. This characteristic accepts the percentage fan speed (0-100), but also accepts a step value. The step value allows configuration for e.g., 3-speed fans (step = 33.3%).

ESP-Homekit-SDK provides a method for configuring the rotation speed characteristic:
  1. /* components/esp_hap_apple_profiles/src/hap_apple_chars.c */
  2. /* Char: Rotation Speed */
  3. hap_char_t *hap_char_rotation_speed_create(float rotation_speed)
  4. {
  5.     hap_char_t *hc = hap_char_float_create(HAP_CHAR_UUID_ROTATION_SPEED,
  6.                                            HAP_CHAR_PERM_PR | HAP_CHAR_PERM_PW | HAP_CHAR_PERM_EV, rotation_speed);
  7.     if (!hc) {
  8.         return NULL;
  9.     }
  10.  
  11.     hap_char_float_set_constraints(hc, 0.0, 100.0, 1);
  12.     hap_char_add_unit(hc, HAP_CHAR_UNIT_PERCENTAGE);
  13.  
  14.     return hc;
  15. }
Am I correct in thinking that this function does not expose the `step` value. And that in order to set a step value of e.g., 33.3 I would need to overwrite the function and replace this line:

Code: Select all

hap_char_float_set_constraints(hc, 0.0, 100.0, 33.3);
I'm not sure if I am overlooking something here, and am having trouble understanding what `hap_char_float_set_constraints` is doing.

Appreciate of someone can confirm that ESP-Homekit-SDK does not provide an api for setting the fan speed step.

Who is online

Users browsing this forum: No registered users and 147 guests