Skip to content

Comments

[RFC] Replace cluster handlers with entity attributes#657

Draft
puddly wants to merge 6 commits intozigpy:devfrom
puddly:puddly/drop-cluster-handlers
Draft

[RFC] Replace cluster handlers with entity attributes#657
puddly wants to merge 6 commits intozigpy:devfrom
puddly:puddly/drop-cluster-handlers

Conversation

@puddly
Copy link
Contributor

@puddly puddly commented Feb 17, 2026

See #653 for a different approach.

As an example:

    # This now matches clusters instead of cluster handlers
    _cluster_match = ClusterMatch(
        server_clusters=frozenset({PowerConfiguration.cluster_id}),
        profile_device_types=frozenset(
            {(zha.PROFILE_ID, SMARTTHINGS_ARRIVAL_SENSOR_DEVICE_TYPE)}
        ),
    )

    # There is a similar `_client_cluster_config`
    _server_cluster_config = {
        PowerConfiguration.cluster_id: ClusterConfig(
            bind=True,
            attributes={
                PowerConfiguration.AttributeDefs.battery_voltage: AttrConfig(
                    read_on_startup=False,
                    reporting=REPORT_CONFIG_BATTERY_SAVE,
                ),
                PowerConfiguration.AttributeDefs.battery_percentage_remaining: AttrConfig(
                    read_on_startup=False,
                    reporting=REPORT_CONFIG_BATTERY_SAVE,
                ),
                PowerConfiguration.AttributeDefs.battery_size: AttrConfig(
                    read_on_startup=True,
                ),
                PowerConfiguration.AttributeDefs.battery_quantity: AttrConfig(
                    read_on_startup=True,
                ),
            },
        ),
    }

For an individual cluster, all entities referencing that cluster will have their configuration combined and ZHA will sync it up.

A few thoughts:

  • Cluster handlers that do not create entities but are used for binding need to be explicitly handled. I think the simplest way to do this would be to merge Add event platform for client cluster #594 and live with having duplicate entities before device deprecating automation triggers.
  • We should maybe introduce version for entity configuration? Right now, changing a reporting interval or adding new attributes requires a user to manually click "reconfigure". An alternative would be to keep track of all binding and reporting config in the zigpy database and diff it with the ZHA defaults. We'd need to track whether configuration has been automatically configured or if it was manually pushed, in case someone overrides reporting.

@dmulcahey
Copy link
Contributor

Cluster handlers that do not create entities but are used for binding need to be explicitly handled. I think the simplest way to do this would be to merge #594 and live with having duplicate entities before device deprecating automation triggers.

I agree. I think adding event entity support first is the way to go

We should maybe introduce version for entity configuration? Right now, changing a reporting interval or adding new attributes requires a user to manually click "reconfigure". An alternative would be to keep track of all binding and reporting config in the zigpy database and diff it with the ZHA defaults. We'd need to track whether configuration has been automatically configured or if it was manually pushed, in case someone overrides reporting.

we need several things to do this correctly .... an additional thing that comes to mind is queuing of commands for sleepy devices for example (if we want to auto apply changes when a new version is created).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants