994  Zigbee Device Binding and ZCL Cluster Configuration

994.1 Learning Objectives

By the end of this chapter, you will be able to:

  • Configure Device Binding: Set up direct switch-to-light control without coordinator routing
  • Understand Client/Server Clusters: Distinguish between input (server) and output (client) cluster roles
  • Design ZCL Clusters: Implement comprehensive cluster configurations for smart devices
  • Implement Energy Monitoring: Configure Electrical Measurement and Metering clusters
  • Ensure Zigbee 3.0 Compliance: Meet certification requirements for smart plugs

What is device binding? Binding creates a direct link between two devices so they communicate without going through a central hub. When you press a switch, the command goes directly to the light - even if the coordinator is offline.

Client vs Server Clusters:

Cluster Role Description Example Device
Server (Input) Receives commands, has attributes Light bulb
Client (Output) Sends commands to servers Wall switch

Why binding matters: - Lower latency: 25ms direct vs 100ms via hub - Offline resilience: Works without coordinator - Local automation: No cloud dependency

Prerequisites: - Zigbee Fundamentals - Zigbee Application Profiles

994.2 Prerequisites

Before diving into these examples, you should be familiar with:


994.3 Worked Example: Configuring Zigbee Device Binding for Direct Switch-to-Light Control

Scenario: A smart home has a Zigbee wall switch that needs to control a ceiling light directly, without routing commands through the coordinator. This enables local control even if the hub is offline, and reduces latency from ~100ms (hub-routed) to ~25ms (direct mesh).

Given: - Wall Switch: Address 0x0018, Endpoint 1, IEEE 0x00158D0001AB0001 - Ceiling Light: Address 0x0025, Endpoint 1, IEEE 0x00158D0001AB0002 - Coordinator: Address 0x0000 - Profile: Zigbee 3.0 Home Automation (0x0104) - Control Clusters: On/Off (0x0006), Level Control (0x0008) - Physical Distance: Switch and light are 4 meters apart (single hop)

994.3.1 Step 1: Verify Switch Endpoint Configuration

Simple Descriptor for Wall Switch (0x0018, Endpoint 1):
- Profile ID: 0x0104 (Zigbee HA)
- Device ID: 0x0103 (On/Off Light Switch)
- Device Version: 1

Input Clusters (Server - switch receives):
- Basic (0x0000): Device information
- Identify (0x0003): Blink LED on command

Output Clusters (Client - switch sends commands):
- On/Off (0x0006): Switch SENDS on/off/toggle commands
- Level Control (0x0008): Switch SENDS brightness commands
- Scenes (0x0005): Switch SENDS scene recall commands

Key point: On/Off cluster is OUTPUT (client) because
the switch ORIGINATES commands, not receives them.

994.3.2 Step 2: Verify Light Endpoint Configuration

Simple Descriptor for Ceiling Light (0x0025, Endpoint 1):
- Profile ID: 0x0104 (Zigbee HA)
- Device ID: 0x0101 (Dimmable Light)
- Device Version: 1

Input Clusters (Server - light receives):
- Basic (0x0000): Device information
- Identify (0x0003): Blink on command
- Groups (0x0004): Group membership management
- Scenes (0x0005): Scene storage and recall
- On/Off (0x0006): Light RECEIVES on/off/toggle commands
- Level Control (0x0008): Light RECEIVES brightness commands

