TimeSynchronization Cluster

Cluster ID: 0x0038  |  Endpoint: Fixed on Endpoint 0 (Root Endpoint)

TimeSynchronization handles Matter device time management — telling the device "what time is it," "what timezone," and "is there daylight saving time." Many features depend on accurate time: scheduled automations, log timestamps, certificate validity checks, energy statistics, etc. Without time synchronization, these features either won't work or will produce incorrect results.

Features

TimeSynchronization Cluster defines three Features; devices choose which to support based on their capabilities: TZ (timezone management) supports timezone lists and DST configuration; NTPC (NTP client) can actively obtain time from NTP servers; NTPS (NTP server) can serve as a time source providing time to other devices. Devices without any Feature enabled only support the most basic SetUTCTime manual time setting.

Commands

TimeSynchronization Cluster has 5 request commands, with SetTimeZone having a corresponding response command. The most basic SetUTCTime is supported by all devices; other commands require the device to enable the corresponding Feature. Click a command ID in the table below to jump to its detailed description.

ID Name Description Required Feature
0x00 SetUTCTime Set the device's UTC time None
0x01 SetTrustedTimeSource Specify a trusted time source node None
0x02 SetTimeZone Set timezone list TZ
0x04 SetDSTOffset Set DST offset list TZ
0x05 SetDefaultNTP Set default NTP server address NTPC

SetUTCTime — Set UTC Time (0x00)

Directly sets the device's UTC time. This is the most basic time setting method — during commissioning, the Commissioner typically uses this command to inject the current time into the device. Upon receiving it, the device updates both Granularity and TimeSource attributes.

ParameterTypeDescription
UTCTime epoch_us UTC time, microsecond-level (microseconds since 2000-01-01T00:00:00Z)
Granularity GranularityEnum Time granularity level — tells the device how precise this time is
TimeSource TimeSourceEnum Time source — tells the device where this time was obtained from
Time Precision Requirements

The device evaluates time reliability based on the Granularity parameter. If the device already has a higher-precision time source (e.g. already synced from NTP), it may reject SetUTCTime requests from lower-precision sources. During commissioning, the device typically has no time, so the setting will always succeed.

Usage Scenarios

The most common usage is the Commissioner immediately calling SetUTCTime after commissioning to set the device's initial time. Granularity is typically passed as SecondsGranularity (2) or MillisecondsGranularity (3), and TimeSource as Admin (2) (indicating time was manually set by an administrator).

SetTrustedTimeSource — Set Trusted Time Source (0x01)

Specifies a node within the Fabric as a trusted time source. The device will periodically synchronize time from this node, similar to a local network "time authority." Setting to null clears the trusted time source.

ParameterTypeDescription
TrustedTimeSource struct / null Trusted time source node info, containing NodeID and Endpoint. Set to null to clear

TrustedTimeSource Struct

FieldTypeDescription
NodeID node-id Time source node's Node ID
Endpoint endpoint-no Endpoint where TimeSynchronization Cluster resides on that node (typically 0)
Usage Scenarios

In a Fabric, a Hub (e.g. Apple HomePod, Google Nest Hub) typically serves as the trusted time source. The Commissioner sets TrustedTimeSource to point to the Hub's Node ID during commissioning, after which the device will automatically synchronize time from the Hub without an external NTP server. This is especially important for Thread devices without direct internet access.

SetTimeZone — Set Timezone (0x02)

Sets the device's timezone list. Can contain multiple timezone entries, each with an effective time (validAt), to support historical or future timezone changes. After successful processing, the device returns SetTimeZoneResponse, informing the Commissioner whether DST offset setting is needed next.

ParameterTypeDescription
TimeZone list<TimeZoneStruct> Timezone list (up to TimeZoneListMaxSize entries)

TimeZoneStruct Struct

