From 4734970c72f35de44deb7877c52f4ee1aff91e1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20BOU=C3=89?= Date: Fri, 16 Aug 2024 15:58:06 +0200 Subject: [PATCH] Eve cluster part2: Add EveWeather attributes (#855) Co-authored-by: Stefan Agner --- matter_server/common/custom_clusters.py | 46 ++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/matter_server/common/custom_clusters.py b/matter_server/common/custom_clusters.py index 58237468..38762f6e 100644 --- a/matter_server/common/custom_clusters.py +++ b/matter_server/common/custom_clusters.py @@ -85,7 +85,7 @@ def descriptor(cls) -> ClusterObjectDescriptor: Label="current", Tag=0x130A0009, Type=float32 ), ClusterObjectFieldDescriptor( - Label="altitude", Tag=0x130A0013, Type=int + Label="altitude", Tag=0x130A0013, Type=float32 ), ClusterObjectFieldDescriptor( Label="pressure", Tag=0x130A0014, Type=float32 @@ -99,6 +99,8 @@ def descriptor(cls) -> ClusterObjectDescriptor: wattAccumulatedControlPoint: float32 | None = None voltage: float32 | None = None current: float32 | None = None + altitude: float32 | None = None + pressure: float32 | None = None class Attributes: """Attributes for the Eve Cluster.""" @@ -243,6 +245,48 @@ def attribute_type(cls) -> ClusterObjectFieldDescriptor: value: float32 = 0 + @dataclass + class Altitude(ClusterAttributeDescriptor, CustomClusterAttributeMixin): + """Altitude Attribute within the Eve Cluster.""" + + @ChipUtility.classproperty + def cluster_id(cls) -> int: + """Return cluster id.""" + return 0x130AFC01 + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + """Return attribute id.""" + return 0x130A0013 + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + """Return attribute type.""" + return ClusterObjectFieldDescriptor(Type=float32) + + value: float32 = 0 + + @dataclass + class Pressure(ClusterAttributeDescriptor, CustomClusterAttributeMixin): + """Pressure Attribute within the Eve Cluster.""" + + @ChipUtility.classproperty + def cluster_id(cls) -> int: + """Return cluster id.""" + return 0x130AFC01 + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + """Return attribute id.""" + return 0x130A0014 + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + """Return attribute type.""" + return ClusterObjectFieldDescriptor(Type=float32) + + value: float32 = 0 + @dataclass class NeoCluster(Cluster, CustomClusterMixin):