A KNX library written in Python
XKNX provides the possibility to send the local time 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 = Time(xknx, 'TimeTest', group_address='1/2/3')
xknx.devices.add(time)
# Sending time to knx bus
await xknx.devices['TimeTest'].sync()
Time objects are usually configured via xknx.yaml
:
groups:
time:
General.Time: {group_address: '2/1/2'}
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, Time
async def main():
xknx = XKNX()
time = Time(xknx, 'TimeTest', group_address='1/2/3')
xknx.devices.add(time)
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()
loop.run_until_complete(main())
loop.close()
from xknx import XKNX,Time
xknx = XKNX()
time = Time(xknx, 'TimeTest', group_address='1/2/3')
# Sending Time to KNX bus
await time.sync()