Closed beckmx closed 4 years ago
I think you can simplify this to this:
int this_state = 0;
sysparam_get_int8("last_state", &this_state);
initial_state.value = HOMEKIT_BOOL(this_state);
If sysparam_get_int8 fails, it will not modify output value and your initial value (0, not NULL) will be your default value. Regardless if values is not there or it is invalid, you can rely on default behavior (and default value) and you will fix sysparam with the next time you store it.
So, in your code if the value is not there, it is left as 0 (thus false).
Hello everyone, I have been trying to report if the device is on/off depending on last saved state, however, for some reason, maybe because I am changing the incorrect value, the HomeKit_characteristic is always starting with the value defined in the beginning, the code looks like this: