Zigbee support for lumi_plug

This commit is contained in:
Stephan Hadinger 2020-11-22 17:38:04 +01:00
parent 4c4c082769
commit 54e7f35998
2 changed files with 171 additions and 137 deletions

View File

@ -350,7 +350,7 @@ const char Z_strings[] PROGMEM =
"Movement" "\x00" "Movement" "\x00"
"Panic" "\x00" "Panic" "\x00"
"GlassBreak" "\x00" "GlassBreak" "\x00"
"CurrentSummDelivered" "\x00" "EnergyTotal" "\x00"
"CompanyName" "\x00" "CompanyName" "\x00"
"MeterTypeID" "\x00" "MeterTypeID" "\x00"
"DataQualityID" "\x00" "DataQualityID" "\x00"
@ -366,6 +366,8 @@ const char Z_strings[] PROGMEM =
"RMSVoltage" "\x00" "RMSVoltage" "\x00"
"RMSCurrent" "\x00" "RMSCurrent" "\x00"
"ActivePower" "\x00" "ActivePower" "\x00"
"ReactivePower" "\x00"
"ApparentPower" "\x00"
"NumberOfResets" "\x00" "NumberOfResets" "\x00"
"PersistentMemoryWrites" "\x00" "PersistentMemoryWrites" "\x00"
"LastMessageLQI" "\x00" "LastMessageLQI" "\x00"
@ -763,140 +765,142 @@ enum Z_offsets {
Zo_Movement = 4610, Zo_Movement = 4610,
Zo_Panic = 4619, Zo_Panic = 4619,
Zo_GlassBreak = 4625, Zo_GlassBreak = 4625,
Zo_CurrentSummDelivered = 4636, Zo_EnergyTotal = 4636,
Zo_CompanyName = 4657, Zo_CompanyName = 4648,
Zo_MeterTypeID = 4669, Zo_MeterTypeID = 4660,
Zo_DataQualityID = 4681, Zo_DataQualityID = 4672,
Zo_CustomerName = 4695, Zo_CustomerName = 4686,
Zo_Model = 4708, Zo_Model = 4699,
Zo_PartNumber = 4714, Zo_PartNumber = 4705,
Zo_ProductRevision = 4725, Zo_ProductRevision = 4716,
Zo_SoftwareRevision = 4741, Zo_SoftwareRevision = 4732,
Zo_UtilityName = 4758, Zo_UtilityName = 4749,
Zo_POD = 4770, Zo_POD = 4761,
Zo_AvailablePower = 4774, Zo_AvailablePower = 4765,
Zo_PowerThreshold = 4789, Zo_PowerThreshold = 4780,
Zo_RMSVoltage = 4804, Zo_RMSVoltage = 4795,
Zo_RMSCurrent = 4815, Zo_RMSCurrent = 4806,
Zo_ActivePower = 4826, Zo_ActivePower = 4817,
Zo_NumberOfResets = 4838, Zo_ReactivePower = 4829,
Zo_PersistentMemoryWrites = 4853, Zo_ApparentPower = 4843,
Zo_LastMessageLQI = 4876, Zo_NumberOfResets = 4857,
Zo_LastMessageRSSI = 4891, Zo_PersistentMemoryWrites = 4872,
Zo_TuyaScheduleWorkdays = 4907, Zo_LastMessageLQI = 4895,
Zo_TuyaScheduleHolidays = 4928, Zo_LastMessageRSSI = 4910,
Zo_Power2 = 4949, Zo_TuyaScheduleWorkdays = 4926,
Zo_Power3 = 4956, Zo_TuyaScheduleHolidays = 4947,
Zo_Power4 = 4963, Zo_Power2 = 4968,
Zo_TuyaChildLock = 4970, Zo_Power3 = 4975,
Zo_TuyaWindowDetection = 4984, Zo_Power4 = 4982,
Zo_TuyaValveDetection = 5004, Zo_TuyaChildLock = 4989,
Zo_TuyaAutoLock = 5023, Zo_TuyaWindowDetection = 5003,
Zo_TuyaTempTarget = 5036, Zo_TuyaValveDetection = 5023,
Zo_TuyaBattery = 5051, Zo_TuyaAutoLock = 5042,
Zo_TuyaMinTemp = 5063, Zo_TuyaTempTarget = 5055,
Zo_TuyaMaxTemp = 5075, Zo_TuyaBattery = 5070,
Zo_TuyaBoostTime = 5087, Zo_TuyaMinTemp = 5082,
Zo_TuyaComfortTemp = 5101, Zo_TuyaMaxTemp = 5094,
Zo_TuyaEcoTemp = 5117, Zo_TuyaBoostTime = 5106,
Zo_TuyaValvePosition = 5129, Zo_TuyaComfortTemp = 5120,
Zo_TuyaAwayTemp = 5147, Zo_TuyaEcoTemp = 5136,
Zo_TuyaAwayDays = 5160, Zo_TuyaValvePosition = 5148,
Zo_TuyaPreset = 5173, Zo_TuyaAwayTemp = 5166,
Zo_TuyaFanMode = 5184, Zo_TuyaAwayDays = 5179,
Zo_TuyaForceMode = 5196, Zo_TuyaPreset = 5192,
Zo_TuyaWeekSelect = 5210, Zo_TuyaFanMode = 5203,
Zo_TerncyDuration = 5225, Zo_TuyaForceMode = 5215,
Zo_TerncyRotate = 5240, Zo_TuyaWeekSelect = 5229,
Zo_Identify = 5253, Zo_TerncyDuration = 5244,
Zo_xxxx = 5262, Zo_TerncyRotate = 5259,
Zo_IdentifyQuery = 5267, Zo_Identify = 5272,
Zo_AddGroup = 5281, Zo_xxxx = 5281,
Zo_xxxx00 = 5290, Zo_IdentifyQuery = 5286,
Zo_ViewGroup = 5297, Zo_AddGroup = 5300,
Zo_GetGroup = 5307, Zo_xxxx00 = 5309,
Zo_01xxxx = 5316, Zo_ViewGroup = 5316,
Zo_GetAllGroups = 5323, Zo_GetGroup = 5326,
Zo_00 = 5336, Zo_01xxxx = 5335,
Zo_RemoveGroup = 5339, Zo_GetAllGroups = 5342,
Zo_RemoveAllGroups = 5351, Zo_00 = 5355,
Zo_ViewScene = 5367, Zo_RemoveGroup = 5358,
Zo_xxxxyy = 5377, Zo_RemoveAllGroups = 5370,
Zo_RemoveScene = 5384, Zo_ViewScene = 5386,
Zo_RemoveAllScenes = 5396, Zo_xxxxyy = 5396,
Zo_RecallScene = 5412, Zo_RemoveScene = 5403,
Zo_GetSceneMembership = 5424, Zo_RemoveAllScenes = 5415,
Zo_PowerOffEffect = 5443, Zo_RecallScene = 5431,
Zo_xxyy = 5458, Zo_GetSceneMembership = 5443,
Zo_PowerOnRecall = 5463, Zo_PowerOffEffect = 5462,
Zo_PowerOnTimer = 5477, Zo_xxyy = 5477,
Zo_xxyyyyzzzz = 5490, Zo_PowerOnRecall = 5482,
Zo_xx0A00 = 5501, Zo_PowerOnTimer = 5496,
Zo_DimmerUp = 5508, Zo_xxyyyyzzzz = 5509,
Zo_00190200 = 5517, Zo_xx0A00 = 5520,
Zo_DimmerDown = 5526, Zo_DimmerUp = 5527,
Zo_01190200 = 5537, Zo_00190200 = 5536,
Zo_DimmerStop = 5546, Zo_DimmerDown = 5545,
Zo_ResetAlarm = 5557, Zo_01190200 = 5556,
Zo_xxyyyy = 5568, Zo_DimmerStop = 5565,
Zo_ResetAllAlarms = 5575, Zo_ResetAlarm = 5576,
Zo_xx000A00 = 5590, Zo_xxyyyy = 5587,
Zo_HueSat = 5599, Zo_ResetAllAlarms = 5594,
Zo_xxyy0A00 = 5606, Zo_xx000A00 = 5609,
Zo_Color = 5615, Zo_HueSat = 5618,
Zo_xxxxyyyy0A00 = 5621, Zo_xxyy0A00 = 5625,
Zo_xxxx0A00 = 5634, Zo_Color = 5634,
Zo_ShutterOpen = 5643, Zo_xxxxyyyy0A00 = 5640,
Zo_ShutterClose = 5655, Zo_xxxx0A00 = 5653,
Zo_ShutterStop = 5668, Zo_ShutterOpen = 5662,
Zo_ShutterLift = 5680, Zo_ShutterClose = 5674,
Zo_xx = 5692, Zo_ShutterStop = 5687,
Zo_ShutterTilt = 5695, Zo_ShutterLift = 5699,
Zo_Shutter = 5707, Zo_xx = 5711,
Zo_DimmerMove = 5715, Zo_ShutterTilt = 5714,
Zo_xx0A = 5726, Zo_Shutter = 5726,
Zo_DimmerStepUp = 5731, Zo_DimmerMove = 5734,
Zo_00xx0A00 = 5744, Zo_xx0A = 5745,
Zo_DimmerStepDown = 5753, Zo_DimmerStepUp = 5750,
Zo_01xx0A00 = 5768, Zo_00xx0A00 = 5763,
Zo_DimmerStep = 5777, Zo_DimmerStepDown = 5772,
Zo_xx190A00 = 5788, Zo_01xx0A00 = 5787,
Zo_01 = 5797, Zo_DimmerStep = 5796,
Zo_HueMove = 5800, Zo_xx190A00 = 5807,
Zo_xx19 = 5808, Zo_01 = 5816,
Zo_HueStepUp = 5813, Zo_HueMove = 5819,
Zo_HueStepDown = 5823, Zo_xx19 = 5827,
Zo_03xx0A00 = 5835, Zo_HueStepUp = 5832,
Zo_HueStep = 5844, Zo_HueStepDown = 5842,
Zo_SatMove = 5852, Zo_03xx0A00 = 5854,
Zo_SatStep = 5860, Zo_HueStep = 5863,
Zo_xx190A = 5868, Zo_SatMove = 5871,
Zo_ColorMove = 5875, Zo_SatStep = 5879,
Zo_xxxxyyyy = 5885, Zo_xx190A = 5887,
Zo_ColorStep = 5894, Zo_ColorMove = 5894,
Zo_ColorTempMoveUp = 5904, Zo_xxxxyyyy = 5904,
Zo_01xxxx000000000000 = 5920, Zo_ColorStep = 5913,
Zo_ColorTempMoveDown = 5939, Zo_ColorTempMoveUp = 5923,
Zo_03xxxx000000000000 = 5957, Zo_01xxxx000000000000 = 5939,
Zo_ColorTempMoveStop = 5976, Zo_ColorTempMoveDown = 5958,
Zo_00xxxx000000000000 = 5994, Zo_03xxxx000000000000 = 5976,
Zo_ColorTempMove = 6013, Zo_ColorTempMoveStop = 5995,
Zo_xxyyyy000000000000 = 6027, Zo_00xxxx000000000000 = 6013,
Zo_ColorTempStepUp = 6046, Zo_ColorTempMove = 6032,
Zo_01xxxx0A0000000000 = 6062, Zo_xxyyyy000000000000 = 6046,
Zo_ColorTempStepDown = 6081, Zo_ColorTempStepUp = 6065,
Zo_03xxxx0A0000000000 = 6099, Zo_01xxxx0A0000000000 = 6081,
Zo_ColorTempStep = 6118, Zo_ColorTempStepDown = 6100,
Zo_xxyyyy0A0000000000 = 6132, Zo_03xxxx0A0000000000 = 6118,
Zo_ArrowClick = 6151, Zo_ColorTempStep = 6137,
Zo_ArrowHold = 6162, Zo_xxyyyy0A0000000000 = 6151,
Zo_ArrowRelease = 6172, Zo_ArrowClick = 6170,
Zo_ZoneStatusChange = 6185, Zo_ArrowHold = 6181,
Zo_xxxxyyzz = 6202, Zo_ArrowRelease = 6191,
Zo_xxyyzzzz = 6211, Zo_ZoneStatusChange = 6204,
Zo_AddScene = 6220, Zo_xxxxyyzz = 6221,
Zo_xxyyyyzz = 6229, Zo_xxyyzzzz = 6230,
Zo_StoreScene = 6238, Zo_AddScene = 6239,
Zo_xxyyyyzz = 6248,
Zo_StoreScene = 6257,
}; };