FieldTypeDescription
Offset int32 Offset from UTC, in seconds. E.g. UTC+8 = 28800, UTC-5 = -18000
ValidAt epoch_us Effective time for this entry (microsecond-level epoch). First entry's ValidAt must be 0
Name string (Optional) IANA timezone name (e.g. "Asia/Shanghai"), used for display and DST database lookup

SetTimeZoneResponse Response Fields

FieldTypeDescription
DSTOffsetRequired bool true means the device needs the Commissioner to follow up with SetDSTOffset
Meaning of DSTOffsetRequired

If the device has a built-in IANA timezone database (TimeZoneDatabase = Full), the device can calculate DST rules on its own, responding with DSTOffsetRequired = false. If the device has no timezone database (TimeZoneDatabase = None), it returns true, and the Commissioner must manually provide DST offsets.

Usage Scenarios

The user moves to a new timezone, or the device needs timezone setup during first commissioning. For Chinese users, typically only one record is needed: Offset = 28800 (UTC+8), ValidAt = 0, Name = "Asia/Shanghai". China doesn't observe DST, so DSTOffset can be set to a single record with offset 0.

SetDSTOffset — Set DST Offset (0x04)

Sets the daylight saving time (DST) offset list. Each entry defines an additional offset within a time range. The device matches entries based on current time and adds the offset on top of the timezone offset to calculate local time.

ParameterTypeDescription
DSTOffset list<DSTOffsetStruct> DST offset list (up to DSTOffsetListMaxSize entries)

DSTOffsetStruct Struct

FieldTypeDescription
Offset int32 DST additional offset, in seconds. E.g. US DST = 3600 (+1 hour), no DST = 0
ValidStarting epoch_us Effective start time for this entry (microsecond-level epoch)
ValidUntil epoch_us / null Expiry time for this entry. The last entry's ValidUntil must be null (meaning it remains valid until replaced by a new list)
Local Time Calculation

LocalTime = UTCTime + TimeZone.Offset + DSTOffset.Offset
Example: UTC time 12:00, timezone UTC+8 (28800 seconds), DST +1h (3600 seconds) → local time 21:00. For regions that don't observe DST (e.g. China), the DSTOffset list only needs one record with Offset = 0.

Usage Scenarios

A device in US Eastern Time (UTC-5) needs to enter DST (+1h) on the second Sunday of March each year and exit on the first Sunday of November. The Commissioner can provide two DSTOffset records to cover the current year's transitions. When the last entry's ValidUntil expires, the device triggers a DSTTableEmpty event, reminding the Commissioner to update the DST table.

SetDefaultNTP — Set Default NTP Server (0x05)

Sets the default NTP server address for device time synchronization. Requires the device to have NTPC (NTP client) feature enabled. Set to null to clear the default NTP server.

ParameterTypeDescription
DefaultNTP string / null NTP server address (domain name or IPv6 address). Set to null to clear
DNS Resolution Capability

If a domain name is provided (e.g. "pool.ntp.org"), the device needs DNS resolution capability (check the SupportsDNSResolve attribute). Devices that don't support DNS can only accept NTP servers in IPv6 address format.

Usage Scenarios

After commissioning, the Commissioner can configure NTP servers for devices supporting NTPC. The device will then automatically synchronize time via NTP protocol, no longer depending on manual Commissioner setup. Common public NTP servers: pool.ntp.org, time.google.com, ntp.aliyun.com.

Attributes

TimeSynchronization Cluster has 13 application attributes. Click an attribute ID in the summary table below to jump to its detailed description.

