espressif/esp-matter

app_attribute_update_cb() when non-volatile attribute is restored from flash (CON-1172)

jonsmirl opened this issue · 2 comments

Shouldn't I be getting an app_attribute_update_cb() when my nonvolatile attributes are restored from flash on a reboot? Without the attribute write callback how do I know what they were restored to?

I'm having to add code like this to retrieve the initial attribute values loaded from flash.

    cluster_t *color_control_cluster = color_control::create(getEndpoint(), &ext_config.color_control, CLUSTER_FLAG_SERVER | CLUSTER_FLAG_CLIENT,
                                                             color_control::feature::color_temperature::get_id() | color_control::feature::xy::get_id() | color_control::feature::hue_saturation::get_id());
    attribute_t *current_x_attribute = attribute::get(color_control_cluster, ColorControl::Attributes::CurrentX::Id);
    attribute::get_val(current_x_attribute, &val);
    currentx(&val);
    attribute::set_deferred_persistence(current_x_attribute);
    attribute_t *current_y_attribute = attribute::get(color_control_cluster, ColorControl::Attributes::CurrentY::Id);
    attribute::get_val(current_y_attribute, &val);
    currenty(&val);
    attribute::set_deferred_persistence(current_y_attribute);
    attribute_t *color_temp_attribute = attribute::get(color_control_cluster, ColorControl::Attributes::ColorTemperatureMireds::Id);
    attribute::get_val(color_temp_attribute, &val);
    temperature(&val);
    attribute::set_deferred_persistence(color_temp_attribute);
    attribute_t *current_hue_attribute = attribute::get(color_control_cluster, ColorControl::Attributes::CurrentHue::Id);
    attribute::get_val(current_hue_attribute, &val);
    hue(&val);
    attribute::set_deferred_persistence(current_hue_attribute);
    attribute_t *current_saturation_attribute = attribute::get(color_control_cluster, ColorControl::Attributes::CurrentSaturation::Id);
    attribute::get_val(current_saturation_attribute, &val);
    saturation(&val);
    attribute::set_deferred_persistence(current_saturation_attribute);

This isn't really needed, there are other ways to achieve this effect.