1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-27 13:13:50 +00:00
Files
esphome/esphome/components/cap1188/binary_sensor.py
2025-03-20 09:51:23 -10:00

25 lines
775 B
Python

import esphome.codegen as cg
from esphome.components import binary_sensor
import esphome.config_validation as cv
from esphome.const import CONF_CHANNEL
from . import CONF_CAP1188_ID, CAP1188Component, cap1188_ns
DEPENDENCIES = ["cap1188"]
CAP1188Channel = cap1188_ns.class_("CAP1188Channel", binary_sensor.BinarySensor)
CONFIG_SCHEMA = binary_sensor.binary_sensor_schema(CAP1188Channel).extend(
{
cv.GenerateID(CONF_CAP1188_ID): cv.use_id(CAP1188Component),
cv.Required(CONF_CHANNEL): cv.int_range(min=0, max=7),
}
)
async def to_code(config):
var = await binary_sensor.new_binary_sensor(config)
hub = await cg.get_variable(config[CONF_CAP1188_ID])
cg.add(var.set_channel(config[CONF_CHANNEL]))
cg.add(hub.register_channel(var))