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', group_address='1/2/3', broadcast_type='TIME', localtime=True ) # `sync()` doesn't send a GroupValueRead when localtime is True but sends the current time to KNX bus await xknx.devices['TimeTest'].sync()
xknxis the XKNX object.
nameis the name of the object.
group_addressis the KNX group address of the sensor device.
broadcast_typedefines the value type that will be sent to the KNX bus. Valid attributes are: ‘time’, ‘date’ and ‘datetime’. Default:
Truesync() and GroupValueRead requests always return the current local time. On
Falsethe set value will be sent. Default:
device_updated_cbawaitable callback for each update.
When XKNX is started in daemon mode, with START_STATE_UPDATER enabled, XKNX will automatically send the time to the KNX bus with the
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") asyncio.run(main())
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()