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',

# Sending 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

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():
    xknx = XKNX()
    time = DateTime(xknx, 'TimeTest', group_address='1/2/3')
    print("Sending time to KNX bus every hour")
    await xknx.start(daemon_mode=True, state_updater=True)
    await xknx.stop()

# pylint: disable=invalid-name
loop = asyncio.get_event_loop()


from xknx import XKNX
from xknx.devices import DateTime

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

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