diff --git a/tasmota/i18n.h b/tasmota/i18n.h index c2f94c48a..473bd8b4a 100644 --- a/tasmota/i18n.h +++ b/tasmota/i18n.h @@ -659,6 +659,8 @@ #define D_CMND_ZIGBEE_DATA "Data" #define D_CMND_ZIGBEE_SCAN "Scan" #define D_JSON_ZIGBEE_SCAN "ZbScan" +#define D_CMND_ZIGBEE_CIE "CIE" +#define D_CMND_ZIGBEE_ENROLL "Enroll" // Commands xdrv_25_A4988_Stepper.ino #define D_CMND_MOTOR "MOTOR" diff --git a/tasmota/xdrv_23_zigbee_8_parsers.ino b/tasmota/xdrv_23_zigbee_8_parsers.ino index 0e1abe0a4..f728e1827 100644 --- a/tasmota/xdrv_23_zigbee_8_parsers.ino +++ b/tasmota/xdrv_23_zigbee_8_parsers.ino @@ -1412,6 +1412,7 @@ void Z_SendSingleAttributeRead(uint16_t shortaddr, uint16_t groupaddr, uint16_t // Write CIE address // void Z_WriteCIEAddress(uint16_t shortaddr, uint16_t groupaddr, uint16_t cluster, uint8_t endpoint, uint32_t value) { + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Sending CIE Address for Cluster %d in Endpoint %d of Device 0x%04X"), cluster, endpoint, shortaddr); ZCLMessage zcl(12); // message is 12 bytes zcl.shortaddr = shortaddr; zcl.cluster = 0x0500; @@ -1428,15 +1429,15 @@ void Z_WriteCIEAddress(uint16_t shortaddr, uint16_t groupaddr, uint16_t cluster, // -// Write CIE address +// Send CIE Zone Enroll Response // void Z_SendCIEZoneEnrollResponse(uint16_t shortaddr, uint16_t groupaddr, uint16_t cluster, uint8_t endpoint, uint32_t value) { - AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Sending Enroll Zone %d"), Z_B0(value)); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Sending Enroll Zone %d for Cluster %d in Endpoint %d of Device 0x%04X"), Z_B0(value), cluster, endpoint, shortaddr); ZCLMessage zcl(2); // message is 2 bytes zcl.shortaddr = shortaddr; zcl.cluster = 0x0500; zcl.endpoint = endpoint; - zcl.cmd = 0x00, // Zone Enroll Response + zcl.cmd = 0x00; // Zone Enroll Response zcl.clusterSpecific = true; zcl.needResponse = true; zcl.direct = false; // discover route diff --git a/tasmota/xdrv_23_zigbee_A_impl.ino b/tasmota/xdrv_23_zigbee_A_impl.ino index 41ee70119..8abe92121 100644 --- a/tasmota/xdrv_23_zigbee_A_impl.ino +++ b/tasmota/xdrv_23_zigbee_A_impl.ino @@ -39,7 +39,7 @@ const char kZbCommands[] PROGMEM = D_PRFX_ZB "|" // prefix D_CMND_ZIGBEE_BIND "|" D_CMND_ZIGBEE_UNBIND "|" D_CMND_ZIGBEE_PING "|" D_CMND_ZIGBEE_MODELID "|" D_CMND_ZIGBEE_LIGHT "|" D_CMND_ZIGBEE_OCCUPANCY "|" D_CMND_ZIGBEE_RESTORE "|" D_CMND_ZIGBEE_BIND_STATE "|" D_CMND_ZIGBEE_MAP "|" D_CMND_ZIGBEE_LEAVE "|" - D_CMND_ZIGBEE_CONFIG "|" D_CMND_ZIGBEE_DATA "|" D_CMND_ZIGBEE_SCAN + D_CMND_ZIGBEE_CONFIG "|" D_CMND_ZIGBEE_DATA "|" D_CMND_ZIGBEE_SCAN "|" D_CMND_ZIGBEE_ENROLL "|" D_CMND_ZIGBEE_CIE ; SO_SYNONYMS(kZbSynonyms, @@ -61,6 +61,7 @@ void (* const ZigbeeCommand[])(void) PROGMEM = { &CmndZbLight, &CmndZbOccupancy, &CmndZbRestore, &CmndZbBindState, &CmndZbMap, &CmndZbLeave, &CmndZbConfig, &CmndZbData, &CmndZbScan, + &CmndZbenroll, &CmndZbcie, }; /********************************************************************************************/ @@ -1331,6 +1332,42 @@ void CmndZbScan(void) { ResponseCmndDone(); } +void CmndZbenroll(void) { + if (zigbee.init_phase) { ResponseCmndChar_P(PSTR(D_ZIGBEE_NOT_STARTED)); return; } + + if ((XdrvMailbox.data_len) && (ArgC() > 1)) { // Process parameter entry + char argument[XdrvMailbox.data_len]; + Z_Device & device = zigbee_devices.parseDeviceFromName(ArgV(argument, 1)); + int enrollEndpoint = atoi(ArgV(argument, 2)); + + if (!device.valid()) { ResponseCmndChar_P(PSTR(D_ZIGBEE_UNKNOWN_DEVICE)); return; } + + Z_SendCIEZoneEnrollResponse(device.shortaddr, 0, 500, enrollEndpoint, 1); + + ResponseCmndDone(); + } else { + ResponseCmndError(); + } +} + +void CmndZbcie(void) { + if (zigbee.init_phase) { ResponseCmndChar_P(PSTR(D_ZIGBEE_NOT_STARTED)); return; } + + if ((XdrvMailbox.data_len) && (ArgC() > 1)) { // Process parameter entry + char argument[XdrvMailbox.data_len]; + Z_Device & device = zigbee_devices.parseDeviceFromName(ArgV(argument, 1)); + int enrollEndpoint = atoi(ArgV(argument, 2)); + + if (!device.valid()) { ResponseCmndChar_P(PSTR(D_ZIGBEE_UNKNOWN_DEVICE)); return; } + + Z_WriteCIEAddress(device.shortaddr, 0, 500, enrollEndpoint, 0); + + ResponseCmndDone(); + } else { + ResponseCmndError(); + } +} + // Restore a device configuration previously exported via `ZbStatus2`` // Format: // Either the entire `ZbStatus3` export, or an array or just the device configuration.