Skip to content

Commit

Permalink
Added commands to sync time in Tuya to manuSpecificTuyaDimmer cluster (
Browse files Browse the repository at this point in the history
  • Loading branch information
hacker-cb authored Sep 29, 2020
1 parent 668f0d5 commit 71c89ce
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/controller/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ const CommandsLookup: {[s: string]: MessagePayloadType} = {
'studyKeyRsp': 'commandStudyKeyRsp',
'createIdRsp': 'commandCreateIdRsp',
'getIdAndKeyCodeListRsp': 'commandGetIdAndKeyCodeListRsp',

'setTimeRequest': 'commandSetTimeRequest', // Tuya time sync
};

type MessagePayloadType =
Expand All @@ -101,7 +103,7 @@ type MessagePayloadType =
'commandAlertsNotification' | 'commandProgrammingEventNotification' | "commandGetPinCodeRsp" |
"commandArrivalSensorNotify" | 'commandCommisioningNotification' |
'commandAtHome' | 'commandGoOut' | 'commandCinema' | 'commandRepast' | 'commandSleep' |
'commandStudyKeyRsp' | 'commandCreateIdRsp' | 'commandGetIdAndKeyCodeListRsp';
'commandStudyKeyRsp' | 'commandCreateIdRsp' | 'commandGetIdAndKeyCodeListRsp' | 'commandSetTimeRequest';

interface MessagePayload {
type: MessagePayloadType;
Expand Down
25 changes: 25 additions & 0 deletions src/zcl/definition/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3772,6 +3772,24 @@ const Cluster: {
{name: 'data', type: BuffaloZclDataType.LIST_UINT8},
],
},
// Time sync command (It's transparent beetween MCU and server)
// Time request device -> server
// payloadSize = 0
// Set time, server -> device
// payloadSize, should be always 8
// payload[0-3] - UTC timestamp (big endian)
// payload[4-7] - Local timestamp (big endian)
//
// Zigbee payload is very similar to the UART payload which is described here: https://developer.tuya.com/en/docs/iot/device-development/access-mode-mcu/zigbee-general-solution/tuya-zigbee-module-uart-communication-protocol/tuya-zigbee-module-uart-communication-protocol?id=K9ear5khsqoty#title-10-Time%20synchronization
//
// NOTE: You need to wait for time request before setting it. You can't set time without request.
setTime: {
ID: 0x24,
parameters: [
{name: 'payloadSize', type: DataType.uint16},
{name: 'payload', type: BuffaloZclDataType.LIST_UINT8},
]
}
},
commandsResponse: {
getData: {
Expand All @@ -3797,6 +3815,13 @@ const Cluster: {
{name: 'data', type: DataType.octetStr},
],
},
setTimeRequest: {
ID: 0x24,
parameters: [
{name: 'payloadSize', type: DataType.uint16}, // Should be always 0
{name: 'payload', type: BuffaloZclDataType.LIST_UINT8},
]
}
},
},
aqaraOpple: {
Expand Down

0 comments on commit 71c89ce

Please sign in to comment.