Skip to content

Commit

Permalink
Add draft ElectricalMeasurement cluster definition (#1000)
Browse files Browse the repository at this point in the history
  • Loading branch information
dext0r authored Dec 11, 2024
1 parent 1ccee23 commit c17d986
Show file tree
Hide file tree
Showing 2 changed files with 310 additions and 0 deletions.
60 changes: 60 additions & 0 deletions dashboard/src/client/models/descriptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12267,5 +12267,65 @@ export const clusters: Record<number, ClusterDescription> = {
"type": "uint"
}
}
},
"2820": {
"id": 2820,
"label": "DraftElectricalMeasurementCluster",
"attributes": {
"1285": {
"id": 1285,
"cluster_id": 2820,
"label": "RmsVoltage",
"type": "uint"
},
"1288": {
"id": 1288,
"cluster_id": 2820,
"label": "RmsCurrent",
"type": "uint"
},
"1291": {
"id": 1291,
"cluster_id": 2820,
"label": "ActivePower",
"type": "uint"
},
"1536": {
"id": 1536,
"cluster_id": 2820,
"label": "AcVoltageMultiplier",
"type": "uint"
},
"1537": {
"id": 1537,
"cluster_id": 2820,
"label": "AcVoltageDivisor",
"type": "uint"
},
"1538": {
"id": 1538,
"cluster_id": 2820,
"label": "AcCurrentMultiplier",
"type": "uint"
},
"1539": {
"id": 1539,
"cluster_id": 2820,
"label": "AcCurrentDivisor",
"type": "uint"
},
"1540": {
"id": 1540,
"cluster_id": 2820,
"label": "AcPowerMultiplier",
"type": "uint"
},
"1541": {
"id": 1541,
"cluster_id": 2820,
"label": "AcPowerDivisor",
"type": "uint"
}
}
}
}
250 changes: 250 additions & 0 deletions matter_server/common/custom_clusters.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,256 @@ def attribute_type(cls) -> ClusterObjectFieldDescriptor:
value: uint = 0


@dataclass
class DraftElectricalMeasurementCluster(Cluster, CustomClusterMixin):
"""Custom ElectricalMetering cluster from Matter 1.0 draft specification."""

id: ClassVar[int] = 0x00000B04

@ChipUtility.classproperty
def descriptor(cls) -> ClusterObjectDescriptor:
"""Return descriptor for this cluster."""
return ClusterObjectDescriptor(
Fields=[
ClusterObjectFieldDescriptor(
Label="rmsVoltage", Tag=0x00000505, Type=uint
),
ClusterObjectFieldDescriptor(
Label="rmsCurrent", Tag=0x00000508, Type=uint
),
ClusterObjectFieldDescriptor(
Label="activePower", Tag=0x0000050B, Type=uint
),
ClusterObjectFieldDescriptor(
Label="acVoltageMultiplier", Tag=0x00000600, Type=uint
),
ClusterObjectFieldDescriptor(
Label="acVoltageDivisor", Tag=0x00000601, Type=uint
),
ClusterObjectFieldDescriptor(
Label="acCurrentMultiplier", Tag=0x00000602, Type=uint
),
ClusterObjectFieldDescriptor(
Label="acCurrentDivisor", Tag=0x00000603, Type=uint
),
ClusterObjectFieldDescriptor(
Label="acPowerMultiplier", Tag=0x00000604, Type=uint
),
ClusterObjectFieldDescriptor(
Label="acPowerDivisor", Tag=0x00000605, Type=uint
),
]
)

rmsVoltage: uint | None = None
rmsCurrent: uint | None = None
activePower: uint | None = None
acVoltageMultiplier: uint | None = None
acVoltageDivisor: uint | None = None
acCurrentMultiplier: uint | None = None
acCurrentDivisor: uint | None = None
acPowerMultiplier: uint | None = None
acPowerDivisor: uint | None = None

class Attributes:
"""Attributes for the custom Cluster."""

@dataclass
class RmsVoltage(ClusterAttributeDescriptor, CustomClusterAttributeMixin):
"""RmsVoltage Attribute within the DraftElectricalMeasurement Cluster."""

@ChipUtility.classproperty
def cluster_id(cls) -> int:
"""Return cluster id."""
return 0x00000B04

@ChipUtility.classproperty
def attribute_id(cls) -> int:
"""Return attribute id."""
return 0x00000505

@ChipUtility.classproperty
def attribute_type(cls) -> ClusterObjectFieldDescriptor:
"""Return attribute type."""
return ClusterObjectFieldDescriptor(Type=uint)

value: uint = 0

@dataclass
class RmsCurrent(ClusterAttributeDescriptor, CustomClusterAttributeMixin):
"""RmsCurrent Attribute within the DraftElectricalMeasurement Cluster."""

@ChipUtility.classproperty
def cluster_id(cls) -> int:
"""Return cluster id."""
return 0x00000B04

@ChipUtility.classproperty
def attribute_id(cls) -> int:
"""Return attribute id."""
return 0x00000508