View File

@ -278,7 +278,7 @@ const Z_AttributeConverter Z_PostProcess[] PROGMEM = {
{ Zsingle, Cx000C, 0x0041, Z_(AnalogInMaxValue), Cm1, 0 }, { Zsingle, Cx000C, 0x0041, Z_(AnalogInMaxValue), Cm1, 0 },
{ Zsingle, Cx000C, 0x0045, Z_(AnalogInMinValue), Cm1, 0 }, { Zsingle, Cx000C, 0x0045, Z_(AnalogInMinValue), Cm1, 0 },
{ Zbool, Cx000C, 0x0051, Z_(AnalogInOutOfService), Cm1, 0 }, { Zbool, Cx000C, 0x0051, Z_(AnalogInOutOfService), Cm1, 0 },
{ Zsingle, Cx000C, 0x0055, Z_(AqaraRotate), Cm1, 0 }, { Zsingle, Cx000C, 0x0055, Z_(AnalogValue), Cm1, 0 },
// { 0xFF, Cx000C, 0x0057, (AnalogInPriorityArray),Cm1, 0 }, // { 0xFF, Cx000C, 0x0057, (AnalogInPriorityArray),Cm1, 0 },
{ Zenum8, Cx000C, 0x0067, Z_(AnalogInReliability), Cm1, 0 }, { Zenum8, Cx000C, 0x0067, Z_(AnalogInReliability), Cm1, 0 },
// { 0xFF, Cx000C, 0x0068, (AnalogInRelinquishDefault),Cm1, 0 }, // { 0xFF, Cx000C, 0x0068, (AnalogInRelinquishDefault),Cm1, 0 },
@ -286,6 +286,7 @@ const Z_AttributeConverter Z_PostProcess[] PROGMEM = {
{ Zmap8, Cx000C, 0x006F, Z_(AnalogInStatusFlags), Cm1, 0 }, { Zmap8, Cx000C, 0x006F, Z_(AnalogInStatusFlags), Cm1, 0 },
{ Zenum16, Cx000C, 0x0075, Z_(AnalogInEngineeringUnits),Cm1, 0 }, { Zenum16, Cx000C, 0x0075, Z_(AnalogInEngineeringUnits),Cm1, 0 },
{ Zuint32, Cx000C, 0x0100, Z_(AnalogInApplicationType),Cm1, 0 }, { Zuint32, Cx000C, 0x0100, Z_(AnalogInApplicationType),Cm1, 0 },
{ Zuint16, Cx000C, 0xFF55, Z_(AqaraRotate), Cm1, 0 },
{ Zuint16, Cx000C, 0xFF05, Z_(Aqara_FF05), Cm1, 0 }, { Zuint16, Cx000C, 0xFF05, Z_(Aqara_FF05), Cm1, 0 },
// Analog Output cluster // Analog Output cluster
@ -572,7 +573,7 @@ const Z_AttributeConverter Z_PostProcess[] PROGMEM = {
{ Zuint8, Cx0500, 0xFFF0 + ZA_GlassBreak, Z_(GlassBreak),Cm1, 0 }, { Zuint8, Cx0500, 0xFFF0 + ZA_GlassBreak, Z_(GlassBreak),Cm1, 0 },
// Metering (Smart Energy) cluster // Metering (Smart Energy) cluster
{ Zuint48, Cx0702, 0x0000, Z_(CurrentSummDelivered), Cm1, 0 }, { Zuint48, Cx0702, 0x0000, Z_(EnergyTotal), Cm1, 0 },
// Meter Identification cluster // Meter Identification cluster
{ Zstring, Cx0B01, 0x0000, Z_(CompanyName), Cm1, 0 }, { Zstring, Cx0B01, 0x0000, Z_(CompanyName), Cm1, 0 },
@ -592,6 +593,8 @@ const Z_AttributeConverter Z_PostProcess[] PROGMEM = {
{ Zuint16, Cx0B04, 0x0505, Z_(RMSVoltage), Cm1 + Z_EXPORT_DATA, Z_MAPPING(Z_Data_Plug, mains_voltage) }, { Zuint16, Cx0B04, 0x0505, Z_(RMSVoltage), Cm1 + Z_EXPORT_DATA, Z_MAPPING(Z_Data_Plug, mains_voltage) },
{ Zuint16, Cx0B04, 0x0508, Z_(RMSCurrent), Cm1, 0 }, { Zuint16, Cx0B04, 0x0508, Z_(RMSCurrent), Cm1, 0 },
{ Zint16, Cx0B04, 0x050B, Z_(ActivePower), Cm1 + Z_EXPORT_DATA, Z_MAPPING(Z_Data_Plug, mains_power) }, { Zint16, Cx0B04, 0x050B, Z_(ActivePower), Cm1 + Z_EXPORT_DATA, Z_MAPPING(Z_Data_Plug, mains_power) },
{ Zint16, Cx0B04, 0x050E, Z_(ReactivePower), Cm1, 0 },
{ Zint16, Cx0B04, 0x050F, Z_(ApparentPower), Cm1, 0 },
// Diagnostics cluster // Diagnostics cluster
{ Zuint16, Cx0B05, 0x0000, Z_(NumberOfResets), Cm1, 0 }, { Zuint16, Cx0B05, 0x0000, Z_(NumberOfResets), Cm1, 0 },
@ -769,6 +772,7 @@ public:
void syntheticAqaraSensor2(Z_attribute_list &attr_list, class Z_attribute &attr); void syntheticAqaraSensor2(Z_attribute_list &attr_list, class Z_attribute &attr);
void syntheticAqaraCubeOrButton(Z_attribute_list &attr_list, class Z_attribute &attr); void syntheticAqaraCubeOrButton(Z_attribute_list &attr_list, class Z_attribute &attr);
void syntheticAqaraVibration(Z_attribute_list &attr_list, class Z_attribute &attr); void syntheticAqaraVibration(Z_attribute_list &attr_list, class Z_attribute &attr);
void syntheticAnalogValue(Z_attribute_list &attr_list, class Z_attribute &attr);
// handle read attributes auto-responder // handle read attributes auto-responder
void autoResponder(const uint16_t *attr_list_ids, size_t attr_len); void autoResponder(const uint16_t *attr_list_ids, size_t attr_len);
@ -1230,6 +1234,9 @@ void ZCLFrame::generateSyntheticAttributes(Z_attribute_list& attr_list) {
case 0x01010508: case 0x01010508:
syntheticAqaraVibration(attr_list, attr); syntheticAqaraVibration(attr_list, attr);
break; break;
case 0x000C0055: // Analog Value
syntheticAnalogValue(attr_list, attr);
break;
} }
} }
} }
@ -1552,6 +1559,21 @@ void ZCLFrame::parseClusterSpecificCommand(Z_attribute_list& attr_list) {
} }
} }
// ======================================================================
// Convert AnalogValue according to the device type
void ZCLFrame::syntheticAnalogValue(Z_attribute_list &attr_list, class Z_attribute &attr) {
const char * modelId_c = zigbee_devices.getModelId(_srcaddr); // null if unknown
String modelId((char*) modelId_c);
if (modelId.startsWith(F("lumi.sensor_cube"))) {
attr.setKeyId(0x000C, 0xFF55); // change to AqaraRotate
}
if (modelId.startsWith(F("lumi.plug"))) {
attr.setKeyId(0x0702, 0x0000); // change to EnergyTotal
}
}
// ====================================================================== // ======================================================================
// New version of synthetic attribute generation // New version of synthetic attribute generation
void ZCLFrame::syntheticAqaraSensor(Z_attribute_list &attr_list, class Z_attribute &attr) { void ZCLFrame::syntheticAqaraSensor(Z_attribute_list &attr_list, class Z_attribute &attr) {
@ -1603,6 +1625,14 @@ void ZCLFrame::syntheticAqaraSensor(Z_attribute_list &attr_list, class Z_attribu
} else if (0x66 == attrid) { } else if (0x66 == attrid) {
attr_list.addAttribute(0x0403, 0x0000).setUInt((ival32 + 50) / 100); // Pressure attr_list.addAttribute(0x0403, 0x0000).setUInt((ival32 + 50) / 100); // Pressure
} }
} else if (modelId.startsWith(F("lumi.plug"))) {
if (0x64 == attrid) {
attr_list.addAttribute(0x0600, 0x0000).setInt(uval32); // Power (on/off)
} else if (0x98 == attrid) {
attr_list.addAttribute(0x0B04, 0x050B).setInt(ival32); // Active Power
} else if (0x95 == attrid) {
attr_list.addAttribute(0x0702, 0x0000).setUInt(uval32); // EnergyDelivered
}
} else { } else {
translated = false; // we didn't find a match translated = false; // we didn't find a match
} }