ID Name Type Group Description
0x0000 UTCTime epoch_us / null Time Status Current UTC time (microsecond-level)
0x0001 Granularity GranularityEnum Time Status Current time's granularity level
0x0002 TimeSource TimeSourceEnum Time Status Current time's source
0x0003 TrustedTimeSource struct / null Time Source Config Trusted time source node within Fabric
0x0004 DefaultNTP string / null Time Source Config Default NTP server address
0x0005 TimeZone list<TimeZoneStruct> Timezone & DST Timezone configuration list
0x0006 DSTOffset list<DSTOffsetStruct> Timezone & DST DST offset list
0x0007 LocalTime epoch_us / null Timezone & DST Current local time (includes timezone + DST offset)
0x0008 TimeZoneDatabase TimeZoneDatabaseEnum Capabilities & Limits Device's timezone database type
0x0009 NTPServerAvailable bool Capabilities & Limits Whether device can serve as NTP server
0x000A TimeZoneListMaxSize uint8 Capabilities & Limits Maximum timezone list entries
0x000B DSTOffsetListMaxSize uint8 Capabilities & Limits Maximum DST offset list entries
0x000C SupportsDNSResolve bool Capabilities & Limits Whether DNS name resolution is supported

Time Status (0x0000 ~ 0x0002)

Describes the device's current time value and its precision and source.

IDNameTypeDescription
0x0000 UTCTime
UTC Time
epoch_us / null The device's current UTC time, microsecond-level precision (since 2000-01-01T00:00:00Z). null means the device has not yet obtained valid time — this is the default state for a freshly powered-on, unsynchronized device
0x0001 Granularity
Time Granularity
GranularityEnum Current time's granularity level. NoTimeGranularity (0) means the device has no trusted time. Higher precision indicates a more reliable time source (see enum definitions below)
0x0002 TimeSource
Time Source
TimeSourceEnum Where the current time was obtained from — NTP, manually set by administrator, GNSS, or other Matter nodes, etc. Used to assess time reliability (see enum definitions below)
Epoch Reference

Matter's time epoch reference is 2000-01-01T00:00:00Z, not Unix's 1970. Conversion formula: Matter epoch_us = (Unix timestamp - 946684800) * 1000000. Be aware of conversion when reading UTCTime.

Time Source Configuration (0x0003, 0x0004)

Describes the device's time synchronization source — where precise time is obtained from.

IDNameTypeDescription
0x0003 TrustedTimeSource
Trusted Time Source
struct / null The designated trusted time source node within the Fabric. Contains three fields: FabricIndex, NodeID, and Endpoint. null means not configured. Set via the SetTrustedTimeSource command
0x0004 DefaultNTP
Default NTP Server
string / null The default NTP server address used by the device (domain name or IPv6 address). null means not configured. Set via the SetDefaultNTP command. Requires NTPC feature
Time Source Priority

Device time acquisition priority is typically: NTP server > trusted time source node > manual admin setting. If the device supports NTPC and DefaultNTP is configured, it will automatically sync via NTP with the highest precision. For Thread devices that cannot directly access the internet, TrustedTimeSource is the only automatic synchronization path.

Timezone and DST (0x0005 ~ 0x0007)

Manages timezone configuration, DST offsets, and local time calculation. Requires the device to have TZ feature enabled.

IDNameTypeDescription
0x0005 TimeZone
Timezone List
list<TimeZoneStruct> Currently effective timezone configuration list. Each entry contains Offset (seconds), ValidAt (effective time), Name (IANA timezone name). Set via the SetTimeZone command. Requires TZ feature
0x0006 DSTOffset
DST Offset List
list<DSTOffsetStruct> Currently effective DST offset list. Each entry contains Offset (seconds), ValidStarting, ValidUntil. Set via the SetDSTOffset command. Requires TZ feature
0x0007 LocalTime
Local Time
epoch_us / null Local time calculated by the device = UTCTime + TimeZone.Offset + DSTOffset.Offset. null means UTC time or timezone configuration is missing, unable to calculate. Read-only attribute. Requires TZ feature

Capabilities and Limits (0x0008 ~ 0x000C)

Describes the device's capability limits and hardware characteristics for time synchronization. Most of these attributes are read-only, determined by device firmware.

