diff --git a/tasmota/xdrv_23_zigbee_5__constants.ino b/tasmota/xdrv_23_zigbee_5__constants.ino index 4176c7ee4..fc8b95661 100644 --- a/tasmota/xdrv_23_zigbee_5__constants.ino +++ b/tasmota/xdrv_23_zigbee_5__constants.ino @@ -381,6 +381,7 @@ const char Z_strings[] PROGMEM = "ProductURL" "\x00" "QualityMeasure" "\x00" "RGB" "\x00" + "RGBb" "\x00" "RMSCurrent" "\x00" "RMSVoltage" "\x00" "ReactivePower" "\x00" @@ -804,120 +805,121 @@ enum Z_offsets { Zo_ProductURL = 4956, Zo_QualityMeasure = 4967, Zo_RGB = 4982, - Zo_RMSCurrent = 4986, - Zo_RMSVoltage = 4997, - Zo_ReactivePower = 5008, - Zo_RecallScene = 5022, - Zo_RemainingTime = 5034, - Zo_RemoteSensing = 5048, - Zo_RemoveAllGroups = 5062, - Zo_RemoveAllScenes = 5078, - Zo_RemoveGroup = 5094, - Zo_RemoveScene = 5106, - Zo_ResetAlarm = 5118, - Zo_ResetAllAlarms = 5129, - Zo_SWBuildID = 5144, - Zo_Sat = 5154, - Zo_SatMove = 5158, - Zo_SatStep = 5166, - Zo_SceneCount = 5174, - Zo_SceneValid = 5185, - Zo_ScheduleMode = 5196, - Zo_SeaPressure = 5209, - Zo_ShortPollInterval = 5221, - Zo_Shutter = 5239, - Zo_ShutterClose = 5247, - Zo_ShutterLift = 5260, - Zo_ShutterOpen = 5272, - Zo_ShutterStop = 5284, - Zo_ShutterTilt = 5296, - Zo_SoftwareRevision = 5308, - Zo_StackVersion = 5325, - Zo_StandardTime = 5338, - Zo_StartUpOnOff = 5351, - Zo_Status = 5364, - Zo_StoreScene = 5371, - Zo_SwitchType = 5382, - Zo_SystemMode = 5393, - Zo_TRVBoost = 5404, - Zo_TRVChildProtection = 5413, - Zo_TRVMirrorDisplay = 5432, - Zo_TRVMode = 5449, - Zo_TRVWindowOpen = 5457, - Zo_TempTarget = 5471, - Zo_Temperature = 5482, - Zo_TemperatureMaxMeasuredValue = 5494, - Zo_TemperatureMinMeasuredValue = 5522, - Zo_TemperatureTolerance = 5550, - Zo_TerncyDuration = 5571, - Zo_TerncyRotate = 5586, - Zo_ThSetpoint = 5599, - Zo_Time = 5610, - Zo_TimeEpoch = 5615, - Zo_TimeStatus = 5625, - Zo_TimeZone = 5636, - Zo_TotalProfileNum = 5645, - Zo_TuyaAutoLock = 5661, - Zo_TuyaAwayDays = 5674, - Zo_TuyaAwayTemp = 5687, - Zo_TuyaBattery = 5700, - Zo_TuyaBoostTime = 5712, - Zo_TuyaChildLock = 5726, - Zo_TuyaComfortTemp = 5740, - Zo_TuyaEcoTemp = 5756, - Zo_TuyaFanMode = 5768, - Zo_TuyaForceMode = 5780, - Zo_TuyaMaxTemp = 5794, - Zo_TuyaMinTemp = 5806, - Zo_TuyaPreset = 5818, - Zo_TuyaScheduleHolidays = 5829, - Zo_TuyaScheduleWorkdays = 5850, - Zo_TuyaTempTarget = 5871, - Zo_TuyaValveDetection = 5886, - Zo_TuyaValvePosition = 5905, - Zo_TuyaWeekSelect = 5923, - Zo_TuyaWindowDetection = 5938, - Zo_UnoccupiedCoolingSetpoint = 5958, - Zo_UnoccupiedHeatingSetpoint = 5984, - Zo_UtilityName = 6010, - Zo_ValidUntilTime = 6022, - Zo_ValvePosition = 6037, - Zo_VelocityLift = 6051, - Zo_ViewGroup = 6064, - Zo_ViewScene = 6074, - Zo_Water = 6084, - Zo_WhitePointX = 6090, - Zo_WhitePointY = 6102, - Zo_WindowCoveringType = 6114, - Zo_X = 6133, - Zo_Y = 6135, - Zo_ZCLVersion = 6137, - Zo_ZoneState = 6148, - Zo_ZoneStatus = 6158, - Zo_ZoneStatusChange = 6169, - Zo_ZoneType = 6186, - Zo_xx = 6195, - Zo_xx000A00 = 6198, - Zo_xx0A = 6207, - Zo_xx0A00 = 6212, - Zo_xx19 = 6219, - Zo_xx190A = 6224, - Zo_xx190A00 = 6231, - Zo_xxxx = 6240, - Zo_xxxx00 = 6245, - Zo_xxxx0A00 = 6252, - Zo_xxxxyy = 6261, - Zo_xxxxyyyy = 6268, - Zo_xxxxyyyy0A00 = 6277, - Zo_xxxxyyzz = 6290, - Zo_xxyy = 6299, - Zo_xxyy0A00 = 6304, - Zo_xxyyyy = 6313, - Zo_xxyyyy000000000000 = 6320, - Zo_xxyyyy0A0000000000 = 6339, - Zo_xxyyyyzz = 6358, - Zo_xxyyyyzzzz = 6367, - Zo_xxyyzzzz = 6378, + Zo_RGBb = 4986, + Zo_RMSCurrent = 4991, + Zo_RMSVoltage = 5002, + Zo_ReactivePower = 5013, + Zo_RecallScene = 5027, + Zo_RemainingTime = 5039, + Zo_RemoteSensing = 5053, + Zo_RemoveAllGroups = 5067, + Zo_RemoveAllScenes = 5083, + Zo_RemoveGroup = 5099, + Zo_RemoveScene = 5111, + Zo_ResetAlarm = 5123, + Zo_ResetAllAlarms = 5134, + Zo_SWBuildID = 5149, + Zo_Sat = 5159, + Zo_SatMove = 5163, + Zo_SatStep = 5171, + Zo_SceneCount = 5179, + Zo_SceneValid = 5190, + Zo_ScheduleMode = 5201, + Zo_SeaPressure = 5214, + Zo_ShortPollInterval = 5226, + Zo_Shutter = 5244, + Zo_ShutterClose = 5252, + Zo_ShutterLift = 5265, + Zo_ShutterOpen = 5277, + Zo_ShutterStop = 5289, + Zo_ShutterTilt = 5301, + Zo_SoftwareRevision = 5313, + Zo_StackVersion = 5330, + Zo_StandardTime = 5343, + Zo_StartUpOnOff = 5356, + Zo_Status = 5369, + Zo_StoreScene = 5376, + Zo_SwitchType = 5387, + Zo_SystemMode = 5398, + Zo_TRVBoost = 5409, + Zo_TRVChildProtection = 5418, + Zo_TRVMirrorDisplay = 5437, + Zo_TRVMode = 5454, + Zo_TRVWindowOpen = 5462, + Zo_TempTarget = 5476, + Zo_Temperature = 5487, + Zo_TemperatureMaxMeasuredValue = 5499, + Zo_TemperatureMinMeasuredValue = 5527, + Zo_TemperatureTolerance = 5555, + Zo_TerncyDuration = 5576, + Zo_TerncyRotate = 5591, + Zo_ThSetpoint = 5604, + Zo_Time = 5615, + Zo_TimeEpoch = 5620, + Zo_TimeStatus = 5630, + Zo_TimeZone = 5641, + Zo_TotalProfileNum = 5650, + Zo_TuyaAutoLock = 5666, + Zo_TuyaAwayDays = 5679, + Zo_TuyaAwayTemp = 5692, + Zo_TuyaBattery = 5705, + Zo_TuyaBoostTime = 5717, + Zo_TuyaChildLock = 5731, + Zo_TuyaComfortTemp = 5745, + Zo_TuyaEcoTemp = 5761, + Zo_TuyaFanMode = 5773, + Zo_TuyaForceMode = 5785, + Zo_TuyaMaxTemp = 5799, + Zo_TuyaMinTemp = 5811, + Zo_TuyaPreset = 5823, + Zo_TuyaScheduleHolidays = 5834, + Zo_TuyaScheduleWorkdays = 5855, + Zo_TuyaTempTarget = 5876, + Zo_TuyaValveDetection = 5891, + Zo_TuyaValvePosition = 5910, + Zo_TuyaWeekSelect = 5928, + Zo_TuyaWindowDetection = 5943, + Zo_UnoccupiedCoolingSetpoint = 5963, + Zo_UnoccupiedHeatingSetpoint = 5989, + Zo_UtilityName = 6015, + Zo_ValidUntilTime = 6027, + Zo_ValvePosition = 6042, + Zo_VelocityLift = 6056, + Zo_ViewGroup = 6069, + Zo_ViewScene = 6079, + Zo_Water = 6089, + Zo_WhitePointX = 6095, + Zo_WhitePointY = 6107, + Zo_WindowCoveringType = 6119, + Zo_X = 6138, + Zo_Y = 6140, + Zo_ZCLVersion = 6142, + Zo_ZoneState = 6153, + Zo_ZoneStatus = 6163, + Zo_ZoneStatusChange = 6174, + Zo_ZoneType = 6191, + Zo_xx = 6200, + Zo_xx000A00 = 6203, + Zo_xx0A = 6212, + Zo_xx0A00 = 6217, + Zo_xx19 = 6224, + Zo_xx190A = 6229, + Zo_xx190A00 = 6236, + Zo_xxxx = 6245, + Zo_xxxx00 = 6250, + Zo_xxxx0A00 = 6257, + Zo_xxxxyy = 6266, + Zo_xxxxyyyy = 6273, + Zo_xxxxyyyy0A00 = 6282, + Zo_xxxxyyzz = 6295, + Zo_xxyy = 6304, + Zo_xxyy0A00 = 6309, + Zo_xxyyyy = 6318, + Zo_xxyyyy000000000000 = 6325, + Zo_xxyyyy0A0000000000 = 6344, + Zo_xxyyyyzz = 6363, + Zo_xxyyyyzzzz = 6372, + Zo_xxyyzzzz = 6383, }; diff --git a/tasmota/xdrv_23_zigbee_5_converters.ino b/tasmota/xdrv_23_zigbee_5_converters.ino index 28f222c99..1f47204a0 100644 --- a/tasmota/xdrv_23_zigbee_5_converters.ino +++ b/tasmota/xdrv_23_zigbee_5_converters.ino @@ -510,6 +510,7 @@ const Z_AttributeConverter Z_PostProcess[] PROGMEM = { { Zuint16, Cx0300, 0x003B, Z_(ColorPointBY), 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) + { Zoctstr, Cx0300, 0xFFF1, Z_(RGBb), Cm1, 0 }, // synthetic argument to show color as RGB including last known brightness // Illuminance Measurement cluster { Zuint16, Cx0400, 0x0000, Z_(Illuminance), Cm1 + Z_EXPORT_DATA, Z_MAPPING(Z_Data_PIR, illuminance) }, // Illuminance (in Lux) @@ -1287,6 +1288,7 @@ void ZCLFrame::removeInvalidAttributes(Z_attribute_list& attr_list) { // Note: both function are now split to compute on extracted attributes // void ZCLFrame::computeSyntheticAttributes(Z_attribute_list& attr_list) { + const Z_Device & device = zigbee_devices.findShortAddr(_srcaddr); const char * model_c = zigbee_devices.getModelId(_srcaddr); // null if unknown String modelId((char*) model_c); // scan through attributes and apply specific converters @@ -1360,6 +1362,23 @@ void ZCLFrame::computeSyntheticAttributes(Z_attribute_list& attr_list) { rgb.add8(g); rgb.add8(b); attr_list.addAttribute(0x0300, 0xFFF0).setBuf(rgb, 0, 3); + + // do we know ZbData for this bulb + uint8_t brightness = 255; + if (device.valid()) { + const Z_Data_Light & light = device.data.find(_srcendpoint); + if (light.validDimmer()) { + // Dimmer has a valid value + brightness = changeUIntScale(light.getDimmer(), 0, 254, 0, 255); // range is 0..255 + } + } + r = changeUIntScale(r, 0, 255, 0, brightness); + g = changeUIntScale(g, 0, 255, 0, brightness); + b = changeUIntScale(b, 0, 255, 0, brightness); + rgb.set8(0, r); + rgb.set8(1, g); + rgb.set8(2, b); + attr_list.addAttribute(0x0300, 0xFFF1).setBuf(rgb, 0, 3); } } }