Switches
Overview
Switches are simple representations of binary actors. They mainly support switching on and off.
Interface
xknxis the XKNX object.nameis the name of the object.group_addressis the KNX group address of the switch device. Used for sending.group_address_stateis the KNX group address of the switch state. Used for updating and reading state.respond_to_readifTrueGroupValueRead requests to thegroup_addressare answered. Defaults toFalsesync_statedefines if and how often the value should be actively read from the bus. IfFalseno GroupValueRead telegrams will be sent to its group address. Defaults toTrueinvertinverts the payload so state “on” is represented by 0 on bus and “off” by 1. Defaults toFalsereset_aftermay be used to reset the switch toOFFagain after given time in sec. Defaults toNonedevice_updated_cbCallback for each update.
Example
switch = Switch(xknx, 'TestOutlet', group_address='1/2/3')
xknx.devices.async_add(switch)
# Accessing switch via xknx.devices
await xknx.devices['TestOutlet'].set_on()
# Switching switch on
await switch.set_on()
# Switching switch off
await switch.set_off()
# Accessing state
print(switch.state)
# Requesting state via KNX GroupValueRead
await switch.sync(wait_for_result=True)