Fix custom components not registered (#441)

This commit is contained in:
Otto Winter 2019-02-18 14:59:35 +01:00
parent efe81e0856
commit fe54700687
No known key found for this signature in database
GPG key ID: DB66C0BE6013F97E
4 changed files with 16 additions and 16 deletions

View file

@ -3,7 +3,7 @@ import voluptuous as vol
from esphome.components import binary_sensor from esphome.components import binary_sensor
import esphome.config_validation as cv import esphome.config_validation as cv
from esphome.const import CONF_BINARY_SENSORS, CONF_ID, CONF_LAMBDA, CONF_NAME 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 from esphome.cpp_types import std_vector
CustomBinarySensorConstructor = binary_sensor.binary_sensor_ns.class_( CustomBinarySensorConstructor = binary_sensor.binary_sensor_ns.class_(
@ -27,9 +27,9 @@ def to_code(config):
rhs = CustomBinarySensorConstructor(template_) rhs = CustomBinarySensorConstructor(template_)
custom = variable(config[CONF_ID], rhs) custom = variable(config[CONF_ID], rhs)
for i, conf in enumerate(config[CONF_BINARY_SENSORS]): for i, conf in enumerate(config[CONF_BINARY_SENSORS]):
var = Pvariable(conf[CONF_ID], custom.get_binary_sensor(i)) rhs = custom.Pget_binary_sensor(i)
add(var.set_name(conf[CONF_NAME])) add(rhs.set_name(conf[CONF_NAME]))
binary_sensor.setup_binary_sensor(var, conf) binary_sensor.register_binary_sensor(rhs, conf)
BUILD_FLAGS = '-DUSE_CUSTOM_BINARY_SENSOR' BUILD_FLAGS = '-DUSE_CUSTOM_BINARY_SENSOR'

View file

@ -3,7 +3,7 @@ import voluptuous as vol
from esphome.components import sensor from esphome.components import sensor
import esphome.config_validation as cv import esphome.config_validation as cv
from esphome.const import CONF_ID, CONF_LAMBDA, CONF_NAME, CONF_SENSORS 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 from esphome.cpp_types import std_vector
CustomSensorConstructor = sensor.sensor_ns.class_('CustomSensorConstructor') CustomSensorConstructor = sensor.sensor_ns.class_('CustomSensorConstructor')
@ -25,9 +25,9 @@ def to_code(config):
rhs = CustomSensorConstructor(template_) rhs = CustomSensorConstructor(template_)
custom = variable(config[CONF_ID], rhs) custom = variable(config[CONF_ID], rhs)
for i, conf in enumerate(config[CONF_SENSORS]): for i, conf in enumerate(config[CONF_SENSORS]):
var = Pvariable(conf[CONF_ID], custom.get_sensor(i)) rhs = custom.Pget_sensor(i)
add(var.set_name(conf[CONF_NAME])) add(rhs.set_name(conf[CONF_NAME]))
sensor.setup_sensor(var, conf) sensor.register_sensor(rhs, conf)
BUILD_FLAGS = '-DUSE_CUSTOM_SENSOR' BUILD_FLAGS = '-DUSE_CUSTOM_SENSOR'

View file

@ -3,7 +3,7 @@ import voluptuous as vol
from esphome.components import switch from esphome.components import switch
import esphome.config_validation as cv import esphome.config_validation as cv
from esphome.const import CONF_ID, CONF_LAMBDA, CONF_NAME, CONF_SWITCHES 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 from esphome.cpp_types import std_vector
CustomSwitchConstructor = switch.switch_ns.class_('CustomSwitchConstructor') CustomSwitchConstructor = switch.switch_ns.class_('CustomSwitchConstructor')
@ -26,9 +26,9 @@ def to_code(config):
rhs = CustomSwitchConstructor(template_) rhs = CustomSwitchConstructor(template_)
custom = variable(config[CONF_ID], rhs) custom = variable(config[CONF_ID], rhs)
for i, conf in enumerate(config[CONF_SWITCHES]): for i, conf in enumerate(config[CONF_SWITCHES]):
var = Pvariable(conf[CONF_ID], custom.get_switch(i)) rhs = custom.Pget_switch(i)
add(var.set_name(conf[CONF_NAME])) add(rhs.set_name(conf[CONF_NAME]))
switch.setup_switch(var, conf) switch.register_switch(rhs, conf)
BUILD_FLAGS = '-DUSE_CUSTOM_SWITCH' BUILD_FLAGS = '-DUSE_CUSTOM_SWITCH'

View file

@ -3,7 +3,7 @@ import voluptuous as vol
from esphome.components import text_sensor from esphome.components import text_sensor
import esphome.config_validation as cv import esphome.config_validation as cv
from esphome.const import CONF_ID, CONF_LAMBDA, CONF_NAME, CONF_TEXT_SENSORS 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 from esphome.cpp_types import std_vector
CustomTextSensorConstructor = text_sensor.text_sensor_ns.class_('CustomTextSensorConstructor') CustomTextSensorConstructor = text_sensor.text_sensor_ns.class_('CustomTextSensorConstructor')
@ -26,9 +26,9 @@ def to_code(config):
rhs = CustomTextSensorConstructor(template_) rhs = CustomTextSensorConstructor(template_)
custom = variable(config[CONF_ID], rhs) custom = variable(config[CONF_ID], rhs)
for i, conf in enumerate(config[CONF_TEXT_SENSORS]): for i, conf in enumerate(config[CONF_TEXT_SENSORS]):
var = Pvariable(conf[CONF_ID], custom.get_text_sensor(i)) rhs = custom.Pget_text_sensor(i)
add(var.set_name(conf[CONF_NAME])) add(rhs.set_name(conf[CONF_NAME]))
text_sensor.setup_text_sensor(var, conf) text_sensor.register_text_sensor(rhs, conf)
BUILD_FLAGS = '-DUSE_CUSTOM_TEXT_SENSOR' BUILD_FLAGS = '-DUSE_CUSTOM_TEXT_SENSOR'