Link Search Menu Expand Document



XKNX provides the possibility to send the local time, date or both combined to the KNX bus in regular intervals. This can be used to display the time within KNX touch sensors or for KNX automation schemes programmed with the ETS.


time_device = DateTime(
    xknx, 'TimeTest',

# `sync()` doesn't send a GroupValueRead when localtime is True but sends the current time to KNX bus
await xknx.devices['TimeTest'].sync()
  • xknx is the XKNX object.
  • name is the name of the object.
  • group_address is the KNX group address of the sensor device.
  • broadcast_type defines the value type that will be sent to the KNX bus. Valid attributes are: ‘time’, ‘date’ and ‘datetime’. Default: time
  • localtime If set True sync() and GroupValueRead requests always return the current local time. On False the set value will be sent. Default: True
  • device_updated_cb awaitable callback for each update.

Configuration via xknx.yaml

Time objects are usually configured via xknx.yaml:

        General.Time: {group_address: '2/1/2'}

Daemon mode

When XKNX is started in daemon mode, with START_STATE_UPDATER enabled, XKNX will automatically send the time to the KNX bus with the sync_state-loop.

import asyncio
from xknx import XKNX
from xknx.devices import DateTime

async def main():
    async with XKNX(daemon_mode=True) as xknx:
        time = DateTime(xknx, 'TimeTest', group_address='1/2/3')
        print("Sending time to KNX bus every hour")


from xknx import XKNX
from xknx.devices import DateTime

xknx = XKNX()
time_device = DateTime(xknx, 'TimeTest', group_address='1/2/3', broadcast_type='time')

await xknx.start()
# Sending Time to KNX bus
await time_device.broadcast_localtime()