Link Search Menu Expand Document

Binary Sensor

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.


binarysensor = BinarySensor(xknx, 'TestInput', group_address_state='1/2/3', device_class='motion')


  • xknx is the XKNX object.
  • name is the name of the object.
  • group_address_state is the KNX group address of the sensor device.
  • invert inverts the payload so state “on” is represented by 0 on bus and “off” by 1. Defaults to False
  • sync_state defines if the value should be actively read from the bus. If False no GroupValueRead telegrams will be sent to its group address. Defaults to True
  • ignore_internal_state allows callback call regardless of the current binary sensor state. Defaults to False
  • context_timeout time in seconds telegrams should be counted towards the current context to increment the counter. If set ignore_internal_state is set True. Defaults to None
  • reset_after may be used to reset the internal state to OFF again after given time in sec. Defaults to None
  • device_class may be used to store the type of sensor, e.g. “motion” for motion detectors for Home-Assistant.
  • device_updated_cb awaitable callback for each update.


binarysensor = BinarySensor(xknx, 'TestInput', group_address_state='2/3/4')

# Returns the last received Telegram or None