@ChipUtility.classproperty
def attribute_type(cls) -> ClusterObjectFieldDescriptor:
"""Return attribute type."""
return ClusterObjectFieldDescriptor(Type=uint)

value: uint = 0

@dataclass
class ActivePower(ClusterAttributeDescriptor, CustomClusterAttributeMixin):
"""ActivePower Attribute within the DraftElectricalMeasurement Cluster."""

@ChipUtility.classproperty
def cluster_id(cls) -> int:
"""Return cluster id."""
return 0x00000B04

@ChipUtility.classproperty
def attribute_id(cls) -> int:
"""Return attribute id."""
return 0x0000050B

@ChipUtility.classproperty
def attribute_type(cls) -> ClusterObjectFieldDescriptor:
"""Return attribute type."""
return ClusterObjectFieldDescriptor(Type=uint)

value: uint = 0

@dataclass
class AcVoltageMultiplier(
ClusterAttributeDescriptor, CustomClusterAttributeMixin
):
"""AcVoltageMultiplier Attribute within the DraftElectricalMeasurement Cluster."""

@ChipUtility.classproperty
def cluster_id(cls) -> int:
"""Return cluster id."""
return 0x00000B04

@ChipUtility.classproperty
def attribute_id(cls) -> int:
"""Return attribute id."""
return 0x00000600

@ChipUtility.classproperty
def attribute_type(cls) -> ClusterObjectFieldDescriptor:
"""Return attribute type."""
return ClusterObjectFieldDescriptor(Type=uint)

value: uint = 0

@dataclass
class AcVoltageDivisor(ClusterAttributeDescriptor, CustomClusterAttributeMixin):
"""AcVoltageDivisor Attribute within the DraftElectricalMeasurement Cluster."""

@ChipUtility.classproperty
def cluster_id(cls) -> int:
"""Return cluster id."""
return 0x00000B04

@ChipUtility.classproperty
def attribute_id(cls) -> int:
"""Return attribute id."""
return 0x00000601

@ChipUtility.classproperty
def attribute_type(cls) -> ClusterObjectFieldDescriptor:
"""Return attribute type."""
return ClusterObjectFieldDescriptor(Type=uint)

value: uint = 0

@dataclass
class AcCurrentMultiplier(
ClusterAttributeDescriptor, CustomClusterAttributeMixin
):
"""AcCurrentMultiplier Attribute within the DraftElectricalMeasurement Cluster."""

@ChipUtility.classproperty
def cluster_id(cls) -> int:
"""Return cluster id."""
return 0x00000B04

@ChipUtility.classproperty
def attribute_id(cls) -> int:
"""Return attribute id."""
return 0x00000602

@ChipUtility.classproperty
def attribute_type(cls) -> ClusterObjectFieldDescriptor:
"""Return attribute type."""
return ClusterObjectFieldDescriptor(Type=uint)

value: uint = 0

@dataclass
class AcCurrentDivisor(ClusterAttributeDescriptor, CustomClusterAttributeMixin):
"""AcCurrentDivisor Attribute within the DraftElectricalMeasurement Cluster."""

@ChipUtility.classproperty
def cluster_id(cls) -> int:
"""Return cluster id."""
return 0x00000B04

@ChipUtility.classproperty
def attribute_id(cls) -> int:
"""Return attribute id."""
return 0x00000603

@ChipUtility.classproperty
def attribute_type(cls) -> ClusterObjectFieldDescriptor:
"""Return attribute type."""
return ClusterObjectFieldDescriptor(Type=uint)

value: uint = 0

@dataclass
class AcPowerMultiplier(
ClusterAttributeDescriptor, CustomClusterAttributeMixin
):
"""AcPowerMultiplier Attribute within the DraftElectricalMeasurement Cluster."""

@ChipUtility.classproperty
def cluster_id(cls) -> int:
"""Return cluster id."""
return 0x00000B04

@ChipUtility.classproperty
def attribute_id(cls) -> int:
"""Return attribute id."""
return 0x00000604

@ChipUtility.classproperty
def attribute_type(cls) -> ClusterObjectFieldDescriptor:
"""Return attribute type."""
return ClusterObjectFieldDescriptor(Type=uint)

value: uint = 0

@dataclass
class AcPowerDivisor(ClusterAttributeDescriptor, CustomClusterAttributeMixin):
"""AcPowerDivisor Attribute within the DraftElectricalMeasurement Cluster."""

@ChipUtility.classproperty
def cluster_id(cls) -> int:
"""Return cluster id."""
return 0x00000B04

@ChipUtility.classproperty
def attribute_id(cls) -> int:
"""Return attribute id."""
return 0x00000605

@ChipUtility.classproperty
def attribute_type(cls) -> ClusterObjectFieldDescriptor:
"""Return attribute type."""
return ClusterObjectFieldDescriptor(Type=uint)

value: uint = 0


def check_polled_attributes(node_data: MatterNodeData) -> set[str]:
"""Check if custom attributes are present in the node data that need to be polled."""
attributes_to_poll: set[str] = set()
Expand Down

0 comments on commit c17d986

Please sign in to comment.