Zigbee report colors as RGB

This commit is contained in:
Stephan Hadinger 2021-01-17 16:39:40 +01:00
parent 8cf07e8bbe
commit 454892c971
2 changed files with 150 additions and 116 deletions

View File

@ -73,7 +73,7 @@ def strings_to_pmem(arg):
DO NOT EDIT DO NOT EDIT
*/ */
const char Z_strings[] PROGMEM = const char Z_strings[] PROGMEM =
"\x00" "\x00"
"00" "\x00" "00" "\x00"
"00190200" "\x00" "00190200" "\x00"
@ -380,6 +380,7 @@ const char Z_strings[] PROGMEM =
"ProductRevision" "\x00" "ProductRevision" "\x00"
"ProductURL" "\x00" "ProductURL" "\x00"
"QualityMeasure" "\x00" "QualityMeasure" "\x00"
"RGB" "\x00"
"RMSCurrent" "\x00" "RMSCurrent" "\x00"
"RMSVoltage" "\x00" "RMSVoltage" "\x00"
"ReactivePower" "\x00" "ReactivePower" "\x00"
@ -802,120 +803,121 @@ enum Z_offsets {
Zo_ProductRevision = 4940, Zo_ProductRevision = 4940,
Zo_ProductURL = 4956, Zo_ProductURL = 4956,
Zo_QualityMeasure = 4967, Zo_QualityMeasure = 4967,
Zo_RMSCurrent = 4982, Zo_RGB = 4982,
Zo_RMSVoltage = 4993, Zo_RMSCurrent = 4986,
Zo_ReactivePower = 5004, Zo_RMSVoltage = 4997,
Zo_RecallScene = 5018, Zo_ReactivePower = 5008,
Zo_RemainingTime = 5030, Zo_RecallScene = 5022,
Zo_RemoteSensing = 5044, Zo_RemainingTime = 5034,
Zo_RemoveAllGroups = 5058, Zo_RemoteSensing = 5048,
Zo_RemoveAllScenes = 5074, Zo_RemoveAllGroups = 5062,
Zo_RemoveGroup = 5090, Zo_RemoveAllScenes = 5078,
Zo_RemoveScene = 5102, Zo_RemoveGroup = 5094,
Zo_ResetAlarm = 5114, Zo_RemoveScene = 5106,
Zo_ResetAllAlarms = 5125, Zo_ResetAlarm = 5118,
Zo_SWBuildID = 5140, Zo_ResetAllAlarms = 5129,
Zo_Sat = 5150, Zo_SWBuildID = 5144,
Zo_SatMove = 5154, Zo_Sat = 5154,
Zo_SatStep = 5162, Zo_SatMove = 5158,
Zo_SceneCount = 5170, Zo_SatStep = 5166,
Zo_SceneValid = 5181, Zo_SceneCount = 5174,
Zo_ScheduleMode = 5192, Zo_SceneValid = 5185,
Zo_SeaPressure = 5205, Zo_ScheduleMode = 5196,
Zo_ShortPollInterval = 5217, Zo_SeaPressure = 5209,
Zo_Shutter = 5235, Zo_ShortPollInterval = 5221,
Zo_ShutterClose = 5243, Zo_Shutter = 5239,
Zo_ShutterLift = 5256, Zo_ShutterClose = 5247,
Zo_ShutterOpen = 5268, Zo_ShutterLift = 5260,
Zo_ShutterStop = 5280, Zo_ShutterOpen = 5272,
Zo_ShutterTilt = 5292, Zo_ShutterStop = 5284,
Zo_SoftwareRevision = 5304, Zo_ShutterTilt = 5296,
Zo_StackVersion = 5321, Zo_SoftwareRevision = 5308,
Zo_StandardTime = 5334, Zo_StackVersion = 5325,
Zo_StartUpOnOff = 5347, Zo_StandardTime = 5338,
Zo_Status = 5360, Zo_StartUpOnOff = 5351,
Zo_StoreScene = 5367, Zo_Status = 5364,
Zo_SwitchType = 5378, Zo_StoreScene = 5371,
Zo_SystemMode = 5389, Zo_SwitchType = 5382,
Zo_TRVBoost = 5400, Zo_SystemMode = 5393,
Zo_TRVChildProtection = 5409, Zo_TRVBoost = 5404,
Zo_TRVMirrorDisplay = 5428, Zo_TRVChildProtection = 5413,
Zo_TRVMode = 5445, Zo_TRVMirrorDisplay = 5432,
Zo_TRVWindowOpen = 5453, Zo_TRVMode = 5449,
Zo_TempTarget = 5467, Zo_TRVWindowOpen = 5457,
Zo_Temperature = 5478, Zo_TempTarget = 5471,
Zo_TemperatureMaxMeasuredValue = 5490, Zo_Temperature = 5482,
Zo_TemperatureMinMeasuredValue = 5518, Zo_TemperatureMaxMeasuredValue = 5494,
Zo_TemperatureTolerance = 5546, Zo_TemperatureMinMeasuredValue = 5522,
Zo_TerncyDuration = 5567, Zo_TemperatureTolerance = 5550,
Zo_TerncyRotate = 5582, Zo_TerncyDuration = 5571,
Zo_ThSetpoint = 5595, Zo_TerncyRotate = 5586,
Zo_Time = 5606, Zo_ThSetpoint = 5599,
Zo_TimeEpoch = 5611, Zo_Time = 5610,
Zo_TimeStatus = 5621, Zo_TimeEpoch = 5615,
Zo_TimeZone = 5632, Zo_TimeStatus = 5625,
Zo_TotalProfileNum = 5641, Zo_TimeZone = 5636,
Zo_TuyaAutoLock = 5657, Zo_TotalProfileNum = 5645,
Zo_TuyaAwayDays = 5670, Zo_TuyaAutoLock = 5661,
Zo_TuyaAwayTemp = 5683, Zo_TuyaAwayDays = 5674,
Zo_TuyaBattery = 5696, Zo_TuyaAwayTemp = 5687,
Zo_TuyaBoostTime = 5708, Zo_TuyaBattery = 5700,
Zo_TuyaChildLock = 5722, Zo_TuyaBoostTime = 5712,
Zo_TuyaComfortTemp = 5736, Zo_TuyaChildLock = 5726,
Zo_TuyaEcoTemp = 5752, Zo_TuyaComfortTemp = 5740,
Zo_TuyaFanMode = 5764, Zo_TuyaEcoTemp = 5756,
Zo_TuyaForceMode = 5776, Zo_TuyaFanMode = 5768,
Zo_TuyaMaxTemp = 5790, Zo_TuyaForceMode = 5780,
Zo_TuyaMinTemp = 5802, Zo_TuyaMaxTemp = 5794,
Zo_TuyaPreset = 5814, Zo_TuyaMinTemp = 5806,
Zo_TuyaScheduleHolidays = 5825, Zo_TuyaPreset = 5818,
Zo_TuyaScheduleWorkdays = 5846, Zo_TuyaScheduleHolidays = 5829,
Zo_TuyaTempTarget = 5867, Zo_TuyaScheduleWorkdays = 5850,
Zo_TuyaValveDetection = 5882, Zo_TuyaTempTarget = 5871,
Zo_TuyaValvePosition = 5901, Zo_TuyaValveDetection = 5886,
Zo_TuyaWeekSelect = 5919, Zo_TuyaValvePosition = 5905,
Zo_TuyaWindowDetection = 5934, Zo_TuyaWeekSelect = 5923,
Zo_UnoccupiedCoolingSetpoint = 5954, Zo_TuyaWindowDetection = 5938,
Zo_UnoccupiedHeatingSetpoint = 5980, Zo_UnoccupiedCoolingSetpoint = 5958,
Zo_UtilityName = 6006, Zo_UnoccupiedHeatingSetpoint = 5984,
Zo_ValidUntilTime = 6018, Zo_UtilityName = 6010,
Zo_ValvePosition = 6033, Zo_ValidUntilTime = 6022,
Zo_VelocityLift = 6047, Zo_ValvePosition = 6037,
Zo_ViewGroup = 6060, Zo_VelocityLift = 6051,
Zo_ViewScene = 6070, Zo_ViewGroup = 6064,
Zo_Water = 6080, Zo_ViewScene = 6074,
Zo_WhitePointX = 6086, Zo_Water = 6084,
Zo_WhitePointY = 6098, Zo_WhitePointX = 6090,
Zo_WindowCoveringType = 6110, Zo_WhitePointY = 6102,
Zo_X = 6129, Zo_WindowCoveringType = 6114,
Zo_Y = 6131, Zo_X = 6133,
Zo_ZCLVersion = 6133, Zo_Y = 6135,
Zo_ZoneState = 6144, Zo_ZCLVersion = 6137,
Zo_ZoneStatus = 6154, Zo_ZoneState = 6148,
Zo_ZoneStatusChange = 6165, Zo_ZoneStatus = 6158,
Zo_ZoneType = 6182, Zo_ZoneStatusChange = 6169,
Zo_xx = 6191, Zo_ZoneType = 6186,
Zo_xx000A00 = 6194, Zo_xx = 6195,
Zo_xx0A = 6203, Zo_xx000A00 = 6198,
Zo_xx0A00 = 6208, Zo_xx0A = 6207,
Zo_xx19 = 6215, Zo_xx0A00 = 6212,
Zo_xx190A = 6220, Zo_xx19 = 6219,
Zo_xx190A00 = 6227, Zo_xx190A = 6224,
Zo_xxxx = 6236, Zo_xx190A00 = 6231,
Zo_xxxx00 = 6241, Zo_xxxx = 6240,
Zo_xxxx0A00 = 6248, Zo_xxxx00 = 6245,
Zo_xxxxyy = 6257, Zo_xxxx0A00 = 6252,
Zo_xxxxyyyy = 6264, Zo_xxxxyy = 6261,
Zo_xxxxyyyy0A00 = 6273, Zo_xxxxyyyy = 6268,
Zo_xxxxyyzz = 6286, Zo_xxxxyyyy0A00 = 6277,
Zo_xxyy = 6295, Zo_xxxxyyzz = 6290,
Zo_xxyy0A00 = 6300, Zo_xxyy = 6299,
Zo_xxyyyy = 6309, Zo_xxyy0A00 = 6304,
Zo_xxyyyy000000000000 = 6316, Zo_xxyyyy = 6313,
Zo_xxyyyy0A0000000000 = 6335, Zo_xxyyyy000000000000 = 6320,
Zo_xxyyyyzz = 6354, Zo_xxyyyy0A0000000000 = 6339,
Zo_xxyyyyzzzz = 6363, Zo_xxyyyyzz = 6358,
Zo_xxyyzzzz = 6374, Zo_xxyyyyzzzz = 6367,
Zo_xxyyzzzz = 6378,
}; };

