2018-08-24 22:44:15 +02:00
|
|
|
import voluptuous as vol
|
|
|
|
|
2018-11-08 16:01:07 +01:00
|
|
|
from esphomeyaml.components import binary_sensor, display
|
2018-08-24 22:44:15 +02:00
|
|
|
from esphomeyaml.components.display.nextion import Nextion
|
2018-11-08 16:01:07 +01:00
|
|
|
import esphomeyaml.config_validation as cv
|
2018-08-24 22:44:15 +02:00
|
|
|
from esphomeyaml.const import CONF_COMPONENT_ID, CONF_NAME, CONF_PAGE_ID
|
|
|
|
from esphomeyaml.helpers import get_variable
|
|
|
|
|
|
|
|
DEPENDENCIES = ['display']
|
|
|
|
|
|
|
|
CONF_NEXTION_ID = 'nextion_id'
|
|
|
|
|
2018-11-12 23:30:31 +01:00
|
|
|
NextionTouchComponent = display.display_ns.class_('NextionTouchComponent',
|
|
|
|
binary_sensor.BinarySensor)
|
2018-11-08 16:01:07 +01:00
|
|
|
|
2018-08-24 22:44:15 +02:00
|
|
|
PLATFORM_SCHEMA = cv.nameable(binary_sensor.BINARY_SENSOR_PLATFORM_SCHEMA.extend({
|
2018-11-08 16:01:07 +01:00
|
|
|
cv.GenerateID(): cv.declare_variable_id(NextionTouchComponent),
|
2018-08-24 22:44:15 +02:00
|
|
|
vol.Required(CONF_PAGE_ID): cv.uint8_t,
|
|
|
|
vol.Required(CONF_COMPONENT_ID): cv.uint8_t,
|
|
|
|
cv.GenerateID(CONF_NEXTION_ID): cv.use_variable_id(Nextion)
|
|
|
|
}))
|
|
|
|
|
|
|
|
|
|
|
|
def to_code(config):
|
|
|
|
hub = None
|
|
|
|
for hub in get_variable(config[CONF_NEXTION_ID]):
|
|
|
|
yield
|
|
|
|
rhs = hub.make_touch_component(config[CONF_NAME], config[CONF_PAGE_ID],
|
|
|
|
config[CONF_COMPONENT_ID])
|
|
|
|
binary_sensor.register_binary_sensor(rhs, config)
|
2018-11-03 14:08:31 +01:00
|
|
|
|
|
|
|
|
|
|
|
def to_hass_config(data, config):
|
|
|
|
return binary_sensor.core_to_hass_config(data, config)
|