You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/en/matter/ep_window_covering.rst
+53-16Lines changed: 53 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -430,16 +430,32 @@ This function will return the operational state for the specified field (``STALL
430
430
Event Handling
431
431
**************
432
432
433
+
The ``MatterWindowCovering`` class automatically detects Matter commands and calls the appropriate callbacks when registered. There are two types of callbacks:
434
+
435
+
**Target Position Callbacks** (triggered when ``TargetPosition`` attributes change):
436
+
* ``onOpen()`` - called when ``UpOrOpen`` command is received (sets target to 0% = fully open)
437
+
* ``onClose()`` - called when ``DownOrClose`` command is received (sets target to 100% = fully closed)
438
+
* ``onStop()`` - called when ``StopMotion`` command is received (sets target to current position)
439
+
* ``onGoToLiftPercentage()`` - called when ``TargetPositionLiftPercent100ths`` changes (from any command, ``setTargetLiftPercent100ths()``, or direct attribute write)
440
+
* ``onGoToTiltPercentage()`` - called when ``TargetPositionTiltPercent100ths`` changes (from any command, ``setTargetTiltPercent100ths()``, or direct attribute write)
441
+
442
+
**Current Position Callback** (triggered when ``CurrentPosition`` attributes change):
443
+
* ``onChange()`` - called when ``CurrentPositionLiftPercent100ths`` or ``CurrentPositionTiltPercent100ths`` change (after ``setLiftPercentage()``/``setTiltPercentage()`` are called or when a Matter controller updates these attributes directly)
444
+
445
+
**Important:** ``onChange()`` is **not** automatically called when Matter commands are executed. Commands modify ``TargetPosition``, not ``CurrentPosition``. To trigger ``onChange()``, your ``onGoToLiftPercentage()`` or ``onGoToTiltPercentage()`` callback must call ``setLiftPercentage()`` or ``setTiltPercentage()`` when the physical device actually moves.
446
+
447
+
**Note:** All callbacks are optional. If a specific callback is not registered, only the generic ``onGoToLiftPercentage()`` or ``onGoToTiltPercentage()`` callbacks will be called (if registered).
448
+
433
449
onOpen
434
450
^^^^^^
435
451
436
-
Sets a callback function to be called when the window covering is opened.
452
+
Sets a callback function to be called when the ``UpOrOpen`` command is received from a Matter controller. This command sets the target position to 0% (fully open).
437
453
438
454
.. code-block:: arduino
439
455
440
456
void onOpen(EndPointOpenCB onChangeCB);
441
457
442
-
* ``onChangeCB`` - Function to call when window covering is opened
458
+
* ``onChangeCB`` - Function to call when ``UpOrOpen`` command is received
443
459
444
460
The callback signature is:
445
461
@@ -450,13 +466,13 @@ The callback signature is:
450
466
onClose
451
467
^^^^^^^
452
468
453
-
Sets a callback function to be called when the window covering is closed.
469
+
Sets a callback function to be called when the ``DownOrClose`` command is received from a Matter controller. This command sets the target position to 100% (fully closed).
454
470
455
471
.. code-block:: arduino
456
472
457
473
void onClose(EndPointCloseCB onChangeCB);
458
474
459
-
* ``onChangeCB`` - Function to call when window covering is closed
475
+
* ``onChangeCB`` - Function to call when ``DownOrClose`` command is received
460
476
461
477
The callback signature is:
462
478
@@ -467,51 +483,65 @@ The callback signature is:
467
483
onGoToLiftPercentage
468
484
^^^^^^^^^^^^^^^^^^^^
469
485
470
-
Sets a callback function to be called when the lift percentage changes.
486
+
Sets a callback function to be called when ``TargetPositionLiftPercent100ths`` changes. This is triggered by:
* Direct attribute writes to ``TargetPositionLiftPercent100ths``
490
+
491
+
This callback is always called when the target lift position changes, regardless of which command or method was used to change it.
492
+
493
+
**Note:** This callback receives the **target** position. To update the **current** position (which triggers ``onChange()``), call ``setLiftPercentage()`` when the physical device actually moves.
* Direct attribute writes to ``TargetPositionTiltPercent100ths``
516
+
517
+
This callback is always called when the target tilt position changes, regardless of which command or method was used to change it.
518
+
519
+
**Note:** This callback receives the **target** position. To update the **current** position (which triggers ``onChange()``), call ``setTiltPercentage()`` when the physical device actually moves.
* ``onChangeCB`` - Function to call when tilt percentage changes
525
+
* ``onChangeCB`` - Function to call when target tilt percentage changes
496
526
497
527
The callback signature is:
498
528
499
529
.. code-block:: arduino
500
530
501
531
bool onChangeCallback(uint8_t tiltPercent);
502
532
503
-
* ``tiltPercent`` - New tilt percentage (0-100)
533
+
* ``tiltPercent`` - Target tilt percentage (0-100, where 0 is fully closed, 100 is fully open)
504
534
505
535
onStop
506
536
^^^^^^
507
537
508
-
Sets a callback function to be called when the window covering movement is stopped.
538
+
Sets a callback function to be called when the ``StopMotion`` command is received from a Matter controller. This command sets the target position to the current position, effectively stopping any movement.
509
539
510
540
.. code-block:: arduino
511
541
512
542
void onStop(EndPointStopCB onChangeCB);
513
543
514
-
* ``onChangeCB`` - Function to call when window covering is stopped
544
+
* ``onChangeCB`` - Function to call when ``StopMotion`` command is received
515
545
516
546
The callback signature is:
517
547
@@ -522,22 +552,28 @@ The callback signature is:
522
552
onChange
523
553
^^^^^^^^
524
554
525
-
Sets a callback function to be called when any parameter changes.
555
+
Sets a callback function to be called when ``CurrentPositionLiftPercent100ths`` or ``CurrentPositionTiltPercent100ths`` attributes change. This is different from ``onGoToLiftPercentage()`` and ``onGoToTiltPercentage()``, which are called when ``TargetPosition`` attributes change.
556
+
557
+
**When ``onChange()`` is called:**
558
+
* When ``CurrentPositionLiftPercent100ths`` changes (after ``setLiftPercentage()`` is called or when a Matter controller updates this attribute directly)
559
+
* When ``CurrentPositionTiltPercent100ths`` changes (after ``setTiltPercentage()`` is called or when a Matter controller updates this attribute directly)
560
+
561
+
**Important:** ``onChange()`` is **not** automatically called when Matter commands are executed. Commands modify ``TargetPosition`` attributes, which trigger ``onGoToLiftPercentage()`` or ``onGoToTiltPercentage()`` callbacks instead. To trigger ``onChange()`` after a command, your ``onGoToLiftPercentage()`` or ``onGoToTiltPercentage()`` callback must call ``setLiftPercentage()`` or ``setTiltPercentage()`` to update the ``CurrentPosition`` attributes when the physical device actually moves.
526
562
527
563
.. code-block:: arduino
528
564
529
565
void onChange(EndPointCB onChangeCB);
530
566
531
-
* ``onChangeCB`` - Function to call when state changes
567
+
* ``onChangeCB`` - Function to call when current position attributes change
0 commit comments