Touchscreen Components¶
The touchscreen
component holds the base code for most touchscreen components
available in ESPHome and is responsible for passing the touch events to
binary_sensors
with the touchscreen
platform.
Base Touchscreen Configuration¶
# Example touchscreen
touchscreen:
- platform: ...
on_touch:
then:
...
Configuration variables:¶
on_touch (Optional, Automation): An automation to perform when the touchscreen is touched. See on_touch Trigger.
display (Required, ID): The display to use. If only one display is available, this can be omitted.
on_touch
Trigger¶
This automation will be triggered when the touchscreen detects a touch.
This trigger provides one argument named touch
of type touchscreen::TouchPoint which has two integer members: x
and y
which
represent the position of the touch in relation to the display width and height. It also has optional members that will be set
depending on the touchscreen platform.
Binary Sensor¶
The touchscreen
binary sensor allows you to setup areas on the touch screen as virtual
buttons.
binary_sensor:
- platform: touchscreen
name: Top Left Touch Button
x_min: 0
x_max: 100
y_min: 0
y_max: 100
page_id: home_page_id
Configuration variables:¶
name (Optional, string): The name for the binary sensor.
id (Optional, ID): Manually specify the ID used for code generation.
touchscreen_id (Optional, ID): Manually specify the ID of the touchscreen.
x_min (Required, int): Left coordinate of the screen area to be detected as the virtual button.
x_max (Required, int): Right coordinate of the screen area to be detected as the virtual button.
y_min (Required, int): Top coordinate of the screen area to be detected as the virtual button.
y_max (Required, int): Bottom coordinate of the screen area to be detected as the virtual button.
page_id (Optional, ID): Only trigger this binary sensor if the display is showing this page.
All other options from Binary Sensor.