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

How to write value to ElectricalEnergyMeasurement::Attributes::Accuracy::Id (CON-1326) #1075

Closed
svn-matterize opened this issue Sep 4, 2024 · 7 comments

Comments

@svn-matterize
Copy link

Trying to write a array value to the attribute ElectricalEnergyMeasurement::Attributes::Accuracy::Id
using esp_matter_array

ElectricalEnergyMeasurement::Structs::MeasurementAccuracyRangeStruct::Type energyAccuracyRanges[] = {
		{ .rangeMin = 0,
		  .rangeMax = 1'000'000'000'000'000, // 1 million Mwh
		  .percentMax = chip::MakeOptional(static_cast<chip::Percent100ths>(500)),
		  .percentMin = chip::MakeOptional(static_cast<chip::Percent100ths>(50)) }
	};

	ElectricalEnergyMeasurement::Structs::MeasurementAccuracyStruct::Type accuracy = {
		.measurementType = chip::app::Clusters::detail::MeasurementTypeEnum::kElectricalEnergy,
		.measured = true,
		.minMeasuredValue = 0,
		.maxMeasuredValue = 1'000'000'000'000'000, // 1 million Mwh
		.accuracyRanges = chip::app::DataModel::List<
			const ElectricalEnergyMeasurement::Structs::MeasurementAccuracyRangeStruct::Type>(
			energyAccuracyRanges)
	};
	arr_val = esp_matter_array((uint8_t *)&accuracy, sizeof(arr_val), 1);
	// err = attribute::set_val(attribute, &arr_val);
	err = attribute::update(Endpoint.kPlug, ElectricalEnergyMeasurement::Id,
				ElectricalEnergyMeasurement::Attributes::Accuracy::Id, &arr_val);
	if (err != ESP_OK) {
		ESP_LOGE(TAG, "Updated EnergyAccuracy failed");
	}

Device log during attribute update

I (2862) esp_matter_attribute: ********** W : Endpoint 0x0001's Cluster 0x00000091's Attribute 0x00000000 is <invalid type: 4> **********

Chip tool read back

[1725446179.843262][8020:8022] CHIP:DMG: ReportDataMessage =
[1725446179.843366][8020:8022] CHIP:DMG: {
[1725446179.843492][8020:8022] CHIP:DMG: 	AttributeReportIBs =
[1725446179.843806][8020:8022] CHIP:DMG: 	[
[1725446179.843979][8020:8022] CHIP:DMG: 		AttributeReportIB =
[1725446179.844116][8020:8022] CHIP:DMG: 		{
[1725446179.844245][8020:8022] CHIP:DMG: 			AttributeStatusIB =
[1725446179.844411][8020:8022] CHIP:DMG: 			{
[1725446179.844566][8020:8022] CHIP:DMG: 				AttributePathIB =
[1725446179.845094][8020:8022] CHIP:DMG: 				{
[1725446179.845569][8020:8022] CHIP:DMG: 					Endpoint = 0x1,
[1725446179.846278][8020:8022] CHIP:DMG: 					Cluster = 0x91,
[1725446179.846903][8020:8022] CHIP:DMG: 					Attribute = 0x0000_0000,
[1725446179.847421][8020:8022] CHIP:DMG: 				}
[1725446179.847961][8020:8022] CHIP:DMG: 					
[1725446179.848284][8020:8022] CHIP:DMG: 				StatusIB =
[1725446179.848313][8020:8022] CHIP:DMG: 				{
[1725446179.848338][8020:8022] CHIP:DMG: 					status = 0x89 (RESOURCE_EXHAUSTED),
[1725446179.848442][8020:8022] CHIP:DMG: 				},
[1725446179.848470][8020:8022] CHIP:DMG: 				
[1725446179.848557][8020:8022] CHIP:DMG: 			},
[1725446179.848583][8020:8022] CHIP:DMG: 			
[1725446179.848651][8020:8022] CHIP:DMG: 		},
[1725446179.849047][8020:8022] CHIP:DMG: 		
[1725446179.849136][8020:8022] CHIP:DMG: 	],
[1725446179.849159][8020:8022] CHIP:DMG: 	
[1725446179.849173][8020:8022] CHIP:DMG: 	SuppressResponse = true, 
[1725446179.849190][8020:8022] CHIP:DMG: 	InteractionModelRevision = 11
[1725446179.849264][8020:8022] CHIP:DMG: }
[1725446179.849314][8020:8022] CHIP:TOO: Response Failure: IM Error 0x00000589: General error: 0x89 (RESOURCE_EXHAUSTED)

while reading the attribute device log is

I (13352) esp_matter_attribute: ********** R : Endpoint 0x0001's Cluster 0x00000091's Attribute 0x00000000 is <invalid type: 4> **********
E (13362) esp_matter_attribute: Insufficient space for reading Endpoint 0x0001's Cluster 0x00000091's Attribute 0x00000000: required: 4, max: 2
@github-actions github-actions bot changed the title How to write value to ElectricalEnergyMeasurement::Attributes::Accuracy::Id How to write value to ElectricalEnergyMeasurement::Attributes::Accuracy::Id (CON-1326) Sep 4, 2024
@lboue
Copy link
Contributor

lboue commented Sep 12, 2024

Any news about this issue?

@jadhavrohit924
Copy link
Contributor

@svn-matterize Sorry for the delayed response, you cannot use esp_matter_array for storage because esp-matter doesn’t support array attribute storage.
There is API to set Accuracy in the connectedhomeip SDK SetMeasurementAccuracy. You have to use this.

@svn-matterize
Copy link
Author

svn-matterize commented Sep 16, 2024

@jadhavrohit924 , attribute storage, are you mentioning (ATTRIBUTE_FLAG_NONVOLATILE) nvs storage?
Is it possible to attribute::update/set attribute value using esp_matter_array, if the flag is (ATTRIBUTE_FLAG_NONE)?
How to form the struct value to array using esp_matter_array any example.

@jadhavrohit924
Copy link
Contributor

Independent of attribute quality, storage of arrays and structs are not possible using esp-matter because for such attributes there is delegate implementation in the connectedhomeip SDK. But delegate is missing for ElectricalEnergyMeasurement cluster so you have to reach to the SDK to update/set the attribute of this cluster.

@HamzaHajeir
Copy link

@svn-matterize Sorry for the delayed response, you cannot use esp_matter_array for storage because esp-matter doesn’t support array attribute storage. There is API to set Accuracy in the connectedhomeip SDK SetMeasurementAccuracy. You have to use this.

Hi there,

Calling this API emits an error CHIP_ERROR_INVALID_ARGUMENT, it seems there's a missing link between EndpointID and emberAfGetClusterServerEndpointIndex() function, as it does not find the corresponding endpoint.

What's really missing?

@HamzaHajeir
Copy link

@svn-matterize Sorry for the delayed response, you cannot use esp_matter_array for storage because esp-matter doesn’t support array attribute storage. There is API to set Accuracy in the connectedhomeip SDK SetMeasurementAccuracy. You have to use this.

Hi there,

Calling this API emits an error CHIP_ERROR_INVALID_ARGUMENT, it seems there's a missing link between EndpointID and emberAfGetClusterServerEndpointIndex() function, as it does not find the corresponding endpoint.

What's really missing?

Queued the function call to post initializing time solves the issue.

@jadhavrohit924
Copy link
Contributor

@svn-matterize Can you please close the issue if it is resolved?

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