IDNameTypeDescription
0x0008 TimeZoneDatabase
Timezone Database
TimeZoneDatabaseEnum Device's built-in timezone database type. Full (0) = full IANA database, can automatically calculate DST; Partial (1) = partial database; None (2) = no database, fully depends on Commissioner for manual setup. Requires TZ feature
0x0009 NTPServerAvailable
NTP Server Available
bool Whether the device itself can serve as an NTP server to provide time to other nodes. true means other devices can set this device as their TrustedTimeSource. Requires NTPS feature
0x000A TimeZoneListMaxSize
Timezone List Max Size
uint8 Maximum number of entries allowed in the TimeZone list. Minimum 1, maximum 2. The list length of SetTimeZone cannot exceed this value. Requires TZ feature
0x000B DSTOffsetListMaxSize
DST Offset List Max Size
uint8 Maximum number of entries allowed in the DSTOffset list. The list length of SetDSTOffset cannot exceed this value. Requires TZ feature
0x000C SupportsDNSResolve
Supports DNS Resolve
bool Whether the device supports resolving domain names to IP addresses. If false, SetDefaultNTP can only accept IPv6 addresses, not domain names. Requires NTPC feature

Feature Bitmap

TimeSynchronization Cluster declares device time synchronization capabilities through FeatureMap (0xFFFC):

Bit 0
TZ(TimeZone) Timezone management — enables SetTimeZone and SetDSTOffset commands, along with timezone, DST, and local time related attributes
Bit 1
NTPC(NTPClient) NTP client — device can actively synchronize time from an NTP server, enables SetDefaultNTP command
Bit 2
NTPS(NTPServer) NTP server — device itself can serve as a time source, providing NTP time service to other devices in the Fabric
Common Combinations

Basic devices (e.g. low-power sensors): no Features, only support manual SetUTCTime;
Standard devices (e.g. lights, outlets): TZ, supports timezone and DST configuration;
Connected devices (e.g. Wi-Fi lights): TZ + NTPC, can auto-sync from NTP;
Hub devices (e.g. border routers): TZ + NTPC + NTPS, not only syncing themselves but also providing time to other devices.

Enum Definitions

GranularityEnum

Describes the device's current time precision level. Higher precision indicates a more reliable time source.

0
NoTimeGranularity No valid time — device has not obtained any time information yet
1
MinutesGranularity Minutes granularity — time error may be up to several minutes
2
SecondsGranularity Seconds granularity — time error within seconds
3
MillisecondsGranularity Milliseconds granularity — typically from NTP synchronization
4
MicrosecondsGranularity Microseconds granularity — typically from PTP or GNSS

TimeSourceEnum

Identifies the source of the device's current time. Higher values typically indicate a more reliable time source. The NTS suffix indicates Network Time Security authentication was used.

0
None No time source
1
Unknown Source unknown
2
Admin Manually set by administrator (via SetUTCTime)
3
NodeTimeCluster Synchronized from another Matter node's TimeSynchronization Cluster
4
NonMatterSNTP SNTP server from non-Matter network
5
NonMatterNTP NTP server from non-Matter network
6
MatterSNTP SNTP server within Matter Fabric
7
MatterNTP NTP server within Matter Fabric
8
MixedNTP Mixed NTP sources (Matter + non-Matter)
9
NonMatterSNTPNTS Non-Matter SNTP + NTS authentication
10
NonMatterNTPNTS Non-Matter NTP + NTS authentication
11
MatterSNTPNTS Matter SNTP + NTS authentication
12
MatterNTPNTS Matter NTP + NTS authentication
13
MixedNTPNTS Mixed NTP sources + NTS authentication
14
CloudSource Cloud time source
15
PTP Precision Time Protocol (IEEE 1588), microsecond-level accuracy
16
GNSS Global Navigation Satellite System (GPS/BeiDou, etc.), highest accuracy time source

TimeZoneDatabaseEnum

Describes the device's built-in timezone database capability, determining whether the device can calculate DST rules on its own.

0
Full Full IANA timezone database — device can automatically calculate DST; usually no need to manually set DSTOffset after SetTimeZone
1
Partial Partial timezone database — covers only some regions; regions not covered still require manual DSTOffset configuration
2
None No timezone database — fully depends on Commissioner to manually provide timezone and DST configuration

