Add support for TM1638 Led and Key component (#3340)

This commit is contained in:
Jordan W. Cobb authored and GitHub committed 2022-09-12 08:30:15 -07:00
1 parent 9ff187c3f8
commit cbd8d70431
17 files changed
+855

No files matched your search

@@ -0,0 +1,22 @@
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome.components import binary_sensor
from esphome.const import CONF_KEY
from ..display import tm1638_ns, TM1638Component, CONF_TM1638_ID
TM1638Key = tm1638_ns.class_("TM1638Key", binary_sensor.BinarySensor)
CONFIG_SCHEMA = binary_sensor.BINARY_SENSOR_SCHEMA.extend(
{
cv.GenerateID(): cv.declare_id(TM1638Key),
cv.GenerateID(CONF_TM1638_ID): cv.use_id(TM1638Component),
cv.Required(CONF_KEY): cv.int_range(min=0, max=15),
}
)
async def to_code(config):
var = await binary_sensor.new_binary_sensor(config)
cg.add(var.set_keycode(config[CONF_KEY]))
hub = await cg.get_variable(config[CONF_TM1638_ID])
cg.add(hub.register_listener(var))