From eff11ae2cb6bef7e0a793c2f5aff3f22b03c1dc3 Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Thu, 13 Aug 2020 10:59:38 +0200 Subject: [PATCH] Fix ZbBind crash and add Identify cluster --- tasmota/xdrv_23_zigbee_2_devices.ino | 4 ++-- tasmota/xdrv_23_zigbee_5_converters.ino | 4 ++++ tasmota/xdrv_23_zigbee_6_commands.ino | 8 +++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/tasmota/xdrv_23_zigbee_2_devices.ino b/tasmota/xdrv_23_zigbee_2_devices.ino index d6c4dce05..bd4024bf7 100644 --- a/tasmota/xdrv_23_zigbee_2_devices.ino +++ b/tasmota/xdrv_23_zigbee_2_devices.ino @@ -417,8 +417,8 @@ uint16_t Z_Devices::isKnownFriendlyName(const char * name) const { } uint64_t Z_Devices::getDeviceLongAddr(uint16_t shortaddr) const { - const Z_Device & device = getShortAddrConst(shortaddr); - return device.longaddr; + const Z_Device &device = getShortAddrConst(shortaddr); + return (&device != nullptr) ? device.longaddr : 0; } // diff --git a/tasmota/xdrv_23_zigbee_5_converters.ino b/tasmota/xdrv_23_zigbee_5_converters.ino index d627c27a5..d3f9f1342 100644 --- a/tasmota/xdrv_23_zigbee_5_converters.ino +++ b/tasmota/xdrv_23_zigbee_5_converters.ino @@ -145,6 +145,7 @@ ZF(ZCLVersion) ZF(AppVersion) ZF(StackVersion) ZF(HWVersion) ZF(Manufacturer) ZF ZF(DateCode) ZF(PowerSource) ZF(SWBuildID) ZF(Power) ZF(SwitchType) ZF(Dimmer) ZF(MainsVoltage) ZF(MainsFrequency) ZF(BatteryVoltage) ZF(BatteryPercentage) ZF(CurrentTemperature) ZF(MinTempExperienced) ZF(MaxTempExperienced) ZF(OverTempTotalDwell) +ZF(IdentifyTime) ZF(SceneCount) ZF(CurrentScene) ZF(CurrentGroup) ZF(SceneValid) ZF(AlarmCount) ZF(Time) ZF(TimeStatus) ZF(TimeZone) ZF(DstStart) ZF(DstEnd) ZF(DstShift) ZF(StandardTime) ZF(LocalTime) ZF(LastSetTime) ZF(ValidUntilTime) ZF(TimeEpoch) @@ -259,6 +260,9 @@ const Z_AttributeConverter Z_PostProcess[] PROGMEM = { { Zint16, Cx0002, 0x0002, Z(MaxTempExperienced), 1, Z_Nop }, { Zuint16, Cx0002, 0x0003, Z(OverTempTotalDwell), 1, Z_Nop }, + // Identify cluster + { Zuint16, Cx0003, 0x0000, Z(IdentifyTime), 1, Z_Nop }, + // Scenes cluster { Zuint8, Cx0005, 0x0000, Z(SceneCount), 1, Z_Nop }, { Zuint8, Cx0005, 0x0001, Z(CurrentScene), 1, Z_Nop }, diff --git a/tasmota/xdrv_23_zigbee_6_commands.ino b/tasmota/xdrv_23_zigbee_6_commands.ino index c4e7e20c8..b6c2d2c11 100644 --- a/tasmota/xdrv_23_zigbee_6_commands.ino +++ b/tasmota/xdrv_23_zigbee_6_commands.ino @@ -27,7 +27,7 @@ typedef struct Z_CommandConverter { const char * tasmota_cmd; uint16_t cluster; uint8_t cmd; // normally 8 bits, 0xFF means it's a parameter - uint8_t direction; // direction of the command. 0x01 client->server, 0x02 server->client, 0x03 both + uint8_t direction; // direction of the command. 0x01 client->server, 0x02 server->client, 0x03 both, 0x80 requires custom decoding const char * param; } Z_CommandConverter; @@ -40,6 +40,7 @@ typedef struct Z_XYZ_Var { // Holds values for vairables X, Y and Z uint8_t z_type = 0; } Z_XYZ_Var; +ZF(Identify) ZF(IdentifyQuery) ZF(AddGroup) ZF(ViewGroup) ZF(GetGroup) ZF(GetAllGroups) ZF(RemoveGroup) ZF(RemoveAllGroups) ZF(AddScene) ZF(ViewScene) ZF(RemoveScene) ZF(RemoveAllScenes) ZF(RecallScene) ZF(StoreScene) ZF(GetSceneMembership) //ZF(Power) ZF(Dimmer) @@ -70,6 +71,9 @@ ZF(00xx0A00) ZF(01xx0A00) ZF(03xx0A00) ZF(01xxxx0A0000000000) ZF(03xxxx0A0000000 // - direction: the direction of the command (bit field). 0x01=from client to server (coord to device), 0x02= from server to client (response), 0x80=needs specific decoding // - param: the paylod template, x/y/z are substituted with arguments, little endian. For command display, payload must match until x/y/z character or until the end of the paylod. '??' means ignore. const Z_CommandConverter Z_Commands[] PROGMEM = { + // Identify cluster + { Z(Identify), 0x0003, 0x00, 0x01, Z(xxxx) }, // Identify device, time in seconds + { Z(IdentifyQuery), 0x0003, 0x01, 0x01, Z() }, // Identify Query (no param) // Group adress commands { Z(AddGroup), 0x0004, 0x00, 0x01, Z(xxxx00) }, // Add group id, group name is not supported { Z(ViewGroup), 0x0004, 0x01, 0x01, Z(xxxx) }, // Ask for the group name @@ -137,6 +141,8 @@ const Z_CommandConverter Z_Commands[] PROGMEM = { { Z(ArrowClick), 0x0005, 0x07, 0x01, Z(xx) }, // xx == 0x01 = left, 0x00 = right { Z(ArrowHold), 0x0005, 0x08, 0x01, Z(xx) }, // xx == 0x01 = left, 0x00 = right { Z(ArrowRelease), 0x0005, 0x09, 0x01, Z() }, + // Response for Indetify cluster + { Z(IdentifyQuery), 0x0003, 0x00, 0x02, Z(xxxx) }, // timeout in seconds // IAS - Intruder Alarm System + leak/fire detection { Z(ZoneStatusChange),0x0500, 0x00, 0x82, Z(xxxxyyzz) }, // xxxx = zone status, yy = extended status, zz = zone id, Delay is ignored // responses for Group cluster commands