Skip to content
This repository has been archived by the owner on Sep 27, 2023. It is now read-only.

Commit

Permalink
Add empty nameable constructors (#509)
Browse files Browse the repository at this point in the history
  • Loading branch information
OttoWinter committed Feb 20, 2019
1 parent 2613ec3 commit 6772e38
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
6 changes: 2 additions & 4 deletions src/esphome/switch_/switch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ static const char *TAG = "switch";
std::string Switch::icon() {
return "";
}
Switch::Switch(const std::string &name)
: Nameable(name), state(false) {

}
Switch::Switch(const std::string &name) : Nameable(name), state(false) {}
Switch::Switch() : Switch("") {}

std::string Switch::get_icon() {
if (this->icon_.has_value())
Expand Down
1 change: 1 addition & 0 deletions src/esphome/switch_/switch.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class MQTTSwitchComponent;
*/
class Switch : public Nameable {
public:
explicit Switch();
explicit Switch(const std::string &name);

/** Publish a state to the front-end from the back-end.
Expand Down
3 changes: 3 additions & 0 deletions src/esphome/text_sensor/text_sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ namespace text_sensor {

static const char *TAG = "text_sensor.text_sensor";

TextSensor::TextSensor() : TextSensor("") {}
TextSensor::TextSensor(const std::string &name) : Nameable(name) {}

void TextSensor::publish_state(std::string state) {
this->state = state;
this->has_state_ = true;
Expand Down
3 changes: 2 additions & 1 deletion src/esphome/text_sensor/text_sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ class MQTTTextSensor;

class TextSensor : public Nameable {
public:
explicit TextSensor(const std::string &name) : Nameable(name) {}
explicit TextSensor();
explicit TextSensor(const std::string &name);

void publish_state(std::string state);

Expand Down

0 comments on commit 6772e38

Please sign in to comment.