Binary Sensor
Overview
Binary sensors which have either the state “on” or “off”. Binary sensors could be e.g. a switch in the wall (the thing you press on when switching on the light) or a motion detector.
The logic within switches can further handle if a button is pressed once or twice - and trigger different actions in HA. Use the attribute counter for this purpose.
Interface
xknxis the XKNX object.nameis the name of the object.group_address_stateis the KNX group address of the sensor device.invertinverts the payload so state “on” is represented by 0 on bus and “off” by 1. 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 toTrueignore_internal_statedefines if consecutive GroupValueWrite telegrams with same payload shall be processed, regardless of the current binary sensor state. Defaults toFalsecontext_timeouttime in seconds telegrams should be counted towards the current context to increment the counter. If setignore_internal_stateis setTrueinternally. GroupValueResponse telegrams are ignored for this. Defaults toNonealways_callbackdefines if a callback shall also be triggered for consecutive telegrams with same payload, regardless of the current binary sensor state. This has precedence overignore_internal_stateand is applied for GroupValueWrite and GroupValueResponse telegrams. Defaults toFalsereset_aftermay be used to reset the internal state toOFFagain after given time in sec. Defaults toNonedevice_updated_cbCallback for each update.
Example
binarysensor = BinarySensor(xknx, 'TestInput', group_address_state='2/3/4')
xknx.devices.async_add(binarysensor)
# Returns the last received Telegram or None
binarysensor.last_telegram