mirror of
https://github.com/esphome/esphome.git
synced 2025-09-29 16:42:19 +01:00
Nextion on_touch
trigger (#5833)
This commit is contained in:
@@ -7,6 +7,7 @@ from esphome.const import (
|
||||
CONF_LAMBDA,
|
||||
CONF_BRIGHTNESS,
|
||||
CONF_TRIGGER_ID,
|
||||
CONF_ON_TOUCH,
|
||||
)
|
||||
from esphome.core import CORE
|
||||
from . import Nextion, nextion_ns, nextion_ref
|
||||
@@ -31,6 +32,7 @@ SetupTrigger = nextion_ns.class_("SetupTrigger", automation.Trigger.template())
|
||||
SleepTrigger = nextion_ns.class_("SleepTrigger", automation.Trigger.template())
|
||||
WakeTrigger = nextion_ns.class_("WakeTrigger", automation.Trigger.template())
|
||||
PageTrigger = nextion_ns.class_("PageTrigger", automation.Trigger.template())
|
||||
TouchTrigger = nextion_ns.class_("TouchTrigger", automation.Trigger.template())
|
||||
|
||||
CONFIG_SCHEMA = (
|
||||
display.BASIC_DISPLAY_SCHEMA.extend(
|
||||
@@ -58,6 +60,11 @@ CONFIG_SCHEMA = (
|
||||
cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(PageTrigger),
|
||||
}
|
||||
),
|
||||
cv.Optional(CONF_ON_TOUCH): automation.validate_automation(
|
||||
{
|
||||
cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(TouchTrigger),
|
||||
}
|
||||
),
|
||||
cv.Optional(CONF_TOUCH_SLEEP_TIMEOUT): cv.int_range(min=3, max=65535),
|
||||
cv.Optional(CONF_WAKE_UP_PAGE): cv.positive_int,
|
||||
cv.Optional(CONF_START_UP_PAGE): cv.positive_int,
|
||||
@@ -119,3 +126,15 @@ async def to_code(config):
|
||||
for conf in config.get(CONF_ON_PAGE, []):
|
||||
trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var)
|
||||
await automation.build_automation(trigger, [(cg.uint8, "x")], conf)
|
||||
|
||||
for conf in config.get(CONF_ON_TOUCH, []):
|
||||
trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var)
|
||||
await automation.build_automation(
|
||||
trigger,
|
||||
[
|
||||
(cg.uint8, "page_id"),
|
||||
(cg.uint8, "component_id"),
|
||||
(cg.bool_, "touch_event"),
|
||||
],
|
||||
conf,
|
||||
)
|
||||
|
Reference in New Issue
Block a user