mirror of
https://github.com/arendst/Tasmota.git
synced 2025-04-23 22:37:16 +00:00
Merge pull request #9407 from s-hadinger/zigbee_sea_pressure_dev
Zigbee add SeaPressure
This commit is contained in:
commit
d0b2b9f70a
@ -328,6 +328,7 @@ const char Z_strings[] PROGMEM =
|
||||
"PressureMaxScaledValue" "\x00"
|
||||
"PressureScaledTolerance" "\x00"
|
||||
"PressureScale" "\x00"
|
||||
"SeaPressure" "\x00"
|
||||
"FlowRate" "\x00"
|
||||
"FlowMinMeasuredValue" "\x00"
|
||||
"FlowMaxMeasuredValue" "\x00"
|
||||
@ -707,128 +708,129 @@ enum Z_offsets {
|
||||
Zo_PressureMaxScaledValue = 4338,
|
||||
Zo_PressureScaledTolerance = 4361,
|
||||
Zo_PressureScale = 4385,
|
||||
Zo_FlowRate = 4399,
|
||||
Zo_FlowMinMeasuredValue = 4408,
|
||||
Zo_FlowMaxMeasuredValue = 4429,
|
||||
Zo_FlowTolerance = 4450,
|
||||
Zo_Humidity = 4464,
|
||||
Zo_HumidityMinMeasuredValue = 4473,
|
||||
Zo_HumidityMaxMeasuredValue = 4498,
|
||||
Zo_HumidityTolerance = 4523,
|
||||
Zo_Occupancy = 4541,
|
||||
Zo_OccupancySensorType = 4551,
|
||||
Zo_ZoneState = 4571,
|
||||
Zo_ZoneType = 4581,
|
||||
Zo_ZoneStatus = 4590,
|
||||
Zo_CurrentSummDelivered = 4601,
|
||||
Zo_CompanyName = 4622,
|
||||
Zo_MeterTypeID = 4634,
|
||||
Zo_DataQualityID = 4646,
|
||||
Zo_CustomerName = 4660,
|
||||
Zo_Model = 4673,
|
||||
Zo_PartNumber = 4679,
|
||||
Zo_ProductRevision = 4690,
|
||||
Zo_SoftwareRevision = 4706,
|
||||
Zo_UtilityName = 4723,
|
||||
Zo_POD = 4735,
|
||||
Zo_AvailablePower = 4739,
|
||||
Zo_PowerThreshold = 4754,
|
||||
Zo_RMSVoltage = 4769,
|
||||
Zo_RMSCurrent = 4780,
|
||||
Zo_ActivePower = 4791,
|
||||
Zo_NumberOfResets = 4803,
|
||||
Zo_PersistentMemoryWrites = 4818,
|
||||
Zo_LastMessageLQI = 4841,
|
||||
Zo_LastMessageRSSI = 4856,
|
||||
Zo_Identify = 4872,
|
||||
Zo_xxxx = 4881,
|
||||
Zo_IdentifyQuery = 4886,
|
||||
Zo_AddGroup = 4900,
|
||||
Zo_xxxx00 = 4909,
|
||||
Zo_ViewGroup = 4916,
|
||||
Zo_GetGroup = 4926,
|
||||
Zo_01xxxx = 4935,
|
||||
Zo_GetAllGroups = 4942,
|
||||
Zo_00 = 4955,
|
||||
Zo_RemoveGroup = 4958,
|
||||
Zo_RemoveAllGroups = 4970,
|
||||
Zo_ViewScene = 4986,
|
||||
Zo_xxxxyy = 4996,
|
||||
Zo_RemoveScene = 5003,
|
||||
Zo_RemoveAllScenes = 5015,
|
||||
Zo_RecallScene = 5031,
|
||||
Zo_GetSceneMembership = 5043,
|
||||
Zo_PowerOffEffect = 5062,
|
||||
Zo_xxyy = 5077,
|
||||
Zo_PowerOnRecall = 5082,
|
||||
Zo_PowerOnTimer = 5096,
|
||||
Zo_xxyyyyzzzz = 5109,
|
||||
Zo_xx0A00 = 5120,
|
||||
Zo_DimmerUp = 5127,
|
||||
Zo_00190200 = 5136,
|
||||
Zo_DimmerDown = 5145,
|
||||
Zo_01190200 = 5156,
|
||||
Zo_DimmerStop = 5165,
|
||||
Zo_ResetAlarm = 5176,
|
||||
Zo_xxyyyy = 5187,
|
||||
Zo_ResetAllAlarms = 5194,
|
||||
Zo_xx000A00 = 5209,
|
||||
Zo_HueSat = 5218,
|
||||
Zo_xxyy0A00 = 5225,
|
||||
Zo_Color = 5234,
|
||||
Zo_xxxxyyyy0A00 = 5240,
|
||||
Zo_xxxx0A00 = 5253,
|
||||
Zo_ShutterOpen = 5262,
|
||||
Zo_ShutterClose = 5274,
|
||||
Zo_ShutterStop = 5287,
|
||||
Zo_ShutterLift = 5299,
|
||||
Zo_xx = 5311,
|
||||
Zo_ShutterTilt = 5314,
|
||||
Zo_Shutter = 5326,
|
||||
Zo_DimmerMove = 5334,
|
||||
Zo_xx0A = 5345,
|
||||
Zo_DimmerStepUp = 5350,
|
||||
Zo_00xx0A00 = 5363,
|
||||
Zo_DimmerStepDown = 5372,
|
||||
Zo_01xx0A00 = 5387,
|
||||
Zo_DimmerStep = 5396,
|
||||
Zo_xx190A00 = 5407,
|
||||
Zo_01 = 5416,
|
||||
Zo_HueMove = 5419,
|
||||
Zo_xx19 = 5427,
|
||||
Zo_HueStepUp = 5432,
|
||||
Zo_HueStepDown = 5442,
|
||||
Zo_03xx0A00 = 5454,
|
||||
Zo_HueStep = 5463,
|
||||
Zo_SatMove = 5471,
|
||||
Zo_SatStep = 5479,
|
||||
Zo_xx190A = 5487,
|
||||
Zo_ColorMove = 5494,
|
||||
Zo_xxxxyyyy = 5504,
|
||||
Zo_ColorStep = 5513,
|
||||
Zo_ColorTempMoveUp = 5523,
|
||||
Zo_01xxxx000000000000 = 5539,
|
||||
Zo_ColorTempMoveDown = 5558,
|
||||
Zo_03xxxx000000000000 = 5576,
|
||||
Zo_ColorTempMoveStop = 5595,
|
||||
Zo_00xxxx000000000000 = 5613,
|
||||
Zo_ColorTempMove = 5632,
|
||||
Zo_xxyyyy000000000000 = 5646,
|
||||
Zo_ColorTempStepUp = 5665,
|
||||
Zo_01xxxx0A0000000000 = 5681,
|
||||
Zo_ColorTempStepDown = 5700,
|
||||
Zo_03xxxx0A0000000000 = 5718,
|
||||
Zo_ColorTempStep = 5737,
|
||||
Zo_xxyyyy0A0000000000 = 5751,
|
||||
Zo_ArrowClick = 5770,
|
||||
Zo_ArrowHold = 5781,
|
||||
Zo_ArrowRelease = 5791,
|
||||
Zo_ZoneStatusChange = 5804,
|
||||
Zo_xxxxyyzz = 5821,
|
||||
Zo_xxyyzzzz = 5830,
|
||||
Zo_AddScene = 5839,
|
||||
Zo_xxyyyyzz = 5848,
|
||||
Zo_StoreScene = 5857,
|
||||
Zo_SeaPressure = 4399,
|
||||
Zo_FlowRate = 4411,
|
||||
Zo_FlowMinMeasuredValue = 4420,
|
||||
Zo_FlowMaxMeasuredValue = 4441,
|
||||
Zo_FlowTolerance = 4462,
|
||||
Zo_Humidity = 4476,
|
||||
Zo_HumidityMinMeasuredValue = 4485,
|
||||
Zo_HumidityMaxMeasuredValue = 4510,
|
||||
Zo_HumidityTolerance = 4535,
|
||||
Zo_Occupancy = 4553,
|
||||
Zo_OccupancySensorType = 4563,
|
||||
Zo_ZoneState = 4583,
|
||||
Zo_ZoneType = 4593,
|
||||
Zo_ZoneStatus = 4602,
|
||||
Zo_CurrentSummDelivered = 4613,
|
||||
Zo_CompanyName = 4634,
|
||||
Zo_MeterTypeID = 4646,
|
||||
Zo_DataQualityID = 4658,
|
||||
Zo_CustomerName = 4672,
|
||||
Zo_Model = 4685,
|
||||
Zo_PartNumber = 4691,
|
||||
Zo_ProductRevision = 4702,
|
||||
Zo_SoftwareRevision = 4718,
|
||||
Zo_UtilityName = 4735,
|
||||
Zo_POD = 4747,
|
||||
Zo_AvailablePower = 4751,
|
||||
Zo_PowerThreshold = 4766,
|
||||
Zo_RMSVoltage = 4781,
|
||||
Zo_RMSCurrent = 4792,
|
||||
Zo_ActivePower = 4803,
|
||||
Zo_NumberOfResets = 4815,
|
||||
Zo_PersistentMemoryWrites = 4830,
|
||||
Zo_LastMessageLQI = 4853,
|
||||
Zo_LastMessageRSSI = 4868,
|
||||
Zo_Identify = 4884,
|
||||
Zo_xxxx = 4893,
|
||||
Zo_IdentifyQuery = 4898,
|
||||
Zo_AddGroup = 4912,
|
||||
Zo_xxxx00 = 4921,
|
||||
Zo_ViewGroup = 4928,
|
||||
Zo_GetGroup = 4938,
|
||||
Zo_01xxxx = 4947,
|
||||
Zo_GetAllGroups = 4954,
|
||||
Zo_00 = 4967,
|
||||
Zo_RemoveGroup = 4970,
|
||||
Zo_RemoveAllGroups = 4982,
|
||||
Zo_ViewScene = 4998,
|
||||
Zo_xxxxyy = 5008,
|
||||
Zo_RemoveScene = 5015,
|
||||
Zo_RemoveAllScenes = 5027,
|
||||
Zo_RecallScene = 5043,
|
||||
Zo_GetSceneMembership = 5055,
|
||||
Zo_PowerOffEffect = 5074,
|
||||
Zo_xxyy = 5089,
|
||||
Zo_PowerOnRecall = 5094,
|
||||
Zo_PowerOnTimer = 5108,
|
||||
Zo_xxyyyyzzzz = 5121,
|
||||
Zo_xx0A00 = 5132,
|
||||
Zo_DimmerUp = 5139,
|
||||
Zo_00190200 = 5148,
|
||||
Zo_DimmerDown = 5157,
|
||||
Zo_01190200 = 5168,
|
||||
Zo_DimmerStop = 5177,
|
||||
Zo_ResetAlarm = 5188,
|
||||
Zo_xxyyyy = 5199,
|
||||
Zo_ResetAllAlarms = 5206,
|
||||
Zo_xx000A00 = 5221,
|
||||
Zo_HueSat = 5230,
|
||||
Zo_xxyy0A00 = 5237,
|
||||
Zo_Color = 5246,
|
||||
Zo_xxxxyyyy0A00 = 5252,
|
||||
Zo_xxxx0A00 = 5265,
|
||||
Zo_ShutterOpen = 5274,
|
||||
Zo_ShutterClose = 5286,
|
||||
Zo_ShutterStop = 5299,
|
||||
Zo_ShutterLift = 5311,
|
||||
Zo_xx = 5323,
|
||||
Zo_ShutterTilt = 5326,
|
||||
Zo_Shutter = 5338,
|
||||
Zo_DimmerMove = 5346,
|
||||
Zo_xx0A = 5357,
|
||||
Zo_DimmerStepUp = 5362,
|
||||
Zo_00xx0A00 = 5375,
|
||||
Zo_DimmerStepDown = 5384,
|
||||
Zo_01xx0A00 = 5399,
|
||||
Zo_DimmerStep = 5408,
|
||||
Zo_xx190A00 = 5419,
|
||||
Zo_01 = 5428,
|
||||
Zo_HueMove = 5431,
|
||||
Zo_xx19 = 5439,
|
||||
Zo_HueStepUp = 5444,
|
||||
Zo_HueStepDown = 5454,
|
||||
Zo_03xx0A00 = 5466,
|
||||
Zo_HueStep = 5475,
|
||||
Zo_SatMove = 5483,
|
||||
Zo_SatStep = 5491,
|
||||
Zo_xx190A = 5499,
|
||||
Zo_ColorMove = 5506,
|
||||
Zo_xxxxyyyy = 5516,
|
||||
Zo_ColorStep = 5525,
|
||||
Zo_ColorTempMoveUp = 5535,
|
||||
Zo_01xxxx000000000000 = 5551,
|
||||
Zo_ColorTempMoveDown = 5570,
|
||||
Zo_03xxxx000000000000 = 5588,
|
||||
Zo_ColorTempMoveStop = 5607,
|
||||
Zo_00xxxx000000000000 = 5625,
|
||||
Zo_ColorTempMove = 5644,
|
||||
Zo_xxyyyy000000000000 = 5658,
|
||||
Zo_ColorTempStepUp = 5677,
|
||||
Zo_01xxxx0A0000000000 = 5693,
|
||||
Zo_ColorTempStepDown = 5712,
|
||||
Zo_03xxxx0A0000000000 = 5730,
|
||||
Zo_ColorTempStep = 5749,
|
||||
Zo_xxyyyy0A0000000000 = 5763,
|
||||
Zo_ArrowClick = 5782,
|
||||
Zo_ArrowHold = 5793,
|
||||
Zo_ArrowRelease = 5803,
|
||||
Zo_ZoneStatusChange = 5816,
|
||||
Zo_xxxxyyzz = 5833,
|
||||
Zo_xxyyzzzz = 5842,
|
||||
Zo_AddScene = 5851,
|
||||
Zo_xxyyyyzz = 5860,
|
||||
Zo_StoreScene = 5869,
|
||||
};
|
||||
|
||||
|
||||
|
@ -489,6 +489,7 @@ const Z_AttributeConverter Z_PostProcess[] PROGMEM = {
|
||||
{ Zint16, Cx0403, 0x0012, Z_(PressureMaxScaledValue), 1 }, //
|
||||
{ Zuint16, Cx0403, 0x0013, Z_(PressureScaledTolerance), 1 }, //
|
||||
{ Zint8, Cx0403, 0x0014, Z_(PressureScale), 1 }, //
|
||||
{ Zint16, Cx0403, 0xFF00, Z_(SeaPressure), 1 }, // Pressure at Sea Level, Tasmota specific
|
||||
{ Zunk, Cx0403, 0xFFFF, Z_(), 0 }, // Remove all other Pressure values
|
||||
|
||||
// Flow Measurement cluster
|
||||
@ -665,6 +666,7 @@ public:
|
||||
|
||||
void parseReportAttributes(Z_attribute_list& attr_list);
|
||||
void generateSyntheticAttributes(Z_attribute_list& attr_list);
|
||||
void computeSyntheticAttributes(Z_attribute_list& attr_list);
|
||||
void generateCallBacks(Z_attribute_list& attr_list);
|
||||
void parseReadAttributes(Z_attribute_list& attr_list);
|
||||
void parseReadAttributesResponse(Z_attribute_list& attr_list);
|
||||
@ -1096,6 +1098,9 @@ void ZCLFrame::parseReportAttributes(Z_attribute_list& attr_list) {
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Extract attributes hidden in other compound attributes
|
||||
//
|
||||
void ZCLFrame::generateSyntheticAttributes(Z_attribute_list& attr_list) {
|
||||
// scan through attributes and apply specific converters
|
||||
for (auto &attr : attr_list) {
|
||||
@ -1103,11 +1108,6 @@ void ZCLFrame::generateSyntheticAttributes(Z_attribute_list& attr_list) {
|
||||
uint32_t ccccaaaa = (attr.key.id.cluster << 16) | attr.key.id.attr_id;
|
||||
|
||||
switch (ccccaaaa) { // 0xccccaaaa . c=cluster, a=attribute
|
||||
case 0x00010020: // BatteryVoltage
|
||||
if (attr_list.countAttribute(0x0001,0x0021) == 0) { // if it does not already contain BatteryPercentage
|
||||
uint32_t mv = attr.getUInt()*100;
|
||||
attr_list.addAttribute(0x0001, 0x0021).setUInt(toPercentageCR2032(mv) * 2);
|
||||
}
|
||||
case 0x0000FF01:
|
||||
syntheticAqaraSensor(attr_list, attr);
|
||||
break;
|
||||
@ -1125,6 +1125,33 @@ void ZCLFrame::generateSyntheticAttributes(Z_attribute_list& attr_list) {
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Compute new attributes based on the standard set
|
||||
// Note: both function are now split to compute on extracted attributes
|
||||
//
|
||||
void ZCLFrame::computeSyntheticAttributes(Z_attribute_list& attr_list) {
|
||||
// scan through attributes and apply specific converters
|
||||
for (auto &attr : attr_list) {
|
||||
if (attr.key_is_str) { continue; } // pass if key is a name
|
||||
uint32_t ccccaaaa = (attr.key.id.cluster << 16) | attr.key.id.attr_id;
|
||||
|
||||
switch (ccccaaaa) { // 0xccccaaaa . c=cluster, a=attribute
|
||||
case 0x00010020: // BatteryVoltage
|
||||
if (attr_list.countAttribute(0x0001,0x0021) == 0) { // if it does not already contain BatteryPercentage
|
||||
uint32_t mv = attr.getUInt()*100;
|
||||
attr_list.addAttribute(0x0001, 0x0021).setUInt(toPercentageCR2032(mv) * 2);
|
||||
}
|
||||
break;
|
||||
case 0x04030000: // Pressure
|
||||
int16_t pressure = attr.getInt();
|
||||
int16_t pressure_sealevel = (pressure / FastPrecisePow(1.0 - ((float)Settings.altitude / 44330.0f), 5.255f)) - 21.6f;
|
||||
attr_list.addAttribute(0x0403, 0xFF00).setInt(pressure_sealevel);
|
||||
// We create a synthetic attribute 0403/FF00 to indicate sea level
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set deferred callbacks for Occupancy
|
||||
// TODO make delay a parameter
|
||||
void ZCLFrame::generateCallBacks(Z_attribute_list& attr_list) {
|
||||
@ -1672,6 +1699,7 @@ void ZCLFrame::postProcessAttributes(uint16_t shortaddr, Z_attribute_list& attr_
|
||||
case 0x03000007: device.ct = uval16; break;
|
||||
case 0x03000008: device.colormode = uval16; break;
|
||||
case 0x04020000: device.temperature = fval * 10 + 0.5f; break;
|
||||
case 0x0403FF00: device.pressure = fval + 0.5f; break; // give priority to sea level
|
||||
case 0x04030000: device.pressure = fval + 0.5f; break;
|
||||
case 0x04050000: device.humidity = fval + 0.5f; break;
|
||||
case 0x0B040505: device.mains_voltage = uval16; break;
|
||||
|
@ -1396,6 +1396,7 @@ void Z_IncomingMessage(class ZCLFrame &zcl_received) {
|
||||
}
|
||||
|
||||
zcl_received.generateSyntheticAttributes(attr_list);
|
||||
zcl_received.computeSyntheticAttributes(attr_list);
|
||||
zcl_received.generateCallBacks(attr_list); // set deferred callbacks, ex: Occupancy
|
||||
zcl_received.postProcessAttributes(srcaddr, attr_list);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user