From a14ce89715088edd5c97d51f4c14f6cd380dded8 Mon Sep 17 00:00:00 2001 From: Lucas Saavedra Vaz <32426024+lucasssvaz@users.noreply.github.com> Date: Tue, 22 Jul 2025 19:38:01 -0300 Subject: [PATCH 1/3] fix(tamc_termod_s3): Fix header includes (#11625) --- variants/tamc_termod_s3/pins_arduino.h | 1 + variants/tamc_termod_s3/variant.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/variants/tamc_termod_s3/pins_arduino.h b/variants/tamc_termod_s3/pins_arduino.h index 3d846c9b1..89d0b5107 100644 --- a/variants/tamc_termod_s3/pins_arduino.h +++ b/variants/tamc_termod_s3/pins_arduino.h @@ -2,6 +2,7 @@ #define Pins_Arduino_h #include +#include #define USB_VID 0x303a #define USB_PID 0x1001 diff --git a/variants/tamc_termod_s3/variant.cpp b/variants/tamc_termod_s3/variant.cpp index 8079bdbba..cc255c316 100644 --- a/variants/tamc_termod_s3/variant.cpp +++ b/variants/tamc_termod_s3/variant.cpp @@ -1,4 +1,5 @@ #include "Arduino.h" +#include "pins_arduino.h" float getBatteryVoltage() { int analogVolt = analogReadMilliVolts(1); From f08efa1fa3dd7c816ddfecc7ef26f771e4aff1a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Proch=C3=A1zka?= <90197375+P-R-O-C-H-Y@users.noreply.github.com> Date: Wed, 23 Jul 2025 00:43:23 +0200 Subject: [PATCH 2/3] feat(docs): Updaze Zigbee docs with latest changes (#11627) --- docs/en/zigbee/ep_fan_control.rst | 133 ++++++++++++++++++++++++++++++ docs/en/zigbee/zigbee_core.rst | 13 +++ docs/en/zigbee/zigbee_ep.rst | 13 +++ 3 files changed, 159 insertions(+) create mode 100644 docs/en/zigbee/ep_fan_control.rst diff --git a/docs/en/zigbee/ep_fan_control.rst b/docs/en/zigbee/ep_fan_control.rst new file mode 100644 index 000000000..1cfff0820 --- /dev/null +++ b/docs/en/zigbee/ep_fan_control.rst @@ -0,0 +1,133 @@ +################ +ZigbeeFanControl +################ + +About +----- + +The ``ZigbeeFanControl`` class provides a Zigbee endpoint for controlling fan devices in a Home Automation (HA) network. This endpoint implements the Fan Control cluster and allows for controlling fan modes and sequences. + +**Features:** +* Fan mode control (OFF, LOW, MEDIUM, HIGH, ON, AUTO, SMART) +* Fan mode sequence configuration +* State change callbacks +* Zigbee HA standard compliance + +**Use Cases:** +* Smart ceiling fans +* HVAC system fans +* Exhaust fans +* Any device requiring fan speed control + +API Reference +------------- + +Constructor +*********** + +ZigbeeFanControl +^^^^^^^^^^^^^^^^ + +Creates a new Zigbee fan control endpoint. + +.. code-block:: arduino + + ZigbeeFanControl(uint8_t endpoint); + +* ``endpoint`` - Endpoint number (1-254) + +Fan Mode Enums +************** + +ZigbeeFanMode +^^^^^^^^^^^^^ + +Available fan modes for controlling the fan speed and operation. + +.. code-block:: arduino + + enum ZigbeeFanMode { + FAN_MODE_OFF, // Fan is off + FAN_MODE_LOW, // Low speed + FAN_MODE_MEDIUM, // Medium speed + FAN_MODE_HIGH, // High speed + FAN_MODE_ON, // Fan is on (full speed) + FAN_MODE_AUTO, // Automatic mode + FAN_MODE_SMART, // Smart mode + }; + +ZigbeeFanModeSequence +^^^^^^^^^^^^^^^^^^^^^ + +Available fan mode sequences that define which modes are available for the fan. + +.. code-block:: arduino + + enum ZigbeeFanModeSequence { + FAN_MODE_SEQUENCE_LOW_MED_HIGH, // Low -> Medium -> High + FAN_MODE_SEQUENCE_LOW_HIGH, // Low -> High + FAN_MODE_SEQUENCE_LOW_MED_HIGH_AUTO, // Low -> Medium -> High -> Auto + FAN_MODE_SEQUENCE_LOW_HIGH_AUTO, // Low -> High -> Auto + FAN_MODE_SEQUENCE_ON_AUTO, // On -> Auto + }; + +API Methods +*********** + +setFanModeSequence +^^^^^^^^^^^^^^^^^^ + +Sets the fan mode sequence and initializes the fan control. + +.. code-block:: arduino + + bool setFanModeSequence(ZigbeeFanModeSequence sequence); + +* ``sequence`` - The fan mode sequence to set + +This function will return ``true`` if successful, ``false`` otherwise. + +getFanMode +^^^^^^^^^^ + +Gets the current fan mode. + +.. code-block:: arduino + + ZigbeeFanMode getFanMode(); + +This function will return current fan mode. + +getFanModeSequence +^^^^^^^^^^^^^^^^^^ + +Gets the current fan mode sequence. + +.. code-block:: arduino + + ZigbeeFanModeSequence getFanModeSequence(); + +This function will return current fan mode sequence. + +Event Handling +************** + +onFanModeChange +^^^^^^^^^^^^^^^ + +Sets a callback function to be called when the fan mode changes. + +.. code-block:: arduino + + void onFanModeChange(void (*callback)(ZigbeeFanMode mode)); + +* ``callback`` - Function to call when fan mode changes + +Example +------- + +Fan Control Implementation +************************** + +.. literalinclude:: ../../../libraries/Zigbee/examples/Zigbee_Fan_Control/Zigbee_Fan_Control.ino + :language: arduino diff --git a/docs/en/zigbee/zigbee_core.rst b/docs/en/zigbee/zigbee_core.rst index ee8f72342..89cf88ecc 100644 --- a/docs/en/zigbee/zigbee_core.rst +++ b/docs/en/zigbee/zigbee_core.rst @@ -345,6 +345,19 @@ Performs a factory reset, clearing all network settings. * ``restart`` - ``true`` to restart after reset (default: ``true``) +onGlobalDefaultResponse +^^^^^^^^^^^^^^^^^^^^^^^ + +Sets a global callback for default response messages. + +.. code-block:: arduino + + void onGlobalDefaultResponse(void (*callback)(zb_cmd_type_t resp_to_cmd, esp_zb_zcl_status_t status, uint8_t endpoint, uint16_t cluster)); + +* ``callback`` - Function pointer to the callback function + +This callback will be called for all endpoints when a default response is received. + Utility Functions ***************** diff --git a/docs/en/zigbee/zigbee_ep.rst b/docs/en/zigbee/zigbee_ep.rst index ce13d60bb..10c0c9fd0 100644 --- a/docs/en/zigbee/zigbee_ep.rst +++ b/docs/en/zigbee/zigbee_ep.rst @@ -345,6 +345,19 @@ Sets a callback function for identify events. * ``callback`` - Function to call when identify event occurs * ``time`` - Identify time in seconds +onDefaultResponse +^^^^^^^^^^^^^^^^^ + +Sets a callback for default response messages for this endpoint. + +.. code-block:: arduino + + void onDefaultResponse(void (*callback)(zb_cmd_type_t resp_to_cmd, esp_zb_zcl_status_t status)); + +* ``callback`` - Function pointer to the callback function + +This callback will be called when a default response is received for this specific endpoint. + Supported Endpoints ------------------- From ae634a92e3b3af3a68daf8e79b025a45ca9134ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Proch=C3=A1zka?= <90197375+P-R-O-C-H-Y@users.noreply.github.com> Date: Wed, 23 Jul 2025 00:44:36 +0200 Subject: [PATCH 3/3] fix(zigbee): Fix RGB color calculation (#11624) --- cores/esp32/ColorFormat.c | 12 +++++++----- cores/esp32/ColorFormat.h | 3 ++- libraries/Zigbee/src/ep/ZigbeeColorDimmableLight.cpp | 5 ++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/cores/esp32/ColorFormat.c b/cores/esp32/ColorFormat.c index a01123545..052249f21 100644 --- a/cores/esp32/ColorFormat.c +++ b/cores/esp32/ColorFormat.c @@ -119,10 +119,10 @@ espHsvColor_t espRgbColorToHsvColor(espRgbColor_t rgb) { } espRgbColor_t espXYColorToRgbColor(uint8_t Level, espXyColor_t xy) { - return espXYToRgbColor(Level, xy.x, xy.y); + return espXYToRgbColor(Level, xy.x, xy.y, true); } -espRgbColor_t espXYToRgbColor(uint8_t Level, uint16_t current_X, uint16_t current_Y) { +espRgbColor_t espXYToRgbColor(uint8_t Level, uint16_t current_X, uint16_t current_Y, bool addXYZScaling) { // convert xyY color space to RGB // https://www.easyrgb.com/en/math.php @@ -156,9 +156,11 @@ espRgbColor_t espXYToRgbColor(uint8_t Level, uint16_t current_X, uint16_t curren // X, Y and Z input refer to a D65/2° standard illuminant. // sR, sG and sB (standard RGB) output range = 0 ÷ 255 // convert XYZ to RGB - CIE XYZ to sRGB - X = X / 100.0f; - Y = Y / 100.0f; - Z = Z / 100.0f; + if (addXYZScaling) { + X = X / 100.0f; + Y = Y / 100.0f; + Z = Z / 100.0f; + } r = (X * 3.2406f) - (Y * 1.5372f) - (Z * 0.4986f); g = -(X * 0.9689f) + (Y * 1.8758f) + (Z * 0.0415f); diff --git a/cores/esp32/ColorFormat.h b/cores/esp32/ColorFormat.h index 0bb87145d..288b79b57 100644 --- a/cores/esp32/ColorFormat.h +++ b/cores/esp32/ColorFormat.h @@ -19,6 +19,7 @@ #pragma once #include +#include #ifdef __cplusplus extern "C" { #endif @@ -49,7 +50,7 @@ typedef struct HsvColor_t espHsvColor_t; typedef struct XyColor_t espXyColor_t; typedef struct CtColor_t espCtColor_t; -espRgbColor_t espXYToRgbColor(uint8_t Level, uint16_t current_X, uint16_t current_Y); +espRgbColor_t espXYToRgbColor(uint8_t Level, uint16_t current_X, uint16_t current_Y, bool addXYZScaling); espRgbColor_t espXYColorToRgb(uint8_t Level, espXyColor_t xy); espXyColor_t espRgbColorToXYColor(espRgbColor_t rgb); espXyColor_t espRgbToXYColor(uint8_t r, uint8_t g, uint8_t b); diff --git a/libraries/Zigbee/src/ep/ZigbeeColorDimmableLight.cpp b/libraries/Zigbee/src/ep/ZigbeeColorDimmableLight.cpp index 2fb07fc21..3611c232c 100644 --- a/libraries/Zigbee/src/ep/ZigbeeColorDimmableLight.cpp +++ b/libraries/Zigbee/src/ep/ZigbeeColorDimmableLight.cpp @@ -76,14 +76,13 @@ void ZigbeeColorDimmableLight::zbAttributeSet(const esp_zb_zcl_set_attr_value_me return; } else { log_w("Received message ignored. Attribute ID: %d not supported for Level Control", message->attribute.id); - //TODO: implement more attributes -> includes/zcl/esp_zigbee_zcl_level.h } } else if (message->info.cluster == ESP_ZB_ZCL_CLUSTER_ID_COLOR_CONTROL) { if (message->attribute.id == ESP_ZB_ZCL_ATTR_COLOR_CONTROL_CURRENT_X_ID && message->attribute.data.type == ESP_ZB_ZCL_ATTR_TYPE_U16) { uint16_t light_color_x = (*(uint16_t *)message->attribute.data.value); uint16_t light_color_y = getCurrentColorY(); //calculate RGB from XY and call setColor() - _current_color = espXYToRgbColor(255, light_color_x, light_color_y); //TODO: Check if level is correct + _current_color = espXYToRgbColor(255, light_color_x, light_color_y, false); lightChanged(); return; @@ -91,7 +90,7 @@ void ZigbeeColorDimmableLight::zbAttributeSet(const esp_zb_zcl_set_attr_value_me uint16_t light_color_x = getCurrentColorX(); uint16_t light_color_y = (*(uint16_t *)message->attribute.data.value); //calculate RGB from XY and call setColor() - _current_color = espXYToRgbColor(255, light_color_x, light_color_y); //TODO: Check if level is correct + _current_color = espXYToRgbColor(255, light_color_x, light_color_y, false); lightChanged(); return; } else if (message->attribute.id == ESP_ZB_ZCL_ATTR_COLOR_CONTROL_CURRENT_HUE_ID && message->attribute.data.type == ESP_ZB_ZCL_ATTR_TYPE_U8) {