mirror of
https://github.com/esphome/esphome.git
synced 2025-09-30 00:52:20 +01:00
brightness support for nextion (#1109)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome.components import display, uart
|
||||
from esphome.const import CONF_ID, CONF_LAMBDA
|
||||
from esphome.const import CONF_ID, CONF_LAMBDA, CONF_BRIGHTNESS
|
||||
from . import nextion_ns
|
||||
|
||||
DEPENDENCIES = ['uart']
|
||||
@@ -12,6 +12,7 @@ NextionRef = Nextion.operator('ref')
|
||||
|
||||
CONFIG_SCHEMA = display.BASIC_DISPLAY_SCHEMA.extend({
|
||||
cv.GenerateID(): cv.declare_id(Nextion),
|
||||
cv.Optional(CONF_BRIGHTNESS, default=1.0): cv.percentage,
|
||||
}).extend(cv.polling_component_schema('5s')).extend(uart.UART_DEVICE_SCHEMA)
|
||||
|
||||
|
||||
@@ -20,6 +21,8 @@ def to_code(config):
|
||||
yield cg.register_component(var, config)
|
||||
yield uart.register_uart_device(var, config)
|
||||
|
||||
if CONF_BRIGHTNESS in config:
|
||||
cg.add(var.set_brightness(config[CONF_BRIGHTNESS]))
|
||||
if CONF_LAMBDA in config:
|
||||
lambda_ = yield cg.process_lambda(config[CONF_LAMBDA], [(NextionRef, 'it')],
|
||||
return_type=cg.void)
|
||||
|
Reference in New Issue
Block a user