-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add custom cluster definition for ThirdReality Energy reporting #789
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
ClusterObjectDescriptor, | ||
ClusterObjectFieldDescriptor, | ||
) | ||
from chip.tlv import float32 | ||
from chip.tlv import float32, uint | ||
|
||
from matter_server.common.helpers.util import parse_attribute_path | ||
|
||
|
@@ -357,6 +357,94 @@ def attribute_type(cls) -> ClusterObjectFieldDescriptor: | |
value: float32 = 0 | ||
|
||
|
||
@dataclass | ||
class ThirdRealityMeteringCluster(Cluster, CustomClusterMixin): | ||
"""Custom (vendor-specific) PowerMetering cluster for ThirdReality.""" | ||
|
||
id: ClassVar[int] = 0x130DFC02 | ||
|
||
@ChipUtility.classproperty | ||
def descriptor(cls) -> ClusterObjectDescriptor: | ||
"""Return descriptor for this cluster.""" | ||
return ClusterObjectDescriptor( | ||
Fields=[ | ||
ClusterObjectFieldDescriptor( | ||
Label="currentSummationDelivered", Tag=0x0000, Type=uint | ||
), | ||
ClusterObjectFieldDescriptor( | ||
Label="instantaneousDemand", Tag=0x0400, Type=uint | ||
), | ||
] | ||
) | ||
|
||
currentSummationDelivered: uint | None = None | ||
instantaneousDemand: uint | None = None | ||
|
||
class Attributes: | ||
"""Attributes for the custom Cluster.""" | ||
|
||
@dataclass | ||
class CurrentSummationDelivered( | ||
ClusterAttributeDescriptor, CustomClusterAttributeMixin | ||
): | ||
"""CurrentSummationDelivered represents the most recent summed value of Energy consumed in the premise. | ||
|
||
CurrentSummationDelivered is updated continuously as new measurements are made. | ||
This attribute is Read only. | ||
Value is set to zero when leave command is received (beginning version 2.6.15), | ||
or local factory reset(10s) is performed on the device.. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Double period |
||
""" | ||
|
||
@ChipUtility.classproperty | ||
def cluster_id(cls) -> int: | ||
"""Return cluster id.""" | ||
return 0x130DFC02 | ||
|
||
@ChipUtility.classproperty | ||
def attribute_id(cls) -> int: | ||
"""Return attribute id.""" | ||
return 0x0000 | ||
|
||
@ChipUtility.classproperty | ||
def attribute_type(cls) -> ClusterObjectFieldDescriptor: | ||
"""Return attribute type.""" | ||
return ClusterObjectFieldDescriptor(Type=uint) | ||
|
||
value: uint = 0 | ||
|
||
@dataclass | ||
class InstantaneousDemand( | ||
ClusterAttributeDescriptor, CustomClusterAttributeMixin | ||
): | ||
""" | ||
InstantaneousDemand represents the current Demand of Energy delivered at the premise. | ||
|
||
Device is able measure only positive values indicate Demand delivered to the premise. | ||
InstantaneousDemand is updated continuously as new measurements are made. | ||
The frequency of updates to this field is specific to the metering device, | ||
but should be within the range of once every second to once every 5 seconds. | ||
The same multiplier and divisor values used for Current Summation Delivered (Energy) will be used. | ||
If connected load is below 1W, this attribute is set to 0 and no accumulation of energy is done. | ||
""" | ||
|
||
@ChipUtility.classproperty | ||
def cluster_id(cls) -> int: | ||
"""Return cluster id.""" | ||
return 0x130DFC02 | ||
|
||
@ChipUtility.classproperty | ||
def attribute_id(cls) -> int: | ||
"""Return attribute id.""" | ||
return 0x0400 | ||
|
||
@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() | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try to stay within 72 characters per line for docstrings in accordance with PEP8.
We don't need to repeat the class name in the docstring. That will help shorten it. Write eg: