mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 08:47:10 +00:00
Add discovery schema for Matter CumulativeEnergyExported (#144061)
* Update sensor.py to add CumulativeEnergyExported attribute * Report exported energy as positive value * Add snapshot * Add translation key
This commit is contained in:
parent
2f7fcb4f5e
commit
c26b3f519a
@ -744,6 +744,25 @@ DISCOVERY_SCHEMAS = [
|
|||||||
clusters.ElectricalEnergyMeasurement.Attributes.CumulativeEnergyImported,
|
clusters.ElectricalEnergyMeasurement.Attributes.CumulativeEnergyImported,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
MatterDiscoverySchema(
|
||||||
|
platform=Platform.SENSOR,
|
||||||
|
entity_description=MatterSensorEntityDescription(
|
||||||
|
key="ElectricalEnergyMeasurementCumulativeEnergyExported",
|
||||||
|
translation_key="energy_exported",
|
||||||
|
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)
|
||||||
|
measurement_to_ha=lambda x: x.energy,
|
||||||
|
),
|
||||||
|
entity_class=MatterSensor,
|
||||||
|
required_attributes=(
|
||||||
|
clusters.ElectricalEnergyMeasurement.Attributes.CumulativeEnergyExported,
|
||||||
|
),
|
||||||
|
),
|
||||||
MatterDiscoverySchema(
|
MatterDiscoverySchema(
|
||||||
platform=Platform.SENSOR,
|
platform=Platform.SENSOR,
|
||||||
entity_description=MatterSensorEntityDescription(
|
entity_description=MatterSensorEntityDescription(
|
||||||
|
@ -303,6 +303,9 @@
|
|||||||
"current_phase": {
|
"current_phase": {
|
||||||
"name": "Current phase"
|
"name": "Current phase"
|
||||||
},
|
},
|
||||||
|
"energy_exported": {
|
||||||
|
"name": "Energy exported"
|
||||||
|
},
|
||||||
"evse_fault_state": {
|
"evse_fault_state": {
|
||||||
"name": "Fault state",
|
"name": "Fault state",
|
||||||
"state": {
|
"state": {
|
||||||
|
@ -4254,6 +4254,64 @@
|
|||||||
'state': '-3.62',
|
'state': '-3.62',
|
||||||
})
|
})
|
||||||
# ---
|
# ---
|
||||||
|
# name: test_sensors[solar_power][sensor.solarpower_energy_exported-entry]
|
||||||
|
EntityRegistryEntrySnapshot({
|
||||||
|
'aliases': set({
|
||||||
|
}),
|
||||||
|
'area_id': None,
|
||||||
|
'capabilities': dict({
|
||||||
|
'state_class': <SensorStateClass.TOTAL_INCREASING: 'total_increasing'>,
|
||||||
|
}),
|
||||||
|
'config_entry_id': <ANY>,
|
||||||
|
'config_subentry_id': <ANY>,
|
||||||
|
'device_class': None,
|
||||||
|
'device_id': <ANY>,
|
||||||
|
'disabled_by': None,
|
||||||
|
'domain': 'sensor',
|
||||||
|
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
|
||||||
|
'entity_id': 'sensor.solarpower_energy_exported',
|
||||||
|
'has_entity_name': True,
|
||||||
|
'hidden_by': None,
|
||||||
|
'icon': None,
|
||||||
|
'id': <ANY>,
|
||||||
|
'labels': set({
|
||||||
|
}),
|
||||||
|
'name': None,
|
||||||
|
'options': dict({
|
||||||
|
'sensor': dict({
|
||||||
|
'suggested_display_precision': 3,
|
||||||
|
}),
|
||||||
|
'sensor.private': dict({
|
||||||
|
'suggested_unit_of_measurement': <UnitOfEnergy.KILO_WATT_HOUR: 'kWh'>,
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
'original_device_class': <SensorDeviceClass.ENERGY: 'energy'>,
|
||||||
|
'original_icon': None,
|
||||||
|
'original_name': 'Energy exported',
|
||||||
|
'platform': 'matter',
|
||||||
|
'previous_unique_id': None,
|
||||||
|
'supported_features': 0,
|
||||||
|
'translation_key': 'energy_exported',
|
||||||
|
'unique_id': '00000000000004D2-0000000000000001-MatterNodeDevice-1-ElectricalEnergyMeasurementCumulativeEnergyExported-145-2',
|
||||||
|
'unit_of_measurement': <UnitOfEnergy.KILO_WATT_HOUR: 'kWh'>,
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_sensors[solar_power][sensor.solarpower_energy_exported-state]
|
||||||
|
StateSnapshot({
|
||||||
|
'attributes': ReadOnlyDict({
|
||||||
|
'device_class': 'energy',
|
||||||
|
'friendly_name': 'SolarPower Energy exported',
|
||||||
|
'state_class': <SensorStateClass.TOTAL_INCREASING: 'total_increasing'>,
|
||||||
|
'unit_of_measurement': <UnitOfEnergy.KILO_WATT_HOUR: 'kWh'>,
|
||||||
|
}),
|
||||||
|
'context': <ANY>,
|
||||||
|
'entity_id': 'sensor.solarpower_energy_exported',
|
||||||
|
'last_changed': <ANY>,
|
||||||
|
'last_reported': <ANY>,
|
||||||
|
'last_updated': <ANY>,
|
||||||
|
'state': '42.279',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
# name: test_sensors[solar_power][sensor.solarpower_power-entry]
|
# name: test_sensors[solar_power][sensor.solarpower_power-entry]
|
||||||
EntityRegistryEntrySnapshot({
|
EntityRegistryEntrySnapshot({
|
||||||
'aliases': set({
|
'aliases': set({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user