diff --git a/esphome/components/binary_sensor/custom.py b/esphome/components/binary_sensor/custom.py index 497aa7fc7d..a2b907aaed 100644 --- a/esphome/components/binary_sensor/custom.py +++ b/esphome/components/binary_sensor/custom.py @@ -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' diff --git a/esphome/components/sensor/custom.py b/esphome/components/sensor/custom.py index 314dbe51e8..3e73ef3581 100644 --- a/esphome/components/sensor/custom.py +++ b/esphome/components/sensor/custom.py @@ -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' diff --git a/esphome/components/switch/custom.py b/esphome/components/switch/custom.py index 5b2fc9e6cc..1b165f2b18 100644 --- a/esphome/components/switch/custom.py +++ b/esphome/components/switch/custom.py @@ -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' diff --git a/esphome/components/text_sensor/custom.py b/esphome/components/text_sensor/custom.py index 1fe2a889a9..342c08d8fb 100644 --- a/esphome/components/text_sensor/custom.py +++ b/esphome/components/text_sensor/custom.py @@ -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'