| ''' |
| {{> header}} |
| ''' |
| |
| # This file contains generated struct, enum, command definition. |
| # Users are not expected to import this file, instead, users can use import chip.clusters, |
| # which will import all symbols from this file and can get a readable, pretty naming like |
| # clusters.OnOff.commands.OnCommand |
| |
| import typing |
| from dataclasses import dataclass, field |
| from enum import IntFlag |
| |
| from chip import ChipUtility |
| from chip.clusters.enum import MatterIntEnum |
| from chip.tlv import float32, uint |
| |
| from .ClusterObjects import (Cluster, ClusterAttributeDescriptor, ClusterCommand, ClusterEvent, ClusterObject, |
| ClusterObjectDescriptor, ClusterObjectFieldDescriptor) |
| from .Types import Nullable, NullValue |
| |
| |
| __all__ = [ |
| "Globals", |
| {{#zcl_clusters}} |
| "{{asUpperCamelCase name}}", |
| {{/zcl_clusters}} |
| ] |
| |
| |
| class Globals: |
| class Enums: |
| {{#zcl_enums}} |
| {{#if has_no_clusters}} |
| {{> enum_def cluster="Globals"}} |
| |
| {{/if}} |
| {{/zcl_enums}} |
| class Bitmaps: |
| {{#zcl_bitmaps}} |
| {{#if has_no_clusters}} |
| {{! Work around https://github.com/project-chip/zap/issues/1370 and manually filter out built-in bitmap types. }} |
| {{#if_is_atomic label}} |
| {{else}} |
| {{> bitmap_def }} |
| |
| {{/if_is_atomic}} |
| {{/if}} |
| {{/zcl_bitmaps}} |
| class Structs: |
| {{#zcl_structs}} |
| {{#if has_no_clusters}} |
| {{> struct_def cluster="Globals"}} |
| |
| {{/if}} |
| {{/zcl_structs}} |
| |
| {{#zcl_clusters}} |
| |
| @dataclass |
| class {{asUpperCamelCase name}}(Cluster): |
| id: typing.ClassVar[int] = {{asMEI manufacturerCode code}} |
| |
| @ChipUtility.classproperty |
| def descriptor(cls) -> ClusterObjectDescriptor: |
| return ClusterObjectDescriptor( |
| Fields=[ |
| {{#zcl_attributes_server}} |
| {{#if entryType}} |
| ClusterObjectFieldDescriptor(Label="{{ asLowerCamelCase label }}", Tag={{asMEI manufacturerCode code}}, Type={{zapTypeToPythonClusterObjectType entryType ns=(asUpperCamelCase parent.name)}}), |
| {{else}} |
| ClusterObjectFieldDescriptor(Label="{{ asLowerCamelCase label }}", Tag={{asMEI manufacturerCode code}}, Type={{zapTypeToPythonClusterObjectType type ns=(asUpperCamelCase parent.name)}}), |
| {{/if}} |
| {{/zcl_attributes_server}} |
| ]) |
| |
| {{#zcl_attributes_server}} |
| {{#if entryType}} |
| {{ asLowerCamelCase label }}: '{{zapTypeToPythonClusterObjectType entryType ns=(asUpperCamelCase parent.name)}}' = None |
| {{else}} |
| {{ asLowerCamelCase label }}: '{{zapTypeToPythonClusterObjectType type ns=(asUpperCamelCase parent.name)}}' = None |
| {{/if}} |
| {{/zcl_attributes_server}} |
| |
| {{#zcl_enums}} |
| {{#first}} |
| class Enums: |
| {{/first}} |
| {{> enum_def cluster=(asUpperCamelCase ../name)}} |
| |
| {{#last}} |
| {{/last}} |
| {{/zcl_enums}} |
| {{#zcl_bitmaps}} |
| {{#first}} |
| class Bitmaps: |
| {{/first}} |
| {{> bitmap_def }} |
| |
| {{/zcl_bitmaps}} |
| {{#zcl_structs}} |
| {{#first}} |
| class Structs: |
| {{/first}} |
| {{> struct_def cluster=(asUpperCamelCase parent.name) }} |
| |
| {{/zcl_structs}} |
| {{#zcl_commands}} |
| {{#first}} |
| class Commands: |
| {{/first}} |
| @dataclass |
| class {{asUpperCamelCase name}}(ClusterCommand): |
| cluster_id: typing.ClassVar[int] = {{ asMEI parent.manufacturerCode parent.code }} |
| command_id: typing.ClassVar[int] = {{ asMEI manufacturerCode code }} |
| {{#if (isServer source)}} |
| is_client: typing.ClassVar[bool] = False |
| {{else}} |
| is_client: typing.ClassVar[bool] = True |
| {{/if}} |
| {{~#if responseName}} |
| response_type: typing.ClassVar[str] = '{{asUpperCamelCase responseName}}' |
| {{else}} |
| response_type: typing.ClassVar[str] = None |
| {{/if}} |
| |
| @ChipUtility.classproperty |
| def descriptor(cls) -> ClusterObjectDescriptor: |
| return ClusterObjectDescriptor( |
| Fields=[ |
| {{#zcl_command_arguments}} |
| ClusterObjectFieldDescriptor(Label="{{ asLowerCamelCase label }}", Tag={{ index }}, Type={{zapTypeToPythonClusterObjectType type ns=(asUpperCamelCase parent.parent.name)}}), |
| {{/zcl_command_arguments}} |
| ]) |
| {{#if mustUseTimedInvoke}} |
| |
| @ChipUtility.classproperty |
| def must_use_timed_invoke(cls) -> bool: |
| return True |
| {{/if}} |
| {{#zcl_command_arguments}} |
| {{#first}} |
| |
| {{/first}} |
| {{ asLowerCamelCase label }}: '{{zapTypeToPythonClusterObjectType type ns=(asUpperCamelCase parent.parent.name)}}' = {{getPythonFieldDefault type ns=(asUpperCamelCase parent.parent.name)}} |
| {{/zcl_command_arguments}} |
| |
| {{/zcl_commands}} |
| {{#zcl_attributes_server}} |
| {{#first}} |
| class Attributes: |
| {{/first}} |
| @dataclass |
| class {{asUpperCamelCase label}}(ClusterAttributeDescriptor): |
| @ChipUtility.classproperty |
| def cluster_id(cls) -> int: |
| return {{ asMEI parent.manufacturerCode parent.code }} |
| |
| @ChipUtility.classproperty |
| def attribute_id(cls) -> int: |
| return {{ asMEI manufacturerCode code }} |
| |
| {{#if mustUseTimedWrite}} |
| @ChipUtility.classproperty |
| def must_use_timed_write(cls) -> bool: |
| return True |
| |
| {{/if}} |
| @ChipUtility.classproperty |
| def attribute_type(cls) -> ClusterObjectFieldDescriptor: |
| {{#if entryType}} |
| return ClusterObjectFieldDescriptor(Type={{zapTypeToPythonClusterObjectType entryType ns=(asUpperCamelCase parent.name)}}) |
| {{else}} |
| return ClusterObjectFieldDescriptor(Type={{zapTypeToPythonClusterObjectType type ns=(asUpperCamelCase parent.name)}}) |
| {{/if}} |
| |
| {{#if entryType}} |
| value: '{{zapTypeToPythonClusterObjectType entryType ns=(asUpperCamelCase parent.name)}}' = {{getPythonFieldDefault entryType ns=(asUpperCamelCase parent.name)}} |
| {{else}} |
| value: '{{zapTypeToPythonClusterObjectType type ns=(asUpperCamelCase parent.name)}}' = {{getPythonFieldDefault type ns=(asUpperCamelCase parent.name)}} |
| {{/if}} |
| |
| {{/zcl_attributes_server}} |
| {{#zcl_events}} |
| {{#first}} |
| class Events: |
| {{/first}} |
| @dataclass |
| class {{asUpperCamelCase name}}(ClusterEvent): |
| @ChipUtility.classproperty |
| def cluster_id(cls) -> int: |
| return {{ asMEI parent.manufacturerCode parent.code }} |
| |
| @ChipUtility.classproperty |
| def event_id(cls) -> int: |
| return {{ asMEI manufacturerCode code }} |
| |
| @ChipUtility.classproperty |
| def descriptor(cls) -> ClusterObjectDescriptor: |
| return ClusterObjectDescriptor( |
| Fields=[ |
| {{#zcl_event_fields}} |
| ClusterObjectFieldDescriptor(Label="{{ asLowerCamelCase name }}", Tag={{ fieldIdentifier }}, Type={{zapTypeToPythonClusterObjectType type ns=(asUpperCamelCase parent.parent.name)}}), |
| {{/zcl_event_fields}} |
| ]) |
| {{#zcl_event_fields}} |
| {{#first}} |
| |
| {{/first}} |
| {{ asLowerCamelCase name }}: '{{zapTypeToPythonClusterObjectType type ns=(asUpperCamelCase parent.parent.name)}}' = {{getPythonFieldDefault type ns=(asUpperCamelCase parent.parent.name)}} |
| {{/zcl_event_fields}} |
| |
| {{/zcl_events}} |
| {{/zcl_clusters}} |