Repository: XKNX/xknx

Issue:
2.6.0 filters telegrams from KNX gateway/tunnel device itself
**Description of problem:**

Since xknx 2.6.0, xknx no longer recieves/processes telegrams originating from the KNX gateway itself.
A RTU modbus device is connected directly to the gateway, which is why the packets originates from the gateway itself (address 1.1.255)
Other telegrams from the KNX/TP bus are received fine through the gateway.

- [X] using xknx standalone
- [X] using Home-Assistant knx integration

**Version information:**
- xknx / Home-Assistant release with the issue: xknx 2.6.0
- last working xknx / Home-Assistant release (if known): xknx 2.5.0

**KNX installation:**
Using a SE SpaceLYnk gateway, with a modbus based power meter connected. The gateway exposes the modbus data via KNX address 1/1/4 as a 4byte_float.
Other devices connected to the gateway over KNX/TP are unaffected by the update to 2.6.0 and still work.

Using https://github.com/XKNX/xknx/blob/main/examples/example_telegram_monitor.py to compare the versons.
With 2.5.0 i see telegrams from the modbus device, on 2.6.0 i don't.

Adding debug logging to the same script shows the frames being recieved, but ignored on 2.6.0:
`DEBUG:xknx.cemi:Ignoring own CEMI: <CEMIFrame code="L_DATA_IND" src_addr="IndividualAddress("1.1.255")" dst_addr="GroupAddress("1/1/4")" flags="1011110011100000" tpci="TDataGroup()" payload="<GroupValueWrite value="<DPTArray value="[0xbe,0xa5,0xbb,0xb8]" />" />" />`

This change seems to be related to this commit:
https://github.com/XKNX/xknx/commit/996697ae8cce878aadfcbd95833b1fde3367008a

Is there a reason for these frames now being ignored? Is it possible to roll back this change?

Discussion:
codecov[bot]: ## [Codecov](https://codecov.io/gh/XKNX/xknx/pull/1227?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XKNX) Report
> Merging [#1227](https://codecov.io/gh/XKNX/xknx/pull/1227?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XKNX) (05d63e0) into [main](https://codecov.io/gh/XKNX/xknx/commit/792864c5c8e6c9cd316af44012f8e261b5df9308?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XKNX) (792864c) will **decrease** coverage by `0.01%`.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/XKNX/xknx/pull/1227/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/1227?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XKNX)

```diff
@@            Coverage Diff             @@
##             main    #1227      +/-   ##
==========================================
- Coverage   96.59%   96.59%   -0.01%     
==========================================
  Files         148      148              
  Lines        9546     9543       -3     
==========================================
- Hits         9221     9218       -3     
  Misses        325      325              
```


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


Patch:
diff --git a/docs/changelog.md b/docs/changelog.md
index 88516e9f..7d8f4ec3 100644
--- a/docs/changelog.md
+++ b/docs/changelog.md
@@ -12,6 +12,7 @@ nav_order: 2
 
 - Add support for Device Management Configuration service.
 - Support CEMI M_Prop messages.
+- Don't ignore CEMIFrames with source address equal to `xknx.current_address`.
 
 ### Internals
 
diff --git a/xknx/cemi/cemi_handler.py b/xknx/cemi/cemi_handler.py
index 0361bb84..f095c6bb 100644
--- a/xknx/cemi/cemi_handler.py
+++ b/xknx/cemi/cemi_handler.py
@@ -118,14 +118,6 @@ class CEMIHandler:
             logger.warning("Received unexpected L_DATA_REQ frame: %s", cemi)
             self.xknx.connection_manager.cemi_count_incoming_error += 1
             return
-        if (
-            cemi.code is CEMIMessageCode.L_DATA_IND
-            and cemi.data.src_addr == self.xknx.current_address
-        ):
-            # L_DATA_IND frames from our own address should be ignored (may occur form routing)
-            logger.debug("Ignoring own CEMI: %s", cemi)
-            self.xknx.connection_manager.cemi_count_incoming_error += 1
-            return
         logger.debug("Incoming CEMI: %s", cemi)
 
         if self.data_secure is not None:


Test patch:
diff --git a/test/cemi_tests/cemi_handler_test.py b/test/cemi_tests/cemi_handler_test.py
index f45ad022..d972e1b0 100644
--- a/test/cemi_tests/cemi_handler_test.py
+++ b/test/cemi_tests/cemi_handler_test.py
@@ -166,7 +166,7 @@ def test_unsupported_cemi(raw):
         assert xknx.connection_manager.cemi_count_incoming_error == 1
 
 
-def test_incoming_from_self():
+def test_incoming_from_own_ia():
     """Test incoming CEMI from own IA."""
     xknx = XKNX()
     xknx.current_address = IndividualAddress("1.1.22")
@@ -178,5 +178,6 @@ def test_incoming_from_self():
     ) as mock_telegram_received:
         xknx.cemi_handler.handle_raw_cemi(raw)
         mock_debug.assert_called_once()
-        mock_telegram_received.assert_not_called()
-        assert xknx.connection_manager.cemi_count_incoming_error == 1
+        mock_telegram_received.assert_called_once()
+        assert xknx.connection_manager.cemi_count_incoming == 1
+        assert xknx.connection_manager.cemi_count_incoming_error == 0