Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give a option to make on_level ATTRIBUTE_FLAG_NONVOLATILE (CON-1431) #1169

Closed
Haerteleric opened this issue Nov 25, 2024 · 19 comments
Closed

Comments

@Haerteleric
Copy link

Is your feature request related to a problem? Please describe.
On Level Attribute (Level Control Cluster) is reset to init values after each power cycle.

Describe the solution you'd like
allow ATTRIBUTE_FLAG_NONVOLATILE for that attribute.

Describe alternatives you've considered
give us a esp_matter func to manually set the ATTRIBUTE_FLAG_NONVOLATILE of a Attribute

Additional context
...

@Haerteleric Haerteleric changed the title Give a option to make on_level Give a option to make on_level ATTRIBUTE_FLAG_NONVOLATILE Nov 25, 2024
@github-actions github-actions bot changed the title Give a option to make on_level ATTRIBUTE_FLAG_NONVOLATILE Give a option to make on_level ATTRIBUTE_FLAG_NONVOLATILE (CON-1431) Nov 25, 2024
@jonsmirl
Copy link
Contributor

Current Level is required by the spec to be non-volatile.
image

I just tried the Espessif Light Demo and it does not appear to be preserving CurrentLevel like it is supposed to do.
You don't need option, this appears to be broken in esp-matter.

@jadhavrohit924
Copy link
Contributor

@Haerteleric We cannot change the quality of an attribute; doing so would violate the Matter spec.

I just tried the Espessif Light Demo and it does not appear to be preserving CurrentLevel like it is supposed to do.

@jonsmirl We will look into this.

@jadhavrohit924
Copy link
Contributor

@jonsmirl Light Demo example has the StartUpCurrentLevel attribute on the LevelControl cluster that's why CurrentLevel's value is being overridden by StartUpCurrentLevel's value. If you don’t want to overwrite the CurrentLevel's value, you can define IGNORE_LEVEL_CONTROL_CLUSTER_START_UP_CURRENT_LEVEL in your application.

@Haerteleric
Copy link
Author

i am not talking about the "CurrentLevel" (0x0000) but the "OnLevel" (0x0011) created in

esp_matter::cluster::level_control::attribute::create_on_level
(esp_matter_attribute.cpp:1136)

@jadhavrohit924
Copy link
Contributor

Yes, as I said in the above comments. We cannot change the quality of an attribute, doing so would violate the Matter spec.

@Haerteleric
Copy link
Author

Haerteleric commented Nov 27, 2024

why should OnLevel be Volatile ?

That does not make sense. If a user sets a TurnOn Brigthness (not startup brightness) it should not default to Max Brightness everytime the device gets power cycled.

That would blind people.

@Haerteleric
Copy link
Author

Haerteleric commented Nov 27, 2024

see 1.6.4.1.1. Effect of On/Off Commands on the CurrentLevel Attribute

Matter Application Cluster
Specification

@shubhamdp
Copy link
Contributor

@Haerteleric I think you should be using StartUpCurrentLevel and not OnLevel

1.6.6.15. StartUpCurrentLevel Attribute
This attribute SHALL indicate the desired startup level for a device when it is supplied with power and this level SHALL be reflected in the CurrentLevel attribute.

@shubhamdp
Copy link
Contributor

@Haerteleric any update on the issue?

@Haerteleric
Copy link
Author

The StartUpCurrentLevel is for power-on-behaviour imo.

The OnLevel is when the light EP was Off (but device is powered and on Network) and got turned on by a toggle or turn on command.

@shubhamdp
Copy link
Contributor

@Haerteleric That is correct, and you should use StartUpCurrentLevel for re-storing level value on power cycle. I think that was the original question you asked in the description.

Is there still a problem? If not can you please close the issue.

@Haerteleric
Copy link
Author

Haerteleric commented Dec 12, 2024

OnLevel is volitile though and has to be set after every PowerCycle atm. I don't think this is the way it should behave.

@Haerteleric
Copy link
Author

Haerteleric commented Dec 12, 2024

Setting On Level:
image

On Level after PowerCycle:
image

@Haerteleric
Copy link
Author

the stack resets the OnLevel value after every reboot to the default setting.

@shubhamdp
Copy link
Contributor

shubhamdp commented Dec 12, 2024

the stack resets the OnLevel value after every reboot to the default setting.

That is expected, as per the specification, OnLevel is a volatile attribute. If you want to mess with spec compliance please add ATTRIBUTE_FLAG_NONVOLATILE below.

attribute_t *create_on_level(cluster_t *cluster, nullable<uint8_t> value)
{
return esp_matter::attribute::create(cluster, LevelControl::Attributes::OnLevel::Id,
ATTRIBUTE_FLAG_WRITABLE | ATTRIBUTE_FLAG_NULLABLE,
esp_matter_nullable_uint8(value));
}

NOTE: I won't recommend you to make that change, but if you want to break the specification compliance, please go ahead.

@Haerteleric
Copy link
Author

Could you please refer me to the specification sections where this is defined?

Cause i can't find it.

@Haerteleric
Copy link
Author

the code section you linked is about the node_label ?!?

the stack resets the OnLevel value after every reboot to the default setting.

That is expected, as per the specification, OnLevel is a volatile attribute. If you want to mess with spec compliance please add ATTRIBUTE_FLAG_NONVOLATILE below.

attribute_t *create_node_label(cluster_t *cluster, char *value, uint16_t length)
{
VerifyOrReturnValue(length <= k_max_node_label_length, NULL, ESP_LOGE(TAG, "Could not create attribute, string length out of bound"));
return esp_matter::attribute::create(cluster, BasicInformation::Attributes::NodeLabel::Id,
ATTRIBUTE_FLAG_WRITABLE | ATTRIBUTE_FLAG_NONVOLATILE,
esp_matter_char_str(value, length), k_max_node_label_length);
}

NOTE: I won't recommend you to make that change, but if you want to break the specification compliance, please go ahead.

@shubhamdp
Copy link
Contributor

Sorry for the cut-paste mistake, I have updated the link in the comment above.

Please check Matter Application Cluster Specification Section 1.6.6. Attributes. Do check the Quality Column, X is nullable and N is non-volatile.

@Haerteleric
Copy link
Author

You are right. I was in the wrong.

I would like to apologize for my tone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants