Skip to content

Commit 2248584

Browse files
Add Matter Electrical measurements additional attributes (home-assistant#150188)
Co-authored-by: Martin Hjelmare <[email protected]>
1 parent d9b6f82 commit 2248584

File tree

5 files changed

+371
-293
lines changed

5 files changed

+371
-293
lines changed

homeassistant/components/matter/sensor.py

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,13 @@
3232
REVOLUTIONS_PER_MINUTE,
3333
EntityCategory,
3434
Platform,
35+
UnitOfApparentPower,
3536
UnitOfElectricCurrent,
3637
UnitOfElectricPotential,
3738
UnitOfEnergy,
3839
UnitOfPower,
3940
UnitOfPressure,
41+
UnitOfReactivePower,
4042
UnitOfTemperature,
4143
UnitOfTime,
4244
UnitOfVolume,
@@ -782,10 +784,43 @@ def _update_from_device(self) -> None:
782784
clusters.ElectricalPowerMeasurement.Attributes.ActivePower,
783785
),
784786
),
787+
MatterDiscoverySchema(
788+
platform=Platform.SENSOR,
789+
entity_description=MatterSensorEntityDescription(
790+
key="ElectricalPowerMeasurementApparentPower",
791+
device_class=SensorDeviceClass.APPARENT_POWER,
792+
entity_category=EntityCategory.DIAGNOSTIC,
793+
native_unit_of_measurement=UnitOfApparentPower.MILLIVOLT_AMPERE,
794+
suggested_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE,
795+
suggested_display_precision=2,
796+
state_class=SensorStateClass.MEASUREMENT,
797+
),
798+
entity_class=MatterSensor,
799+
required_attributes=(
800+
clusters.ElectricalPowerMeasurement.Attributes.ApparentPower,
801+
),
802+
),
803+
MatterDiscoverySchema(
804+
platform=Platform.SENSOR,
805+
entity_description=MatterSensorEntityDescription(
806+
key="ElectricalPowerMeasurementReactivePower",
807+
device_class=SensorDeviceClass.REACTIVE_POWER,
808+
entity_category=EntityCategory.DIAGNOSTIC,
809+
native_unit_of_measurement=UnitOfReactivePower.MILLIVOLT_AMPERE_REACTIVE,
810+
suggested_unit_of_measurement=UnitOfReactivePower.VOLT_AMPERE_REACTIVE,
811+
suggested_display_precision=2,
812+
state_class=SensorStateClass.MEASUREMENT,
813+
),
814+
entity_class=MatterSensor,
815+
required_attributes=(
816+
clusters.ElectricalPowerMeasurement.Attributes.ReactivePower,
817+
),
818+
),
785819
MatterDiscoverySchema(
786820
platform=Platform.SENSOR,
787821
entity_description=MatterSensorEntityDescription(
788822
key="ElectricalPowerMeasurementVoltage",
823+
translation_key="voltage",
789824
device_class=SensorDeviceClass.VOLTAGE,
790825
entity_category=EntityCategory.DIAGNOSTIC,
791826
native_unit_of_measurement=UnitOfElectricPotential.MILLIVOLT,
@@ -796,10 +831,45 @@ def _update_from_device(self) -> None:
796831
entity_class=MatterSensor,
797832
required_attributes=(clusters.ElectricalPowerMeasurement.Attributes.Voltage,),
798833
),
834+
MatterDiscoverySchema(
835+
platform=Platform.SENSOR,
836+
entity_description=MatterSensorEntityDescription(
837+
key="ElectricalPowerMeasurementRMSVoltage",
838+
translation_key="rms_voltage",
839+
device_class=SensorDeviceClass.VOLTAGE,
840+
entity_category=EntityCategory.DIAGNOSTIC,
841+
native_unit_of_measurement=UnitOfElectricPotential.MILLIVOLT,
842+
suggested_unit_of_measurement=UnitOfElectricPotential.VOLT,
843+
suggested_display_precision=0,
844+
state_class=SensorStateClass.MEASUREMENT,
845+
),
846+
entity_class=MatterSensor,
847+
required_attributes=(
848+
clusters.ElectricalPowerMeasurement.Attributes.RMSVoltage,
849+
),
850+
),
851+
MatterDiscoverySchema(
852+
platform=Platform.SENSOR,
853+
entity_description=MatterSensorEntityDescription(
854+
key="ElectricalPowerMeasurementApparentCurrent",
855+
translation_key="apparent_current",
856+
device_class=SensorDeviceClass.CURRENT,
857+
entity_category=EntityCategory.DIAGNOSTIC,
858+
native_unit_of_measurement=UnitOfElectricCurrent.MILLIAMPERE,
859+
suggested_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
860+
suggested_display_precision=2,
861+
state_class=SensorStateClass.MEASUREMENT,
862+
),
863+
entity_class=MatterSensor,
864+
required_attributes=(
865+
clusters.ElectricalPowerMeasurement.Attributes.ApparentCurrent,
866+
),
867+
),
799868
MatterDiscoverySchema(
800869
platform=Platform.SENSOR,
801870
entity_description=MatterSensorEntityDescription(
802871
key="ElectricalPowerMeasurementActiveCurrent",
872+
translation_key="active_current",
803873
device_class=SensorDeviceClass.CURRENT,
804874
entity_category=EntityCategory.DIAGNOSTIC,
805875
native_unit_of_measurement=UnitOfElectricCurrent.MILLIAMPERE,
@@ -812,6 +882,40 @@ def _update_from_device(self) -> None:
812882
clusters.ElectricalPowerMeasurement.Attributes.ActiveCurrent,
813883
),
814884
),
885+
MatterDiscoverySchema(
886+
platform=Platform.SENSOR,
887+
entity_description=MatterSensorEntityDescription(
888+
key="ElectricalPowerMeasurementReactiveCurrent",
889+
translation_key="reactive_current",
890+
device_class=SensorDeviceClass.CURRENT,
891+
entity_category=EntityCategory.DIAGNOSTIC,
892+
native_unit_of_measurement=UnitOfElectricCurrent.MILLIAMPERE,
893+
suggested_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
894+
suggested_display_precision=2,
895+
state_class=SensorStateClass.MEASUREMENT,
896+
),
897+
entity_class=MatterSensor,
898+
required_attributes=(
899+
clusters.ElectricalPowerMeasurement.Attributes.ReactiveCurrent,
900+
),
901+
),
902+
MatterDiscoverySchema(
903+
platform=Platform.SENSOR,
904+
entity_description=MatterSensorEntityDescription(
905+
key="ElectricalPowerMeasurementRMSCurrent",
906+
translation_key="rms_current",
907+
device_class=SensorDeviceClass.CURRENT,
908+
entity_category=EntityCategory.DIAGNOSTIC,
909+
native_unit_of_measurement=UnitOfElectricCurrent.MILLIAMPERE,
910+
suggested_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
911+
suggested_display_precision=2,
912+
state_class=SensorStateClass.MEASUREMENT,
913+
),
914+
entity_class=MatterSensor,
915+
required_attributes=(
916+
clusters.ElectricalPowerMeasurement.Attributes.RMSCurrent,
917+
),
918+
),
815919
MatterDiscoverySchema(
816920
platform=Platform.SENSOR,
817921
entity_description=MatterSensorEntityDescription(

homeassistant/components/matter/strings.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,24 @@
451451
},
452452
"window_covering_target_position": {
453453
"name": "Target opening position"
454+
},
455+
"active_current": {
456+
"name": "Active current"
457+
},
458+
"apparent_current": {
459+
"name": "Apparent current"
460+
},
461+
"reactive_current": {
462+
"name": "Reactive current"
463+
},
464+
"rms_current": {
465+
"name": "Effective current"
466+
},
467+
"rms_voltage": {
468+
"name": "Effective voltage"
469+
},
470+
"voltage": {
471+
"name": "Voltage"
454472
}
455473
},
456474
"switch": {

tests/components/matter/fixtures/nodes/silabs_dishwasher.json

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -588,31 +588,9 @@
588588
"10": 101
589589
}
590590
],
591-
"2/144/4": 120000,
592-
"2/144/5": 0,
593-
"2/144/6": 0,
594-
"2/144/7": 0,
595591
"2/144/8": 0,
596-
"2/144/9": 0,
597-
"2/144/10": 0,
598592
"2/144/11": 120000,
599593
"2/144/12": 0,
600-
"2/144/13": 0,
601-
"2/144/14": 60,
602-
"2/144/15": [
603-
{
604-
"0": 1,
605-
"1": 100000
606-
}
607-
],
608-
"2/144/16": [
609-
{
610-
"0": 1,
611-
"1": 100000
612-
}
613-
],
614-
"2/144/17": 9800,
615-
"2/144/18": 0,
616594
"2/144/65532": 31,
617595
"2/144/65533": 1,
618596
"2/144/65528": [],

tests/components/matter/fixtures/nodes/silabs_laundrywasher.json

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -832,31 +832,9 @@
832832
"10": 129
833833
}
834834
],
835-
"2/144/4": 120000,
836-
"2/144/5": 0,
837-
"2/144/6": 0,
838-
"2/144/7": 0,
839835
"2/144/8": 0,
840-
"2/144/9": 0,
841-
"2/144/10": 0,
842836
"2/144/11": 120000,
843837
"2/144/12": 0,
844-
"2/144/13": 0,
845-
"2/144/14": 60,
846-
"2/144/15": [
847-
{
848-
"0": 1,
849-
"1": 100000
850-
}
851-
],
852-
"2/144/16": [
853-
{
854-
"0": 1,
855-
"1": 100000
856-
}
857-
],
858-
"2/144/17": 9800,
859-
"2/144/18": 0,
860838
"2/144/65532": 31,
861839
"2/144/65533": 1,
862840
"2/144/65528": [],

0 commit comments

Comments
 (0)