#Home Assistant Matter integration ignores nullable CumulativeEnergyImported attribute

1 messages · Page 1 of 1 (latest)

buoyant owl
#

Hello community,

I encountered an issue where the Energy entity is not created in the web interface if its value is null.

From a Matter standard perspective, null is a valid value for the ElectricalEnergyMeasurement cluster attribute CumulativeEnergyImported.

I propose adjusting the code so that the Energy entity is created in the web interface even if its current value is null. I have described the situation in more detail here:
https://github.com/home-assistant/core/issues/162023

I would appreciate your feedback.

GitHub

The problem Hello dear community, I’ve encountered the following behavior in Matter when adding an Electrical Sensor device with the ElectricalEnergyMeasurement cluster (ClusterId 145 / 0x0091). Th...

vale depot
#

Is this validated as working incorrectly against the EOL Matter python server or the new Matter-js Server (available to test as a beta on the Matter Server App/Add-on since version 8.2) that will replace it soon?

buoyant owl
# vale depot Is this validated as working incorrectly against the EOL Matter python server or...

I am using the Python Matter server.

Alright, I will switch to Matter.js and report back with the results. However, based on my current observations, the behavior appears to be related to Home Assistant itself and the way it interprets sensor data. The Matter server correctly discovers the cluster and reads the attribute value from it.

In any case, I will verify the behavior using the Matter.js server as well.

vale depot
vale depot
buoyant owl
# vale depot If validated, you may want to post this issue in the Matter dev channel https://...

I tested the behavior with Matter.js.
The device is a bridge, so different sensors can be added dynamically even after Matter pairing has already been completed.

When the device has just started and CumulativeEnergyImported = null, the attribute is visible on the Matter server but not in the web interface.

After the attribute receives a valid value, it appears in the web interface within about 5 minutes.

As I understand it, the logic that prevents attributes with a null value from being displayed is implemented in MatterDiscoverySchema in this file:
https://github.com/home-assistant/core/blob/dev/homeassistant/components/matter/sensor.py#L1003

There is even a dedicated parameter allow_none_value. If allow_none_value=True is set like this:

MatterDiscoverySchema( platform=Platform.SENSOR, entity_description=MatterSensorEntityDescription( key="ElectricalEnergyMeasurementCumulativeEnergyImported", device_class=SensorDeviceClass.ENERGY, entity_category=EntityCategory.DIAGNOSTIC, native_unit_of_measurement=UnitOfEnergy.MILLIWATT_HOUR, suggested_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, suggested_display_precision=3, state_class=SensorStateClass.TOTAL_INCREASING, # id 0 of the EnergyMeasurementStruct is the cumulative energy (in mWh) device_to_ha=lambda x: x.energy, ), entity_class=MatterSensor, allow_none_value=True, required_attributes=( clusters.ElectricalEnergyMeasurement.Attributes.CumulativeEnergyImported, ), ),

then the Energy entity will appear in the web interface even if its current value is null.

To be honest, I am not sure which behavior is preferable:
whether the attribute should appear immediately with an “Unknown” state until real measurement values are received,
or appear later only once valid measured values are available.

In my opinion, the delayed appearance of the attribute slightly degrades the user experience.

GitHub

:house_with_garden: Open source home automation that puts local control and privacy first. - home-assistant/core