From ffa19426d79b92f2e16f4c5a71eb25481d0d4a61 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Thu, 17 Feb 2022 16:56:44 +1300 Subject: [PATCH] Remove redundant name from binary_sensor constructor (#3213) --- esphome/components/binary_sensor/__init__.py | 3 +-- esphome/components/binary_sensor/binary_sensor.cpp | 3 +-- esphome/components/binary_sensor/binary_sensor.h | 5 ----- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/esphome/components/binary_sensor/__init__.py b/esphome/components/binary_sensor/__init__.py index 1eab76d54e..c6065ddae4 100644 --- a/esphome/components/binary_sensor/__init__.py +++ b/esphome/components/binary_sensor/__init__.py @@ -22,7 +22,6 @@ from esphome.const import ( CONF_STATE, CONF_TIMING, CONF_TRIGGER_ID, - CONF_NAME, CONF_MQTT_ID, DEVICE_CLASS_EMPTY, DEVICE_CLASS_BATTERY, @@ -443,7 +442,7 @@ async def register_binary_sensor(var, config): async def new_binary_sensor(config): - var = cg.new_Pvariable(config[CONF_ID], config[CONF_NAME]) + var = cg.new_Pvariable(config[CONF_ID]) await register_binary_sensor(var, config) return var diff --git a/esphome/components/binary_sensor/binary_sensor.cpp b/esphome/components/binary_sensor/binary_sensor.cpp index 71422609d7..02735feaae 100644 --- a/esphome/components/binary_sensor/binary_sensor.cpp +++ b/esphome/components/binary_sensor/binary_sensor.cpp @@ -42,8 +42,7 @@ void BinarySensor::send_state_internal(bool state, bool is_initial) { } } std::string BinarySensor::device_class() { return ""; } -BinarySensor::BinarySensor(const std::string &name) : EntityBase(name), state(false) {} -BinarySensor::BinarySensor() : BinarySensor("") {} +BinarySensor::BinarySensor() : state(false) {} void BinarySensor::set_device_class(const std::string &device_class) { this->device_class_ = device_class; } std::string BinarySensor::get_device_class() { if (this->device_class_.has_value()) diff --git a/esphome/components/binary_sensor/binary_sensor.h b/esphome/components/binary_sensor/binary_sensor.h index 591f444387..b5d1244bce 100644 --- a/esphome/components/binary_sensor/binary_sensor.h +++ b/esphome/components/binary_sensor/binary_sensor.h @@ -26,11 +26,6 @@ namespace binary_sensor { class BinarySensor : public EntityBase { public: explicit BinarySensor(); - /** Construct a binary sensor with the specified name - * - * @param name Name of this binary sensor. - */ - explicit BinarySensor(const std::string &name); /** Add a callback to be notified of state changes. *