XKNX

A KNX library written in Python

Introduction

Changelog

XKNX Object

Lights / Dimmer

Cover

Switches

Time

Sensors

Binary Sensors

HVAC

Configuration

Home Assistant Plugin

Time

Overview

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.

Example

time = Time(xknx, 'TimeTest', group_address='1/2/3')
xknx.devices.add(time)

# Sending time to knx bus
await xknx.devices['TimeTest'].sync()

Configuration via xknx.yaml

Time objects are usually configured via xknx.yaml:

groups:
    time:
        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, 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()

Interface

from xknx import XKNX,Time

xknx = XKNX()
time = Time(xknx, 'TimeTest', group_address='1/2/3')

# Sending Time to KNX bus 
await time.sync()