mirror of
https://github.com/esphome/esphome.git
synced 2024-11-29 18:24:13 +01:00
TTP229-LSF i2c device support (#489)
* setting up non i2c ttp229 * add component * fixed const and multiconf * fixed issues with i2c address (it is fixed for this device renamed component and platform to ttp229_lsf => i2c device. There is another ttp229_bsf device that uses a proprietary bus protocol * max channels is 0 to 15 * folow up on code review * fixed Component ttf229_lsf
This commit is contained in:
parent
0272048899
commit
cb9f36a153
2 changed files with 49 additions and 0 deletions
24
esphome/components/binary_sensor/ttp229_lsf.py
Normal file
24
esphome/components/binary_sensor/ttp229_lsf.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
import voluptuous as vol
|
||||
|
||||
from esphome.components import binary_sensor
|
||||
from esphome.components.ttp229_lsf import TTP229LSFComponent, CONF_TTP229_ID
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import CONF_CHANNEL, CONF_NAME
|
||||
from esphome.cpp_generator import get_variable
|
||||
|
||||
DEPENDENCIES = ['ttp229_lsf']
|
||||
TTP229Channel = binary_sensor.binary_sensor_ns.class_(
|
||||
'TTP229Channel', binary_sensor.BinarySensor)
|
||||
|
||||
PLATFORM_SCHEMA = cv.nameable(binary_sensor.BINARY_SENSOR_PLATFORM_SCHEMA.extend({
|
||||
cv.GenerateID(): cv.declare_variable_id(TTP229Channel),
|
||||
cv.GenerateID(CONF_TTP229_ID): cv.use_variable_id(TTP229LSFComponent),
|
||||
vol.Required(CONF_CHANNEL): vol.All(vol.Coerce(int), vol.Range(min=0, max=15))
|
||||
}))
|
||||
|
||||
|
||||
def to_code(config):
|
||||
for hub in get_variable(config[CONF_TTP229_ID]):
|
||||
yield
|
||||
rhs = TTP229Channel.new(config[CONF_NAME], config[CONF_CHANNEL])
|
||||
binary_sensor.register_binary_sensor(hub.add_channel(rhs), config)
|
25
esphome/components/ttp229_lsf.py
Normal file
25
esphome/components/ttp229_lsf.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
from esphome.components import binary_sensor
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import CONF_ID
|
||||
from esphome.cpp_generator import Pvariable
|
||||
from esphome.cpp_helpers import setup_component
|
||||
from esphome.cpp_types import App, Component
|
||||
|
||||
DEPENDENCIES = ['i2c']
|
||||
|
||||
CONF_TTP229_ID = 'ttp229_id'
|
||||
TTP229LSFComponent = binary_sensor.binary_sensor_ns.class_('TTP229LSFComponent', Component)
|
||||
|
||||
CONFIG_SCHEMA = cv.Schema({
|
||||
cv.GenerateID(): cv.declare_variable_id(TTP229LSFComponent),
|
||||
}).extend(cv.COMPONENT_SCHEMA.schema)
|
||||
|
||||
|
||||
def to_code(config):
|
||||
rhs = App.make_ttp229_lsf()
|
||||
var = Pvariable(config[CONF_ID], rhs)
|
||||
|
||||
setup_component(var, config)
|
||||
|
||||
|
||||
BUILD_FLAGS = '-DUSE_TTP229_LSF'
|
Loading…
Reference in a new issue