Events

TimeSynchronization Cluster defines 5 events to notify the Commissioner or automation systems of time status changes.

Event Name Severity Required Feature Description
DSTTableEmpty Info TZ DST table exhausted — all DSTOffset entries have expired, device can no longer correctly calculate local time. Commissioner needs to provide a new DSTOffset list
DSTStatus Info TZ DST status change — device entering or exiting DST. Contains a DSTOffsetActive boolean field, true = DST is active
TimeZoneStatus Info TZ Timezone switch — the next entry in the timezone list has taken effect (ValidAt reached). Contains new Offset and Name fields
TimeFailure Info None Time sync failure — device cannot obtain or verify time from any source. Possible causes include NTP unreachable, trusted time source offline, etc.
MissingTrustedTimeSource Info None Missing trusted time source — device needs time sync but has no TrustedTimeSource configured and no available NTP. Reminds Commissioner to configure a time source
Event Subscription Advice

It is recommended that the Commissioner subscribe to DSTTableEmpty and TimeFailure events. The former triggers when the DST table expires; if not updated promptly, the device's local time will be incorrect (affecting scheduled automations, etc.); the latter triggers when the time sync chain breaks, enabling timely discovery and resolution of issues.

Example Data

Attribute Data Example

Below is typical attribute data from a TimeSynchronization Cluster of a smart light (China region) supporting TZ + NTPC:

{
  // --- Time Status ---
  "0x0000": 1695312000000000,    // UTCTime = 2023-09-21T16:00:00Z (microsecond-level epoch)
  "0x0001": 3,                   // Granularity = MillisecondsGranularity
  "0x0002": 7,                   // TimeSource = MatterNTP

  // --- Trusted Time Source ---
  "0x0003": {                    // TrustedTimeSource
    "fabricIndex": 1,
    "nodeID": "0x0000000000000001",
    "endpoint": 0
  },
  "0x0004": "pool.ntp.org",      // DefaultNTP

  // --- Timezone & DST ---
  "0x0005": [{                   // TimeZone
    "offset": 28800,             //   UTC+8 (seconds)
    "validAt": 0,
    "name": "Asia/Shanghai"
  }],
  "0x0006": [{                   // DSTOffset
    "offset": 0,                 //   No DST
    "validStarting": 0,
    "validUntil": null
  }],

  // --- Local Time ---
  "0x0007": 1695340800000000,    // LocalTime (timezone offset applied)

  // --- Capabilities & Limits ---
  "0x0008": 1,                   // TimeZoneDatabase = Full
  "0x0009": false,               // NTPServerAvailable = false
  "0x000A": 2,                   // TimeZoneListMaxSize = 2
  "0x000B": 2,                   // DSTOffsetListMaxSize = 2
  "0x000C": true                 // SupportsDNSResolve = true
}

SetUTCTime Interaction Example

Commissioner sets initial time for the device after commissioning:

// Commissioner → Device: Set UTC time
{
  "invokeRequests": [{
    "commandPath": {
      "endpointId": 0,
      "clusterId": "0x0038",
      "commandId": "0x00"            // SetUTCTime
    },
    "commandFields": {
      "UTCTime": 1695312000000000,   // 2023-09-21T16:00:00Z (microseconds)
      "granularity": 3,              // MillisecondsGranularity
      "timeSource": 2                // Admin
    }
  }]
}

SetTimeZone Interaction Example

Setting the China timezone (UTC+8) for the device:

// Commissioner → Device: Set timezone
{
  "invokeRequests": [{
    "commandPath": {
      "endpointId": 0,
      "clusterId": "0x0038",
      "commandId": "0x02"            // SetTimeZone
    },
    "commandFields": {
      "timeZone": [{
        "offset": 28800,             // UTC+8 (seconds)
        "validAt": 0,                // Effective immediately
        "name": "Asia/Shanghai"      // IANA timezone name (optional)
      }]
    }
  }]
}

