Closed renandw closed 1 year ago
I don't know if this is the best way, but it worked for me
case button_event_single_press:
printf("single press\n");
if(current_state.value.int_value == HOMEKIT_CURRENT_HEATING_COOLING_STATE_COOL){
target_state.value = HOMEKIT_UINT8(HOMEKIT_CURRENT_HEATING_COOLING_STATE_OFF);
homekit_characteristic_notify(&target_state, target_state.value);
printf("desligando\n");
} else {
target_state.value = HOMEKIT_UINT8(HOMEKIT_CURRENT_HEATING_COOLING_STATE_COOL);
homekit_characteristic_notify(&target_state, target_state.value);
printf("ligando\n");
}
update_state();
break;
thanks
Both code pieces look fine, the problem, I guess, is in how you have implemented your IF logic. In the second example, it is safe to extract homekit_characteristic_notify() from inside IF branches to after the IF since it is the same in both cases. It does not really matter if you check current_state or target_state inside IF condition since I believe it is you who updates current_state inside update_state so it can't be anything but what target_state is set to.
Hello Maxim.
After two years I finally got the decoding right and it worked with my AC unit. Now I am trying to implement a button to control it in a wall or something like that. So far I managed to figured out how to do using single_press and double_press:
But when I try to do with a "IF" function If ON >> turn OFF If OFF >> turno ON I get an error: "Fujitsu command send failed". And nothing happens :/
any help would be great! thanks in advance