Repository: XKNX/xknx
Pull request #1295 (2023-06-26 11:43:12)

Fix processing custom time data
<!--
  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 processing custom time data

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)
- [ ] Code quality improvements to existing code or addition of tests

## Checklist

- [ ] The documentation has been adjusted accordingly
- [x] Tests have been added that prove the fix is effective or that the feature works
- [x] The changes are documented in the changelog (docs/changelog.md)


Patch:
diff --git a/docs/changelog.md b/docs/changelog.md
index b8f82bdf..d69ebc67 100644
--- a/docs/changelog.md
+++ b/docs/changelog.md
@@ -6,6 +6,12 @@ nav_order: 2
 
 # Changelog
 
+# 2.11.1 DateTime fix 2023-06-26
+
+### Bugfixes
+
+- Fix processing custom time data in DateTime devices.
+
 # 2.11.0 DateTime state 2023-06-25
 
 ### Devices
diff --git a/xknx/__version__.py b/xknx/__version__.py
index bdf59505..d23692c0 100644
--- a/xknx/__version__.py
+++ b/xknx/__version__.py
@@ -1,3 +1,3 @@
 """XKNX version."""
 
-__version__ = "2.11.0"
+__version__ = "2.11.1"
diff --git a/xknx/devices/datetime.py b/xknx/devices/datetime.py
index 6ee05827..af996e8c 100644
--- a/xknx/devices/datetime.py
+++ b/xknx/devices/datetime.py
@@ -96,6 +96,10 @@ class DateTime(Device):
         """Set time and send to KNX bus."""
         await self.remote_value.set(struct_time)
 
+    async def process_group_write(self, telegram: Telegram) -> None:
+        """Process incoming and outgoing GROUP WRITE telegram."""
+        await self.remote_value.process(telegram)
+
     async def process_group_read(self, telegram: Telegram) -> None:
         """Process incoming GROUP READ telegram."""
         if self.localtime:


Test patch:
diff --git a/requirements/testing.txt b/requirements/testing.txt
index 7ccefc8a..28505ef7 100644
--- a/requirements/testing.txt
+++ b/requirements/testing.txt
@@ -3,11 +3,11 @@ pre-commit==3.3.3
 isort==5.12.0
 flake8==6.0.0
 pylint==2.17.4
-pytest==7.3.2
+pytest==7.4.0
 pytest-asyncio==0.21.0
 pytest-cov==4.1.0
 pytest-icdiff==0.6
 ruff==0.0.275
 setuptools==68.0.0
-tox==4.6.2
+tox==4.6.3
 mypy==1.4.1
diff --git a/test/devices_tests/datetime_test.py b/test/devices_tests/datetime_test.py
index ef1d6847..af06abc6 100644
--- a/test/devices_tests/datetime_test.py
+++ b/test/devices_tests/datetime_test.py
@@ -30,12 +30,17 @@ class TestDateTime:
             broadcast_type="TIME",
             localtime=False,
         )
-        await self.datetime.set(time.struct_time([2017, 1, 7, 9, 13, 14, 6, 0, 0]))
+        assert self.datetime.remote_value.value is None
+
+        test_time = time.strptime("9:13:14", "%H:%M:%S")
+        await self.datetime.set(test_time)
         telegram = xknx.telegrams.get_nowait()
         assert telegram == Telegram(
             destination_address=GroupAddress("1/2/3"),
-            payload=GroupValueWrite(DPTArray((0xE9, 0xD, 0xE))),
+            payload=GroupValueWrite(DPTArray((0x9, 0xD, 0xE))),
         )
+        await self.datetime.process(telegram)
+        assert self.datetime.remote_value.value == test_time
 
     #
     # SYNC DateTime