// Device → Commissioner: Confirm timezone setting
{
  "DSTOffsetRequired": true          // Need to follow up with DST offset setting
}
Developer Tip

Most Matter SDKs (e.g. connectedhomeip) automatically handle basic time setup during commissioning. App developers typically only need to focus on timezone configuration (especially when users change regions) and periodic DST table updates. Subscribing to the DSTTableEmpty event provides notification when an update is needed.

Common Scenarios

Scenario 1: Set Initial Time During Commissioning
  1. After commissioning (CommissioningComplete succeeded), read the device's FeatureMap (0xFFFC) to confirm time sync capabilities
  2. Send SetUTCTime (0x00) to inject current UTC time with Granularity = SecondsGranularity (2), TimeSource = Admin (2)
  3. Send SetTrustedTimeSource (0x01) to designate a Hub in the Fabric as the trusted time source
  4. If the device supports NTPC, send SetDefaultNTP (0x05) to configure the NTP server
  5. Verify: read UTCTime (0x0000) to confirm time is set, Granularity (0x0001) is no longer 0

The device will subsequently auto-sync time from NTP or TrustedTimeSource, with precision gradually improving.

Scenario 2: Timezone Configuration (User Moves to a New Timezone)
  1. Confirm device supports TZ feature (FeatureMap Bit 0 = 1)
  2. Read TimeZoneListMaxSize (0x000A) to confirm list capacity
  3. Send SetTimeZone (0x02) with new timezone info:
    • Moving from Beijing to New York: Offset = -18000 (UTC-5), Name = "America/New_York"
  4. Check the response's DSTOffsetRequired:
    • If true: device has no built-in timezone database, need to follow up with SetDSTOffset (0x04) to manually set US Eastern DST rules
    • If false: device has a built-in database and has already calculated DST automatically, no additional action needed
  5. Verify: read LocalTime (0x0007) to confirm local time correctly reflects the new timezone
Scenario 3: NTP Auto-sync Configuration
  1. Confirm device supports NTPC feature (FeatureMap Bit 1 = 1)
  2. Check SupportsDNSResolve (0x000C):
    • true: can pass domain names, e.g. "pool.ntp.org"
    • false: can only pass IPv6 addresses
  3. Send SetDefaultNTP (0x05) to set the NTP server address
  4. After waiting some time, read Granularity (0x0001) and TimeSource (0x0002), to confirm successful NTP sync (Granularity should upgrade to MillisecondsGranularity, TimeSource changes to NTP-related value)

Recommended NTP servers: pool.ntp.org (global), ntp.aliyun.com (China), time.google.com (global). For enterprise environments, internal NTP servers can be used for security.

Scenario 4: Handling the DSTTableEmpty Event (DST Table Expired)
  1. Subscribe to the device's DSTTableEmpty event
  2. When the event is received, it means all DSTOffset entries have expired
  3. Query future DST transition times based on the device's timezone
  4. Send SetDSTOffset (0x04) to provide a new DST offset list
  5. Set the last entry's ValidUntil to null, ensuring the list covers until the next update

Note: If this event is not handled promptly, the device's LocalTime will be incorrect due to missing DST information, affecting all automation rules that depend on local time (e.g. "turn on lights at 7 AM" would actually be an hour early or late).

Scenario 5: Time Synchronization Strategy for Thread Devices

Thread devices typically lack direct internet access and cannot use NTP. They rely on the following time sync chain:

  1. Commissioning phase: Commissioner injects initial time via SetUTCTime
  2. Running phase: Via SetTrustedTimeSource, point to the Thread Border Router, which forwards NTP time obtained from the internet to Thread devices
  3. If TrustedTimeSource goes offline, the device triggers a MissingTrustedTimeSource event
  4. Time precision will gradually degrade (Granularity may deteriorate from Milliseconds to Seconds or even Minutes)

Best practice: Ensure at least one reliable time source node in the Fabric (e.g. Hub or Border Router), and configure TrustedTimeSource pointing to it for all devices during commissioning.