Output Clusters (Client): None (light doesn't send commands)

Key point: On/Off cluster is INPUT (server) because
the light RECEIVES commands and acts on them.

994.3.3 Step 3: Create On/Off Cluster Binding on Switch

ZDO Bind Request (sent to Switch 0x0018):
- Source IEEE: 0x00158D0001AB0001 (Switch)
- Source Endpoint: 1
- Cluster ID: 0x0006 (On/Off)
- Destination Address Mode: 0x03 (IEEE 64-bit)
- Destination IEEE: 0x00158D0001AB0002 (Light)
- Destination Endpoint: 1

Switch Binding Table Entry Created:
+-------+----------+--------+---------+--------------------+--------+
| Index | Cluster  | SrcEP  | DstType | Destination        | DstEP  |
+-------+----------+--------+---------+--------------------+--------+
| 0     | 0x0006   | 1      | IEEE    | 0x00158D0001AB0002 | 1      |
+-------+----------+--------+---------+--------------------+--------+

Binding response: ZDO_SUCCESS (0x00)

994.3.4 Step 4: Create Level Control Cluster Binding

ZDO Bind Request (sent to Switch 0x0018):
- Source IEEE: 0x00158D0001AB0001
- Source Endpoint: 1
- Cluster ID: 0x0008 (Level Control)
- Destination Address Mode: 0x03 (IEEE 64-bit)
- Destination IEEE: 0x00158D0001AB0002
- Destination Endpoint: 1

Updated Switch Binding Table:
+-------+----------+--------+---------+--------------------+--------+
| Index | Cluster  | SrcEP  | DstType | Destination        | DstEP  |
+-------+----------+--------+---------+--------------------+--------+
| 0     | 0x0006   | 1      | IEEE    | 0x00158D0001AB0002 | 1      |
| 1     | 0x0008   | 1      | IEEE    | 0x00158D0001AB0002 | 1      |
+-------+----------+--------+---------+--------------------+--------+

994.3.5 Step 5: Test Direct Control Path

Test 1: Button Press (Toggle)

T=0ms:    User presses switch button
T=2ms:    Switch MCU detects GPIO interrupt
T=5ms:    Switch checks binding table for cluster 0x0006
T=6ms:    Binding found -> resolve IEEE to network address
T=10ms:   Address cache hit: 0x00158D0001AB0002 -> 0x0025
T=12ms:   ZCL Toggle command (0x02) constructed:
          - Frame Control: 0x01 (cluster-specific, to server)
          - Sequence: 0x42
          - Command: 0x02 (Toggle)
T=15ms:   APS frame sent to 0x0025, Endpoint 1
T=20ms:   Light receives frame via direct mesh link
T=22ms:   Light executes toggle: OFF -> ON
T=25ms:   Light sends Default Response (success)
T=28ms:   Switch receives ACK

Total latency: 28ms (direct) vs ~100ms (hub-routed)

994.3.6 Step 6: Test Dimming Control

Test 2: Long Press (Dim Up)

T=0ms:    User holds button for 500ms
T=500ms:  Switch detects long press, initiates Move command
T=505ms:  ZCL Move command constructed:
          - Cluster: 0x0008 (Level Control)
          - Command: 0x01 (Move)
          - Move Mode: 0x00 (Up)
          - Rate: 50 (units per second)
T=510ms:  Frame sent to Light 0x0025
T=520ms:  Light begins continuous dimming up
T=2500ms: User releases button
T=2505ms: Switch sends Stop command (0x03)
T=2515ms: Light stops at current level (e.g., 178 of 254)

Result: Smooth dimming from press-and-hold gesture

994.3.7 Step 7: Verify Offline Resilience

Test 3: Coordinator Offline

Scenario: Coordinator loses power

T=0ms:    Coordinator 0x0000 goes offline
T=5s:     Routers detect lost parent, re-route mesh
T=10s:    Network stabilized without coordinator

T=15s:    User presses switch
T=15.015s: Switch sends Toggle to Light
T=15.030s: Light responds, toggles state

LOCAL CONTROL WORKS WITHOUT COORDINATOR

Why? Binding uses IEEE address stored on switch.
Switch -> Light direct mesh path doesn't require coordinator.
Only new device joining, key distribution need coordinator.

994.3.8 Result

The wall switch now controls the ceiling light directly with 25-30ms latency, regardless of coordinator status. Both On/Off and Level Control clusters are bound, enabling toggle, on, off, and dimming commands.

Control Action ZCL Command Cluster Latency
Single Press Toggle (0x02) 0x0006 ~25ms
Double Press On (0x01) 0x0006 ~25ms
Triple Press Off (0x00) 0x0006 ~25ms
Long Press Move (0x01) 0x0008 ~25ms start
Release Stop (0x03) 0x0008 ~25ms
NoteKey Insight: Binding Best Practices

Zigbee binding creates a persistent association between a source endpoint’s output cluster and a destination endpoint’s input cluster. The binding is stored on the source device (switch), not the destination (light). This means:

  1. Bindings survive power cycles on both devices
  2. Multiple switches can bind to the same light (many-to-one)
  3. One switch can bind to multiple lights by adding more binding entries (one-to-many)
  4. Local mesh control works even when the coordinator is offline because the switch has the light’s IEEE address cached

For reliable binding, always use IEEE (64-bit) addresses rather than network (16-bit) addresses, as network addresses can change if a device rejoins the network.


994.4 Worked Example: Designing Zigbee Cluster Configuration for Smart Outlet with Energy Monitoring

Scenario: You are developing a smart outlet product that must: (1) control on/off state remotely, (2) report real-time power consumption, (3) track cumulative energy usage, and (4) implement overload protection. The outlet must be Zigbee 3.0 certified for interoperability with major smart home hubs.

Given: - Device: Single-outlet smart plug with internal current/voltage sensor - Profile: Zigbee 3.0 Home Automation (0x0104) - Network Role: Router (mains-powered, must route for mesh) - Maximum Load: 15A @ 120V (1800W) - Energy Sensor: ADE7953 IC (measures voltage, current, power, energy) - Network Address: 0x003A (assigned by coordinator) - IEEE Address: 0x00124B00ABCD1234

994.4.1 Step 1: Define Endpoint Structure

Endpoint 1: Smart Outlet Functions
- Profile ID: 0x0104 (Zigbee Home Automation)
- Device ID: 0x0051 (Smart Plug)
- Device Version: 1

Endpoint 242: Green Power Proxy (Required for Zigbee 3.0)
- Profile ID: 0xA1E0 (Green Power)
- Device ID: 0x0061 (GP Proxy Basic)

Why separate endpoints?
- Endpoint 1: Application-specific functionality
- Endpoint 242: Mandatory for Zigbee 3.0 certification
- Allows Green Power devices (battery-less) to interact

994.4.2 Step 2: Configure Server Clusters on Endpoint 1

Required Server Clusters (outlet provides these services):

Basic Cluster (0x0000):
- Attribute 0x0000: ZCLVersion = 0x03
- Attribute 0x0001: ApplicationVersion = 0x01
- Attribute 0x0003: HWVersion = 0x02
- Attribute 0x0004: ManufacturerName = "SmartPlug Inc"
- Attribute 0x0005: ModelIdentifier = "SP-1500-ZB"
- Attribute 0x0006: DateCode = "20251215"
- Attribute 0x0007: PowerSource = 0x01 (Mains, single phase)

Identify Cluster (0x0003):
- Attribute 0x0000: IdentifyTime = 0 (seconds remaining)
- Command 0x00: Identify (flash LED for IdentifyTime seconds)
- Command 0x01: IdentifyQuery

Groups Cluster (0x0004):
- Attribute 0x0000: NameSupport = 0x80 (names supported)
- Command 0x00: AddGroup
- Command 0x01: ViewGroup
- Command 0x02: GetGroupMembership
- Command 0x03: RemoveGroup
- Command 0x04: RemoveAllGroups

Scenes Cluster (0x0005):
- Attribute 0x0000: SceneCount = 0
- Attribute 0x0001: CurrentScene = 0x00
- Attribute 0x0002: CurrentGroup = 0x0000
- Attribute 0x0003: SceneValid = FALSE
- Attribute 0x0004: NameSupport = 0x80
- Command 0x00: AddScene
- Command 0x01: ViewScene
- Command 0x02: RemoveScene
- Command 0x05: RecallScene
- Command 0x06: GetSceneMembership

On/Off Cluster (0x0006):
- Attribute 0x0000: OnOff = 0x00 (Off initially)
- Attribute 0x4000: GlobalSceneControl = TRUE
- Attribute 0x4001: OnTime = 0
- Attribute 0x4002: OffWaitTime = 0
- Command 0x00: Off
- Command 0x01: On
- Command 0x02: Toggle
- Command 0x40: OffWithEffect
- Command 0x41: OnWithRecallGlobalScene
- Command 0x42: OnWithTimedOff

994.4.3 Step 3: Configure Energy Monitoring Clusters

Electrical Measurement Cluster (0x0B04) - Real-time readings:

Measurement Type Attributes:
- Attribute 0x0000: MeasurementType = 0x00000008 (AC Active Power)

AC (Single Phase) Measurement Attributes:
- Attribute 0x0505: RMSVoltage = 1200 (120.0V with divisor 10)
- Attribute 0x0506: RMSVoltageMin = 1000 (100.0V - brownout)
- Attribute 0x0507: RMSVoltageMax = 1300 (130.0V - overvoltage)
- Attribute 0x0508: RMSCurrent = 52 (0.52A with divisor 100)
- Attribute 0x0509: RMSCurrentMin = 0
- Attribute 0x050A: RMSCurrentMax = 1500 (15.0A max load)
- Attribute 0x050B: ActivePower = 62 (62W)
- Attribute 0x050D: ReactivePower = 8 (8VAR)
- Attribute 0x050E: ApparentPower = 63 (63VA)
- Attribute 0x050F: PowerFactor = 98 (0.98 PF)

Formatting Attributes:
- Attribute 0x0600: ACVoltageMultiplier = 1
- Attribute 0x0601: ACVoltageDivisor = 10
- Attribute 0x0602: ACCurrentMultiplier = 1
- Attribute 0x0603: ACCurrentDivisor = 100
- Attribute 0x0604: ACPowerMultiplier = 1
- Attribute 0x0605: ACPowerDivisor = 1

Metering Cluster (0x0702) - Cumulative energy:

Reading Information Attributes:
- Attribute 0x0000: CurrentSummationDelivered = 123456
  (123.456 kWh with divisor 1000)
- Attribute 0x0200: Status = 0x00 (Normal operation)
- Attribute 0x0300: UnitOfMeasure = 0x00 (kWh)
- Attribute 0x0301: Multiplier = 1
- Attribute 0x0302: Divisor = 1000
- Attribute 0x0303: SummationFormatting = 0x2B
  (3 digits after decimal, 5 digits before)
- Attribute 0x0306: MeteringDeviceType = 0x00 (Electric)

994.4.4 Step 4: Implement Overload Protection Cluster

Device Temperature Configuration Cluster (0x0002):
- Attribute 0x0000: CurrentTemperature = 35 (35C internal temp)
- Attribute 0x0001: MinTempExperienced = 20
- Attribute 0x0002: MaxTempExperienced = 45
- Attribute 0x0010: OverTempTotalDuration = 0
- Attribute 0x0011: DeviceTempAlarmMask = 0x02 (high temp alarm)
- Attribute 0x0012: LowTempThreshold = 0
- Attribute 0x0013: HighTempThreshold = 70 (shutdown at 70C)

Overload Protection Logic (firmware):
void monitor_safety() {
    uint16_t current = read_rms_current();  // in 0.01A units
    int16_t temp = read_internal_temp();     // in degrees C

    // Over-current protection (15A limit)
    if (current > 1500) {
        set_outlet_state(OFF);
        send_zcl_alarm(OVER_CURRENT_ALARM);
        log_event("Overcurrent: %d.%02dA", current/100, current%100);
    }

    // Over-temperature protection (70C limit)
    if (temp > 70) {
        set_outlet_state(OFF);
        send_zcl_alarm(OVER_TEMP_ALARM);
        log_event("Overtemp: %dC", temp);
    }

    // Update ZCL attributes
    update_attribute(0x0B04, 0x0508, current);
    update_attribute(0x0002, 0x0000, temp);
}

994.4.5 Step 5: Configure Attribute Reporting

Power Reporting Configuration:

Configure Reporting Command to Outlet:
- Cluster: 0x0B04 (Electrical Measurement)
- Attribute: 0x050B (ActivePower)
- Data Type: 0x29 (INT16S)
- Minimum Interval: 10 seconds
- Maximum Interval: 300 seconds
- Reportable Change: 5 (5W threshold)

Energy Reporting Configuration:
- Cluster: 0x0702 (Metering)
- Attribute: 0x0000 (CurrentSummationDelivered)
- Data Type: 0x25 (UINT48)
- Minimum Interval: 60 seconds
- Maximum Interval: 900 seconds (15 minutes)
- Reportable Change: 100 (0.1 kWh threshold)

Result: Hub receives power updates every 10-300 seconds
(or immediately if change > 5W), energy updates every
1-15 minutes (or immediately if change > 0.1 kWh).

994.4.6 Step 6: Test ZCL Command Sequence

Scenario: User turns on outlet via hub app

T=0ms:    Hub sends ZCL On command to 0x003A/EP1
          Frame: [01 42 01] (FrameCtrl, SeqNum, On)
T=15ms:   Outlet receives, activates relay
T=20ms:   Outlet sends Default Response (success)
T=25ms:   Outlet updates OnOff attribute to 0x01
T=30ms:   Outlet sends Report Attributes (if reporting configured)
          - OnOff: 0x01

T=1000ms: Power stabilizes, ADE7953 samples
T=1010ms: Outlet reads: 120.2V, 0.52A, 62W
T=1020ms: Report Attributes sent:
          - RMSVoltage: 1202
          - RMSCurrent: 52
          - ActivePower: 62

Hub displays: "Smart Outlet ON - 62W"

994.4.7 Step 7: Verify Zigbee 3.0 Certification Requirements

Mandatory Clusters for Smart Plug (0x0051):

[CHECK] Basic (0x0000) - Device identification
[CHECK] Identify (0x0003) - Physical identification
[CHECK] Groups (0x0004) - Group membership
[CHECK] Scenes (0x0005) - Scene participation
[CHECK] On/Off (0x0006) - Primary function

Optional but Recommended:
[CHECK] Electrical Measurement (0x0B04) - Real-time power
[CHECK] Metering (0x0702) - Energy accumulation
[CHECK] Device Temperature (0x0002) - Safety monitoring

Green Power Proxy (Endpoint 242):
[CHECK] GP Proxy Table - Store GP device info
[CHECK] GP Sink Table - Forward GP commands

Base Device Behavior (BDB):
[CHECK] Touchlink commissioning capable
[CHECK] Network steering (join existing network)
[CHECK] Finding & Binding support

All requirements met for Zigbee 3.0 Smart Plug certification.

994.4.8 Result

The smart outlet is configured with 6 clusters providing comprehensive functionality: remote on/off control, real-time power monitoring, cumulative energy tracking, safety protection, scene/group support, and Zigbee 3.0 compliance.

Cluster ID Function Key Attributes
Basic 0x0000 Device info ManufacturerName, ModelID
Identify 0x0003 Physical ID IdentifyTime
Groups 0x0004 Group control Group table (16 max)
Scenes 0x0005 Scene recall SceneCount, CurrentScene
On/Off 0x0006 Power control OnOff state
Elec Meas 0x0B04 Real-time power Voltage, Current, Power
Metering 0x0702 Energy tracking SummationDelivered (kWh)
Device Temp 0x0002 Safety CurrentTemperature, alarms
NoteKey Insight: Energy Monitoring Cluster Design

Zigbee 3.0 smart outlets require careful cluster configuration to achieve both certification compliance and practical functionality. Key distinctions:

Electrical Measurement (0x0B04) reports instantaneous values (voltage, current, power at this moment)

Metering (0x0702) accumulates consumption over time (total kWh since installation)

For certification: - Basic and Identify clusters are mandatory for all devices - Groups and Scenes enable integration with automation systems - Green Power Proxy endpoint allows the outlet to forward commands from battery-less switches

Always implement safety features (overcurrent, overtemperature) in firmware with hardware backup, as these cannot be reliably handled by ZCL alone.


994.5 Visual Reference: Binding Architecture

%%{init: {'theme': 'base', 'themeVariables': {'primaryColor': '#2C3E50', 'primaryTextColor': '#ffffff', 'primaryBorderColor': '#16A085', 'lineColor': '#E67E22', 'secondaryColor': '#16A085', 'tertiaryColor': '#7F8C8D'}}}%%
flowchart LR
    subgraph Switch["Wall Switch (0x0018)"]
        SW_EP1["Endpoint 1"]
        SW_BT["Binding Table"]
        SW_ONOFF["On/Off Client"]
        SW_LEVEL["Level Client"]
    end

    subgraph Light["Ceiling Light (0x0025)"]
        LT_EP1["Endpoint 1"]
        LT_ONOFF["On/Off Server"]
        LT_LEVEL["Level Server"]
    end

    SW_EP1 --> SW_ONOFF
    SW_EP1 --> SW_LEVEL
    SW_ONOFF -->|"Binding 0x0006"| SW_BT
    SW_LEVEL -->|"Binding 0x0008"| SW_BT

    SW_BT ==>|"Direct Mesh"| LT_EP1
    LT_EP1 --> LT_ONOFF
    LT_EP1 --> LT_LEVEL

    style SW_EP1 fill:#2C3E50,color:#fff
    style SW_BT fill:#E67E22,color:#fff
    style LT_EP1 fill:#16A085,color:#fff


994.6 Summary

This chapter covered two essential Zigbee implementation patterns:

  • Device Binding: Demonstrated how to configure direct switch-to-light control with 25ms latency, working even when the coordinator is offline
  • Client/Server Cluster Roles: Explained that switches have OUTPUT (client) clusters for commands they send, while lights have INPUT (server) clusters for commands they receive
  • ZCL Cluster Configuration: Designed a complete smart outlet with 8 clusters covering control, energy monitoring, safety, and certification requirements
  • Energy Monitoring: Showed the difference between Electrical Measurement (real-time) and Metering (cumulative) clusters
  • Zigbee 3.0 Compliance: Listed mandatory and optional clusters needed for certification

994.7 What’s Next

The next chapter provides Zigbee Practical Exercises covering XBee setup, Zigbee2MQTT integration, OTA firmware updates, and Matter migration planning.

Prerequisites: - Zigbee Fundamentals - Core protocol concepts - Zigbee Application Profiles - ZCL clusters

Next Steps: - Zigbee Practical Exercises - Hands-on projects - Zigbee Network Scaling Examples - Group messaging