mirror of
https://github.com/esphome/esphome.git
synced 2024-11-22 23:18:10 +01:00
Fix custom components not registered (#441)
This commit is contained in:
parent
efe81e0856
commit
fe54700687
4 changed files with 16 additions and 16 deletions
|
@ -3,7 +3,7 @@ import voluptuous as vol
|
|||
from esphome.components import binary_sensor
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import CONF_BINARY_SENSORS, CONF_ID, CONF_LAMBDA, CONF_NAME
|
||||
from esphome.cpp_generator import Pvariable, add, process_lambda, variable
|
||||
from esphome.cpp_generator import add, process_lambda, variable
|
||||
from esphome.cpp_types import std_vector
|
||||
|
||||
CustomBinarySensorConstructor = binary_sensor.binary_sensor_ns.class_(
|
||||
|
@ -27,9 +27,9 @@ def to_code(config):
|
|||
rhs = CustomBinarySensorConstructor(template_)
|
||||
custom = variable(config[CONF_ID], rhs)
|
||||
for i, conf in enumerate(config[CONF_BINARY_SENSORS]):
|
||||
var = Pvariable(conf[CONF_ID], custom.get_binary_sensor(i))
|
||||
add(var.set_name(conf[CONF_NAME]))
|
||||
binary_sensor.setup_binary_sensor(var, conf)
|
||||
rhs = custom.Pget_binary_sensor(i)
|
||||
add(rhs.set_name(conf[CONF_NAME]))
|
||||
binary_sensor.register_binary_sensor(rhs, conf)
|
||||
|
||||
|
||||
BUILD_FLAGS = '-DUSE_CUSTOM_BINARY_SENSOR'
|
||||
|
|
|
@ -3,7 +3,7 @@ import voluptuous as vol
|
|||
from esphome.components import sensor
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import CONF_ID, CONF_LAMBDA, CONF_NAME, CONF_SENSORS
|
||||
from esphome.cpp_generator import Pvariable, add, process_lambda, variable
|
||||
from esphome.cpp_generator import add, process_lambda, variable
|
||||
from esphome.cpp_types import std_vector
|
||||
|
||||
CustomSensorConstructor = sensor.sensor_ns.class_('CustomSensorConstructor')
|
||||
|
@ -25,9 +25,9 @@ def to_code(config):
|
|||
rhs = CustomSensorConstructor(template_)
|
||||
custom = variable(config[CONF_ID], rhs)
|
||||
for i, conf in enumerate(config[CONF_SENSORS]):
|
||||
var = Pvariable(conf[CONF_ID], custom.get_sensor(i))
|
||||
add(var.set_name(conf[CONF_NAME]))
|
||||
sensor.setup_sensor(var, conf)
|
||||
rhs = custom.Pget_sensor(i)
|
||||
add(rhs.set_name(conf[CONF_NAME]))
|
||||
sensor.register_sensor(rhs, conf)
|
||||
|
||||
|
||||
BUILD_FLAGS = '-DUSE_CUSTOM_SENSOR'
|
||||
|
|
|
@ -3,7 +3,7 @@ import voluptuous as vol
|
|||
from esphome.components import switch
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import CONF_ID, CONF_LAMBDA, CONF_NAME, CONF_SWITCHES
|
||||
from esphome.cpp_generator import Pvariable, add, process_lambda, variable
|
||||
from esphome.cpp_generator import add, process_lambda, variable
|
||||
from esphome.cpp_types import std_vector
|
||||
|
||||
CustomSwitchConstructor = switch.switch_ns.class_('CustomSwitchConstructor')
|
||||
|
@ -26,9 +26,9 @@ def to_code(config):
|
|||
rhs = CustomSwitchConstructor(template_)
|
||||
custom = variable(config[CONF_ID], rhs)
|
||||
for i, conf in enumerate(config[CONF_SWITCHES]):
|
||||
var = Pvariable(conf[CONF_ID], custom.get_switch(i))
|
||||
add(var.set_name(conf[CONF_NAME]))
|
||||
switch.setup_switch(var, conf)
|
||||
rhs = custom.Pget_switch(i)
|
||||
add(rhs.set_name(conf[CONF_NAME]))
|
||||
switch.register_switch(rhs, conf)
|
||||
|
||||
|
||||
BUILD_FLAGS = '-DUSE_CUSTOM_SWITCH'
|
||||
|
|
|
@ -3,7 +3,7 @@ import voluptuous as vol
|
|||
from esphome.components import text_sensor
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import CONF_ID, CONF_LAMBDA, CONF_NAME, CONF_TEXT_SENSORS
|
||||
from esphome.cpp_generator import Pvariable, add, process_lambda, variable
|
||||
from esphome.cpp_generator import add, process_lambda, variable
|
||||
from esphome.cpp_types import std_vector
|
||||
|
||||
CustomTextSensorConstructor = text_sensor.text_sensor_ns.class_('CustomTextSensorConstructor')
|
||||
|
@ -26,9 +26,9 @@ def to_code(config):
|
|||
rhs = CustomTextSensorConstructor(template_)
|
||||
custom = variable(config[CONF_ID], rhs)
|
||||
for i, conf in enumerate(config[CONF_TEXT_SENSORS]):
|
||||
var = Pvariable(conf[CONF_ID], custom.get_text_sensor(i))
|
||||
add(var.set_name(conf[CONF_NAME]))
|
||||
text_sensor.setup_text_sensor(var, conf)
|
||||
rhs = custom.Pget_text_sensor(i)
|
||||
add(rhs.set_name(conf[CONF_NAME]))
|
||||
text_sensor.register_text_sensor(rhs, conf)
|
||||
|
||||
|
||||
BUILD_FLAGS = '-DUSE_CUSTOM_TEXT_SENSOR'
|
||||
|
|
Loading…
Reference in a new issue