Repository: XKNX/xknx
Pull request #958 (2022-05-24 12:32:44)

Fix CEMI Ack-request Flag
<!--
  You are awesome! Thanks for contributing to our project!
  Please, DO NOT DELETE ANY TEXT from this template!.
-->
## Description
<!--
Please include a summary of the change and which issue is fixed.
Please also include relevant motivation and context.
List any dependencies that are required for this change.
-->
Fix CEMI Ack Flag
This is not needed to be set for KNX IP. It's also meant to request Layer 2 Acks.
See https://knx-user-forum.de/forum/%C3%B6ffentlicher-bereich/knx-eib-forum/1770282-cemi-frame-ack-request

Fixes # (issue)

## Type of change
<!--
Please tick the applicable options.
NOTE: Ticking multiple options most likely indicates
that your change is to big and it is suggested to split it into several smaller PRs.
-->

- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] This change requires a documentation update

## Checklist:

- [ ] The documentation has been adjusted accordingly
- [ ] Tests have been added that prove the fix is effective or that the feature works
- [ ] The changes are documented in the changelog (docs/changelog.md)

codecov[bot]: # [Codecov](https://codecov.io/gh/XKNX/xknx/pull/958?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XKNX) Report
> Merging [#958](https://codecov.io/gh/XKNX/xknx/pull/958?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XKNX) (eaaaae1) into [main](https://codecov.io/gh/XKNX/xknx/commit/a044f2b177ef87097654fab1664c4d7da4cbaffb?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XKNX) (a044f2b) will **not change** coverage.
> The diff coverage is `n/a`.

> :exclamation: Current head eaaaae1 differs from pull request most recent head e8aba44. Consider uploading reports for the commit e8aba44 to get more accurate results

[![Impacted file tree graph](https://codecov.io/gh/XKNX/xknx/pull/958/graphs/tree.svg?width=650&height=150&src=pr&token=irWbIygS84&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XKNX)](https://codecov.io/gh/XKNX/xknx/pull/958?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XKNX)

```diff
@@           Coverage Diff           @@
##             main     #958   +/-   ##
=======================================
  Coverage   95.99%   95.99%           
=======================================
  Files         131      131           
  Lines        7922     7922           
=======================================
  Hits         7605     7605           
  Misses        317      317           
```


| [Impacted Files](https://codecov.io/gh/XKNX/xknx/pull/958?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XKNX) | Coverage Δ | |
|---|---|---|
| [xknx/knxip/cemi\_frame.py](https://codecov.io/gh/XKNX/xknx/pull/958/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XKNX#diff-eGtueC9rbnhpcC9jZW1pX2ZyYW1lLnB5) | `100.00% <ø> (ø)` | |


Patch:
diff --git a/docs/changelog.md b/docs/changelog.md
index 45034ac5..392d98e0 100644
--- a/docs/changelog.md
+++ b/docs/changelog.md
@@ -11,6 +11,7 @@ nav_order: 2
 ### Internals
 
 - Use device subclass for `device_updated_cb` callback argument type hint
+- Fix CEMI Frame Ack-request flag set wrongly
 
 ## 0.21.3 Cover updates 2022-05-17
 
diff --git a/xknx/knxip/cemi_frame.py b/xknx/knxip/cemi_frame.py
index 49755785..5a50e04d 100644
--- a/xknx/knxip/cemi_frame.py
+++ b/xknx/knxip/cemi_frame.py
@@ -73,11 +73,7 @@ class CEMIFrame:
             CEMIFlags.FRAME_TYPE_STANDARD
             | CEMIFlags.DO_NOT_REPEAT
             | CEMIFlags.BROADCAST
-            | (
-                CEMIFlags.ACK_REQUESTED
-                if telegram.tpci.ack_request
-                else CEMIFlags.NO_ACK_REQUESTED
-            )
+            | CEMIFlags.NO_ACK_REQUESTED
             | CEMIFlags.CONFIRM_NO_ERROR
             | CEMIFlags.HOP_COUNT_1ST
         )


Test patch:
diff --git a/test/knxip_tests/cemi_frame_test.py b/test/knxip_tests/cemi_frame_test.py
index 46a7073f..9c3e202b 100644
--- a/test/knxip_tests/cemi_frame_test.py
+++ b/test/knxip_tests/cemi_frame_test.py
@@ -197,21 +197,6 @@ def test_telegram_individual_address():
     frame.telegram = _telegram
     assert frame.flags & 0x0080 == CEMIFlags.DESTINATION_INDIVIDUAL_ADDRESS
     assert frame.flags & 0x0C00 == CEMIFlags.PRIORITY_SYSTEM
-    assert frame.flags & 0x0200 == CEMIFlags.ACK_REQUESTED
-    # test CEMIFrame.telegram property
-    assert frame.telegram == _telegram
-
-
-def test_telegram_individual_address_ack():
-    """Test telegram conversion flags with a individual address."""
-    frame = CEMIFrame()
-    _telegram = Telegram(
-        destination_address=IndividualAddress(0), tpci=TAck(sequence_number=2)
-    )
-    # test CEMIFrame.telegram setter
-    frame.telegram = _telegram
-    assert frame.flags & 0x0080 == CEMIFlags.DESTINATION_INDIVIDUAL_ADDRESS
-    assert frame.flags & 0x0C00 == CEMIFlags.PRIORITY_SYSTEM
     assert frame.flags & 0x0200 == CEMIFlags.NO_ACK_REQUESTED
     # test CEMIFrame.telegram property
     assert frame.telegram == _telegram