View File

@ -509,6 +509,7 @@ const Z_AttributeConverter Z_PostProcess[] PROGMEM = {
{ Zuint16, Cx0300, 0x003A, Z_(ColorPointBX), Cm1, 0 }, { Zuint16, Cx0300, 0x003A, Z_(ColorPointBX), Cm1, 0 },
{ Zuint16, Cx0300, 0x003B, Z_(ColorPointBY), Cm1, 0 }, { Zuint16, Cx0300, 0x003B, Z_(ColorPointBY), Cm1, 0 },
{ Zuint8, Cx0300, 0x003C, Z_(ColorPointBIntensity), Cm1, 0 }, { Zuint8, Cx0300, 0x003C, Z_(ColorPointBIntensity), Cm1, 0 },
{ Zoctstr, Cx0300, 0xFFF0, Z_(RGB), Cm1, 0 }, // synthetic argument to show color as RGB (converted from HueSat or XY)
// Illuminance Measurement cluster // Illuminance Measurement cluster
{ Zuint16, Cx0400, 0x0000, Z_(Illuminance), Cm1 + Z_EXPORT_DATA, Z_MAPPING(Z_Data_PIR, illuminance) }, // Illuminance (in Lux) { Zuint16, Cx0400, 0x0000, Z_(Illuminance), Cm1 + Z_EXPORT_DATA, Z_MAPPING(Z_Data_PIR, illuminance) }, // Illuminance (in Lux)
@ -1332,7 +1333,38 @@ void ZCLFrame::computeSyntheticAttributes(Z_attribute_list& attr_list) {
} }
} }
break; break;
case 0x04030000: // Pressure case 0x03000000: // Hue
case 0x03000001: // Sat
case 0x03000003: // X
case 0x03000004: // Y
{ // generate synthetic RGB
const Z_attribute * attr_rgb = attr_list.findAttribute(0x0300, 0xFFF0);
if (attr_rgb == nullptr) { // make sure we didn't already computed it
uint8_t r,g,b;
bool is_rgb = false;
const Z_attribute * attr_hue = attr_list.findAttribute(0x0300, 0x0000);
const Z_attribute * attr_sat = attr_list.findAttribute(0x0300, 0x0001);
const Z_attribute * attr_x = attr_list.findAttribute(0x0300, 0x0003);
const Z_attribute * attr_y = attr_list.findAttribute(0x0300, 0x0004);
if (attr_hue && attr_sat) {
uint8_t sat = changeUIntScale(attr_sat->getUInt(), 0, 254, 0, 255);
HsToRgb(attr_hue->getUInt(), sat, &r, &g, &b);
is_rgb = true;
} else if (attr_x && attr_y) {
XyToRgb(attr_x->getUInt() / 65535.0f, attr_y->getUInt() / 65535.0f, &r, &g, &b);
is_rgb = true;
}
if (is_rgb) {
SBuffer rgb(3);
rgb.add8(r);
rgb.add8(g);
rgb.add8(b);
attr_list.addAttribute(0x0300, 0xFFF0).setBuf(rgb, 0, 3);
}
}
}
break;
case 0x04030000: // SeaPressure
{ {
int16_t pressure = attr.getInt(); int16_t pressure = attr.getInt();
int16_t pressure_sealevel = (pressure / FastPrecisePow(1.0 - ((float)Settings.altitude / 44330.0f), 5.255f)) - 21.6f; int16_t pressure_sealevel = (pressure / FastPrecisePow(1.0 - ((float)Settings.altitude / 44330.0f), 5.255f)) - 21.6f;