esphome/esphome/components/binary_sensor/status.py

25 lines
955 B
Python
Raw Normal View History

from esphome.components import binary_sensor
import esphome.config_validation as cv
from esphome.const import CONF_ID, CONF_NAME
from esphome.cpp_generator import Pvariable
from esphome.cpp_helpers import setup_component
from esphome.cpp_types import App, Component
2018-04-07 01:23:03 +02:00
StatusBinarySensor = binary_sensor.binary_sensor_ns.class_('StatusBinarySensor',
binary_sensor.BinarySensor,
Component)
2018-06-02 22:22:20 +02:00
PLATFORM_SCHEMA = cv.nameable(binary_sensor.BINARY_SENSOR_PLATFORM_SCHEMA.extend({
cv.GenerateID(): cv.declare_variable_id(StatusBinarySensor),
}).extend(cv.COMPONENT_SCHEMA.schema))
2018-05-20 12:41:52 +02:00
2018-04-07 01:23:03 +02:00
def to_code(config):
rhs = App.make_status_binary_sensor(config[CONF_NAME])
status = Pvariable(config[CONF_ID], rhs)
binary_sensor.setup_binary_sensor(status, config)
setup_component(status, config)
2018-05-06 15:56:12 +02:00
BUILD_FLAGS = '-DUSE_STATUS_BINARY_SENSOR'