revert
This commit is contained in:
@@ -13,8 +13,6 @@ static const char *const TAG = "alarm_control_panel";
|
||||
|
||||
AlarmControlPanelCall AlarmControlPanel::make_call() { return AlarmControlPanelCall(this); }
|
||||
|
||||
const char *AlarmControlPanel::get_component_type() const { return "alarm_control_panel"; }
|
||||
|
||||
bool AlarmControlPanel::is_state_armed(AlarmControlPanelState state) {
|
||||
switch (state) {
|
||||
case ACP_STATE_ARMED_AWAY:
|
||||
|
||||
@@ -29,8 +29,6 @@ class AlarmControlPanel : public EntityBase {
|
||||
*/
|
||||
AlarmControlPanelCall make_call();
|
||||
|
||||
const char *get_component_type() const override;
|
||||
|
||||
/** Set the state of the alarm_control_panel.
|
||||
*
|
||||
* @param state The AlarmControlPanelState.
|
||||
|
||||
@@ -289,7 +289,8 @@ bool APIConnection::try_send_binary_sensor_info_(binary_sensor::BinarySensor *bi
|
||||
ListEntitiesBinarySensorResponse msg;
|
||||
msg.device_class = binary_sensor->get_device_class();
|
||||
msg.is_status_binary_sensor = binary_sensor->is_status_binary_sensor();
|
||||
return this->try_send_entity_info_(binary_sensor, msg, &APIConnection::send_list_entities_binary_sensor_response);
|
||||
return this->try_send_entity_info_(binary_sensor, msg, "binary_sensor",
|
||||
&APIConnection::send_list_entities_binary_sensor_response);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -320,7 +321,7 @@ bool APIConnection::try_send_cover_info_(cover::Cover *cover) {
|
||||
msg.supports_tilt = traits.get_supports_tilt();
|
||||
msg.supports_stop = traits.get_supports_stop();
|
||||
msg.device_class = cover->get_device_class();
|
||||
return this->try_send_entity_info_(cover, msg, &APIConnection::send_list_entities_cover_response);
|
||||
return this->try_send_entity_info_(cover, msg, "cover", &APIConnection::send_list_entities_cover_response);
|
||||
}
|
||||
void APIConnection::cover_command(const CoverCommandRequest &msg) {
|
||||
cover::Cover *cover = App.get_cover_by_key(msg.key);
|
||||
@@ -381,7 +382,7 @@ bool APIConnection::try_send_fan_info_(fan::Fan *fan) {
|
||||
msg.supported_speed_count = traits.supported_speed_count();
|
||||
for (auto const &preset : traits.supported_preset_modes())
|
||||
msg.supported_preset_modes.push_back(preset);
|
||||
return this->try_send_entity_info_(fan, msg, &APIConnection::send_list_entities_fan_response);
|
||||
return this->try_send_entity_info_(fan, msg, "fan", &APIConnection::send_list_entities_fan_response);
|
||||
}
|
||||
void APIConnection::fan_command(const FanCommandRequest &msg) {
|
||||
fan::Fan *fan = App.get_fan_by_key(msg.key);
|
||||
@@ -455,7 +456,7 @@ bool APIConnection::try_send_light_info_(light::LightState *light) {
|
||||
msg.effects.push_back(effect->get_name());
|
||||
}
|
||||
}
|
||||
return this->try_send_entity_info_(light, msg, &APIConnection::send_list_entities_light_response);
|
||||
return this->try_send_entity_info_(light, msg, "light", &APIConnection::send_list_entities_light_response);
|
||||
}
|
||||
void APIConnection::light_command(const LightCommandRequest &msg) {
|
||||
light::LightState *light = App.get_light_by_key(msg.key);
|
||||
@@ -520,7 +521,7 @@ bool APIConnection::try_send_sensor_info_(sensor::Sensor *sensor) {
|
||||
msg.force_update = sensor->get_force_update();
|
||||
msg.device_class = sensor->get_device_class();
|
||||
msg.state_class = static_cast<enums::SensorStateClass>(sensor->get_state_class());
|
||||
return this->try_send_entity_info_(sensor, msg, &APIConnection::send_list_entities_sensor_response);
|
||||
return this->try_send_entity_info_(sensor, msg, "sensor", &APIConnection::send_list_entities_sensor_response);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -546,7 +547,7 @@ bool APIConnection::try_send_switch_info_(switch_::Switch *a_switch) {
|
||||
ListEntitiesSwitchResponse msg;
|
||||
msg.assumed_state = a_switch->assumed_state();
|
||||
msg.device_class = a_switch->get_device_class();
|
||||
return this->try_send_entity_info_(a_switch, msg, &APIConnection::send_list_entities_switch_response);
|
||||
return this->try_send_entity_info_(a_switch, msg, "switch", &APIConnection::send_list_entities_switch_response);
|
||||
}
|
||||
void APIConnection::switch_command(const SwitchCommandRequest &msg) {
|
||||
switch_::Switch *a_switch = App.get_switch_by_key(msg.key);
|
||||
@@ -583,7 +584,8 @@ bool APIConnection::try_send_text_sensor_state_(text_sensor::TextSensor *text_se
|
||||
bool APIConnection::try_send_text_sensor_info_(text_sensor::TextSensor *text_sensor) {
|
||||
ListEntitiesTextSensorResponse msg;
|
||||
msg.device_class = text_sensor->get_device_class();
|
||||
return this->try_send_entity_info_(text_sensor, msg, &APIConnection::send_list_entities_text_sensor_response);
|
||||
return this->try_send_entity_info_(text_sensor, msg, "text_sensor",
|
||||
&APIConnection::send_list_entities_text_sensor_response);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -652,7 +654,7 @@ bool APIConnection::try_send_climate_info_(climate::Climate *climate) {
|
||||
msg.supported_custom_presets.push_back(custom_preset);
|
||||
for (auto swing_mode : traits.get_supported_swing_modes())
|
||||
msg.supported_swing_modes.push_back(static_cast<enums::ClimateSwingMode>(swing_mode));
|
||||
return this->try_send_entity_info_(climate, msg, &APIConnection::send_list_entities_climate_response);
|
||||
return this->try_send_entity_info_(climate, msg, "climate", &APIConnection::send_list_entities_climate_response);
|
||||
}
|
||||
void APIConnection::climate_command(const ClimateCommandRequest &msg) {
|
||||
climate::Climate *climate = App.get_climate_by_key(msg.key);
|
||||
@@ -711,7 +713,7 @@ bool APIConnection::try_send_number_info_(number::Number *number) {
|
||||
msg.min_value = number->traits.get_min_value();
|
||||
msg.max_value = number->traits.get_max_value();
|
||||
msg.step = number->traits.get_step();
|
||||
return this->try_send_entity_info_(number, msg, &APIConnection::send_list_entities_number_response);
|
||||
return this->try_send_entity_info_(number, msg, "number", &APIConnection::send_list_entities_number_response);
|
||||
}
|
||||
void APIConnection::number_command(const NumberCommandRequest &msg) {
|
||||
number::Number *number = App.get_number_by_key(msg.key);
|
||||
@@ -743,7 +745,7 @@ bool APIConnection::try_send_date_state_(datetime::DateEntity *date) {
|
||||
}
|
||||
bool APIConnection::try_send_date_info_(datetime::DateEntity *date) {
|
||||
ListEntitiesDateResponse msg;
|
||||
return this->try_send_entity_info_(date, msg, &APIConnection::send_list_entities_date_response);
|
||||
return this->try_send_entity_info_(date, msg, "date", &APIConnection::send_list_entities_date_response);
|
||||
}
|
||||
void APIConnection::date_command(const DateCommandRequest &msg) {
|
||||
datetime::DateEntity *date = App.get_date_by_key(msg.key);
|
||||
@@ -775,7 +777,7 @@ bool APIConnection::try_send_time_state_(datetime::TimeEntity *time) {
|
||||
}
|
||||
bool APIConnection::try_send_time_info_(datetime::TimeEntity *time) {
|
||||
ListEntitiesTimeResponse msg;
|
||||
return this->try_send_entity_info_(time, msg, &APIConnection::send_list_entities_time_response);
|
||||
return this->try_send_entity_info_(time, msg, "time", &APIConnection::send_list_entities_time_response);
|
||||
}
|
||||
void APIConnection::time_command(const TimeCommandRequest &msg) {
|
||||
datetime::TimeEntity *time = App.get_time_by_key(msg.key);
|
||||
@@ -808,7 +810,7 @@ bool APIConnection::try_send_datetime_state_(datetime::DateTimeEntity *datetime)
|
||||
}
|
||||
bool APIConnection::try_send_datetime_info_(datetime::DateTimeEntity *datetime) {
|
||||
ListEntitiesDateTimeResponse msg;
|
||||
return this->try_send_entity_info_(datetime, msg, &APIConnection::send_list_entities_date_time_response);
|
||||
return this->try_send_entity_info_(datetime, msg, "datetime", &APIConnection::send_list_entities_date_time_response);
|
||||
}
|
||||
void APIConnection::datetime_command(const DateTimeCommandRequest &msg) {
|
||||
datetime::DateTimeEntity *datetime = App.get_datetime_by_key(msg.key);
|
||||
@@ -842,7 +844,7 @@ bool APIConnection::try_send_text_info_(text::Text *text) {
|
||||
msg.min_length = text->traits.get_min_length();
|
||||
msg.max_length = text->traits.get_max_length();
|
||||
msg.pattern = text->traits.get_pattern();
|
||||
return this->try_send_entity_info_(text, msg, &APIConnection::send_list_entities_text_response);
|
||||
return this->try_send_entity_info_(text, msg, "text", &APIConnection::send_list_entities_text_response);
|
||||
}
|
||||
void APIConnection::text_command(const TextCommandRequest &msg) {
|
||||
text::Text *text = App.get_text_by_key(msg.key);
|
||||
@@ -878,7 +880,7 @@ bool APIConnection::try_send_select_info_(select::Select *select) {
|
||||
ListEntitiesSelectResponse msg;
|
||||
for (const auto &option : select->traits.get_options())
|
||||
msg.options.push_back(option);
|
||||
return this->try_send_entity_info_(select, msg, &APIConnection::send_list_entities_select_response);
|
||||
return this->try_send_entity_info_(select, msg, "select", &APIConnection::send_list_entities_select_response);
|
||||
}
|
||||
void APIConnection::select_command(const SelectCommandRequest &msg) {
|
||||
select::Select *select = App.get_select_by_key(msg.key);
|
||||
@@ -898,7 +900,7 @@ void esphome::api::APIConnection::send_button_info(button::Button *button) {
|
||||
bool esphome::api::APIConnection::try_send_button_info_(button::Button *button) {
|
||||
ListEntitiesButtonResponse msg;
|
||||
msg.device_class = button->get_device_class();
|
||||
return this->try_send_entity_info_(button, msg, &APIConnection::send_list_entities_button_response);
|
||||
return this->try_send_entity_info_(button, msg, "button", &APIConnection::send_list_entities_button_response);
|
||||
}
|
||||
void esphome::api::APIConnection::button_command(const ButtonCommandRequest &msg) {
|
||||
button::Button *button = App.get_button_by_key(msg.key);
|
||||
@@ -932,7 +934,7 @@ bool APIConnection::try_send_lock_info_(lock::Lock *a_lock) {
|
||||
msg.assumed_state = a_lock->traits.get_assumed_state();
|
||||
msg.supports_open = a_lock->traits.get_supports_open();
|
||||
msg.requires_code = a_lock->traits.get_requires_code();
|
||||
return this->try_send_entity_info_(a_lock, msg, &APIConnection::send_list_entities_lock_response);
|
||||
return this->try_send_entity_info_(a_lock, msg, "lock", &APIConnection::send_list_entities_lock_response);
|
||||
}
|
||||
void APIConnection::lock_command(const LockCommandRequest &msg) {
|
||||
lock::Lock *a_lock = App.get_lock_by_key(msg.key);
|
||||
@@ -975,7 +977,7 @@ bool APIConnection::try_send_valve_info_(valve::Valve *valve) {
|
||||
msg.assumed_state = traits.get_is_assumed_state();
|
||||
msg.supports_position = traits.get_supports_position();
|
||||
msg.supports_stop = traits.get_supports_stop();
|
||||
return this->try_send_entity_info_(valve, msg, &APIConnection::send_list_entities_valve_response);
|
||||
return this->try_send_entity_info_(valve, msg, "valve", &APIConnection::send_list_entities_valve_response);
|
||||
}
|
||||
void APIConnection::valve_command(const ValveCommandRequest &msg) {
|
||||
valve::Valve *valve = App.get_valve_by_key(msg.key);
|
||||
@@ -1023,7 +1025,8 @@ bool APIConnection::try_send_media_player_info_(media_player::MediaPlayer *media
|
||||
media_format.sample_bytes = supported_format.sample_bytes;
|
||||
msg.supported_formats.push_back(media_format);
|
||||
}
|
||||
return this->try_send_entity_info_(media_player, msg, &APIConnection::send_list_entities_media_player_response);
|
||||
return this->try_send_entity_info_(media_player, msg, "media_player",
|
||||
&APIConnection::send_list_entities_media_player_response);
|
||||
}
|
||||
void APIConnection::media_player_command(const MediaPlayerCommandRequest &msg) {
|
||||
media_player::MediaPlayer *media_player = App.get_media_player_by_key(msg.key);
|
||||
@@ -1062,7 +1065,7 @@ void APIConnection::send_camera_info(esp32_camera::ESP32Camera *camera) {
|
||||
}
|
||||
bool APIConnection::try_send_camera_info_(esp32_camera::ESP32Camera *camera) {
|
||||
ListEntitiesCameraResponse msg;
|
||||
return this->try_send_entity_info_(camera, msg, &APIConnection::send_list_entities_camera_response);
|
||||
return this->try_send_entity_info_(camera, msg, "camera", &APIConnection::send_list_entities_camera_response);
|
||||
}
|
||||
void APIConnection::camera_image(const CameraImageRequest &msg) {
|
||||
if (esp32_camera::global_esp32_camera == nullptr)
|
||||
@@ -1268,7 +1271,7 @@ bool APIConnection::try_send_alarm_control_panel_info_(alarm_control_panel::Alar
|
||||
msg.supported_features = a_alarm_control_panel->get_supported_features();
|
||||
msg.requires_code = a_alarm_control_panel->get_requires_code();
|
||||
msg.requires_code_to_arm = a_alarm_control_panel->get_requires_code_to_arm();
|
||||
return this->try_send_entity_info_(a_alarm_control_panel, msg,
|
||||
return this->try_send_entity_info_(a_alarm_control_panel, msg, "alarm_control_panel",
|
||||
&APIConnection::send_list_entities_alarm_control_panel_response);
|
||||
}
|
||||
void APIConnection::alarm_control_panel_command(const AlarmControlPanelCommandRequest &msg) {
|
||||
@@ -1328,7 +1331,7 @@ bool APIConnection::try_send_event_info_(event::Event *event) {
|
||||
msg.device_class = event->get_device_class();
|
||||
for (const auto &event_type : event->get_event_types())
|
||||
msg.event_types.push_back(event_type);
|
||||
return this->try_send_entity_info_(event, msg, &APIConnection::send_list_entities_event_response);
|
||||
return this->try_send_entity_info_(event, msg, "event", &APIConnection::send_list_entities_event_response);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1361,7 +1364,7 @@ bool APIConnection::try_send_update_state_(update::UpdateEntity *update) {
|
||||
bool APIConnection::try_send_update_info_(update::UpdateEntity *update) {
|
||||
ListEntitiesUpdateResponse msg;
|
||||
msg.device_class = update->get_device_class();
|
||||
return this->try_send_entity_info_(update, msg, &APIConnection::send_list_entities_update_response);
|
||||
return this->try_send_entity_info_(update, msg, "update", &APIConnection::send_list_entities_update_response);
|
||||
}
|
||||
void APIConnection::update_command(const UpdateCommandRequest &msg) {
|
||||
update::UpdateEntity *update = App.get_update_by_key(msg.key);
|
||||
|
||||
@@ -497,7 +497,7 @@ class APIConnection : public APIServerConnection {
|
||||
* @return True if the message was sent successfully
|
||||
*/
|
||||
template<typename EntityT, typename ResponseT>
|
||||
bool try_send_entity_info_(EntityT *entity, ResponseT &response,
|
||||
bool try_send_entity_info_(EntityT *entity, ResponseT &response, const char *component_type,
|
||||
bool (APIServerConnectionBase::*send_response_func)(const ResponseT &)) {
|
||||
// Set common fields that are shared by all entity types
|
||||
response.key = entity->get_object_id_hash();
|
||||
@@ -511,7 +511,7 @@ class APIConnection : public APIServerConnection {
|
||||
response.unique_id = entity->unique_id();
|
||||
// Fall back to default if empty
|
||||
if (response.unique_id.empty())
|
||||
response.unique_id = get_default_unique_id(entity->get_component_type(), entity);
|
||||
response.unique_id = get_default_unique_id(component_type, entity);
|
||||
|
||||
// Set common EntityBase properties
|
||||
response.icon = entity->get_icon();
|
||||
|
||||
@@ -59,8 +59,6 @@ void BinarySensor::add_filters(const std::vector<Filter *> &filters) {
|
||||
bool BinarySensor::has_state() const { return this->has_state_; }
|
||||
bool BinarySensor::is_status_binary_sensor() const { return false; }
|
||||
|
||||
const char *BinarySensor::get_component_type() const { return "binary_sensor"; }
|
||||
|
||||
} // namespace binary_sensor
|
||||
|
||||
} // namespace esphome
|
||||
|
||||
@@ -74,9 +74,6 @@ class BinarySensor : public EntityBase, public EntityBase_DeviceClass {
|
||||
|
||||
virtual bool is_status_binary_sensor() const;
|
||||
|
||||
// Get the component type for this entity
|
||||
const char *get_component_type() const override;
|
||||
|
||||
protected:
|
||||
CallbackManager<void(bool)> state_callback_{};
|
||||
Filter *filter_list_{nullptr};
|
||||
|
||||
@@ -13,7 +13,5 @@ void Button::press() {
|
||||
}
|
||||
void Button::add_on_press_callback(std::function<void()> &&callback) { this->press_callback_.add(std::move(callback)); }
|
||||
|
||||
const char *Button::get_component_type() const { return "button"; }
|
||||
|
||||
} // namespace button
|
||||
} // namespace esphome
|
||||
|
||||
@@ -40,8 +40,6 @@ class Button : public EntityBase, public EntityBase_DeviceClass {
|
||||
*/
|
||||
void add_on_press_callback(std::function<void()> &&callback);
|
||||
|
||||
const char *get_component_type() const override;
|
||||
|
||||
protected:
|
||||
/** You should implement this virtual method if you want to create your own button.
|
||||
*/
|
||||
|
||||
@@ -566,8 +566,6 @@ bool Climate::set_custom_preset_(const std::string &preset) {
|
||||
return set_alternative(this->custom_preset, this->preset, preset);
|
||||
}
|
||||
|
||||
const char *Climate::get_component_type() const { return "climate"; }
|
||||
|
||||
void Climate::dump_traits_(const char *tag) {
|
||||
auto traits = this->get_traits();
|
||||
ESP_LOGCONFIG(tag, "ClimateTraits:");
|
||||
|
||||
@@ -169,8 +169,6 @@ class Climate : public EntityBase {
|
||||
public:
|
||||
Climate() {}
|
||||
|
||||
const char *get_component_type() const override;
|
||||
|
||||
/// The active mode of the climate device.
|
||||
ClimateMode mode{CLIMATE_MODE_OFF};
|
||||
|
||||
|
||||
@@ -207,7 +207,6 @@ optional<CoverRestoreState> Cover::restore_state_() {
|
||||
|
||||
bool Cover::is_fully_open() const { return this->position == COVER_OPEN; }
|
||||
bool Cover::is_fully_closed() const { return this->position == COVER_CLOSED; }
|
||||
const char *Cover::get_component_type() const { return "cover"; }
|
||||
|
||||
CoverCall CoverRestoreState::to_call(Cover *cover) {
|
||||
auto call = cover->make_call();
|
||||
|
||||
@@ -164,7 +164,6 @@ class Cover : public EntityBase, public EntityBase_DeviceClass {
|
||||
bool is_fully_closed() const;
|
||||
|
||||
// Get the component type for this entity
|
||||
const char *get_component_type() const override;
|
||||
|
||||
protected:
|
||||
friend CoverCall;
|
||||
|
||||
@@ -43,8 +43,6 @@ class DateEntity : public DateTimeBase {
|
||||
void publish_state();
|
||||
DateCall make_call();
|
||||
|
||||
const char *get_component_type() const override { return "date"; }
|
||||
|
||||
ESPTime state_as_esptime() const override {
|
||||
ESPTime obj;
|
||||
obj.year = this->year_;
|
||||
|
||||
@@ -20,8 +20,6 @@ class DateTimeBase : public EntityBase {
|
||||
|
||||
void add_on_state_callback(std::function<void()> &&callback) { this->state_callback_.add(std::move(callback)); }
|
||||
|
||||
const char *get_component_type() const override = 0;
|
||||
|
||||
#ifdef USE_TIME
|
||||
void set_rtc(time::RealTimeClock *rtc) { this->rtc_ = rtc; }
|
||||
time::RealTimeClock *get_rtc() const { return this->rtc_; }
|
||||
|
||||
@@ -49,8 +49,6 @@ class DateTimeEntity : public DateTimeBase {
|
||||
void publish_state();
|
||||
DateTimeCall make_call();
|
||||
|
||||
const char *get_component_type() const override { return "datetime"; }
|
||||
|
||||
ESPTime state_as_esptime() const override;
|
||||
|
||||
const uint16_t &year = year_;
|
||||
|
||||
@@ -44,8 +44,6 @@ class TimeEntity : public DateTimeBase {
|
||||
void publish_state();
|
||||
TimeCall make_call();
|
||||
|
||||
const char *get_component_type() const override { return "time"; }
|
||||
|
||||
ESPTime state_as_esptime() const override {
|
||||
ESPTime obj;
|
||||
obj.hour = this->hour_;
|
||||
|
||||
@@ -22,7 +22,5 @@ void Event::add_on_event_callback(std::function<void(const std::string &event_ty
|
||||
this->event_callback_.add(std::move(callback));
|
||||
}
|
||||
|
||||
const char *Event::get_component_type() const { return "event"; }
|
||||
|
||||
} // namespace event
|
||||
} // namespace esphome
|
||||
|
||||
@@ -30,8 +30,6 @@ class Event : public EntityBase, public EntityBase_DeviceClass {
|
||||
std::set<std::string> get_event_types() const { return this->types_; }
|
||||
void add_on_event_callback(std::function<void(const std::string &event_type)> &&callback);
|
||||
|
||||
const char *get_component_type() const override;
|
||||
|
||||
protected:
|
||||
CallbackManager<void(const std::string &event_type)> event_callback_;
|
||||
std::set<std::string> types_;
|
||||
|
||||
@@ -205,7 +205,5 @@ void Fan::dump_traits_(const char *tag, const char *prefix) {
|
||||
}
|
||||
}
|
||||
|
||||
const char *Fan::get_component_type() const { return "fan"; }
|
||||
|
||||
} // namespace fan
|
||||
} // namespace esphome
|
||||
|
||||
@@ -133,7 +133,6 @@ class Fan : public EntityBase {
|
||||
void set_restore_mode(FanRestoreMode restore_mode) { this->restore_mode_ = restore_mode; }
|
||||
|
||||
// Get the component type for this entity
|
||||
const char *get_component_type() const override;
|
||||
|
||||
protected:
|
||||
friend FanCall;
|
||||
|
||||
@@ -11,8 +11,6 @@ static const char *const TAG = "light";
|
||||
|
||||
LightState::LightState(LightOutput *output) : output_(output) {}
|
||||
|
||||
const char *LightState::get_component_type() const { return "light"; }
|
||||
|
||||
LightTraits LightState::get_traits() { return this->output_->get_traits(); }
|
||||
LightCall LightState::turn_on() { return this->make_call().set_state(true); }
|
||||
LightCall LightState::turn_off() { return this->make_call().set_state(false); }
|
||||
|
||||
@@ -64,8 +64,6 @@ class LightState : public EntityBase, public Component {
|
||||
public:
|
||||
LightState(LightOutput *output);
|
||||
|
||||
const char *get_component_type() const override;
|
||||
|
||||
LightTraits get_traits();
|
||||
|
||||
/// Make a light state call
|
||||
|
||||
@@ -57,8 +57,6 @@ void Lock::publish_state(LockState state) {
|
||||
|
||||
void Lock::add_on_state_callback(std::function<void()> &&callback) { this->state_callback_.add(std::move(callback)); }
|
||||
|
||||
const char *Lock::get_component_type() const { return "lock"; }
|
||||
|
||||
void LockCall::perform() {
|
||||
ESP_LOGD(TAG, "'%s' - Setting", this->parent_->get_name().c_str());
|
||||
this->validate_();
|
||||
|
||||
@@ -145,8 +145,6 @@ class Lock : public EntityBase {
|
||||
*/
|
||||
void add_on_state_callback(std::function<void()> &&callback);
|
||||
|
||||
const char *get_component_type() const override;
|
||||
|
||||
protected:
|
||||
friend LockCall;
|
||||
|
||||
|
||||
@@ -137,7 +137,5 @@ void MediaPlayer::add_on_state_callback(std::function<void()> &&callback) {
|
||||
|
||||
void MediaPlayer::publish_state() { this->state_callback_.call(); }
|
||||
|
||||
const char *MediaPlayer::get_component_type() const { return "media_player"; }
|
||||
|
||||
} // namespace media_player
|
||||
} // namespace esphome
|
||||
|
||||
@@ -105,8 +105,6 @@ class MediaPlayer : public EntityBase {
|
||||
|
||||
virtual MediaPlayerTraits get_traits() = 0;
|
||||
|
||||
const char *get_component_type() const override;
|
||||
|
||||
protected:
|
||||
friend MediaPlayerCall;
|
||||
|
||||
|
||||
@@ -17,7 +17,5 @@ void Number::add_on_state_callback(std::function<void(float)> &&callback) {
|
||||
this->state_callback_.add(std::move(callback));
|
||||
}
|
||||
|
||||
const char *Number::get_component_type() const { return "number"; }
|
||||
|
||||
} // namespace number
|
||||
} // namespace esphome
|
||||
|
||||
@@ -51,8 +51,6 @@ class Number : public EntityBase {
|
||||
/// Return whether this number has gotten a full state yet.
|
||||
bool has_state() const { return has_state_; }
|
||||
|
||||
const char *get_component_type() const override;
|
||||
|
||||
protected:
|
||||
friend class NumberCall;
|
||||
|
||||
|
||||
@@ -58,7 +58,5 @@ optional<std::string> Select::at(size_t index) const {
|
||||
}
|
||||
}
|
||||
|
||||
const char *Select::get_component_type() const { return "select"; }
|
||||
|
||||
} // namespace select
|
||||
} // namespace esphome
|
||||
|
||||
@@ -61,8 +61,6 @@ class Select : public EntityBase {
|
||||
|
||||
void add_on_state_callback(std::function<void(std::string, size_t)> &&callback);
|
||||
|
||||
const char *get_component_type() const override;
|
||||
|
||||
protected:
|
||||
friend class SelectCall;
|
||||
|
||||
|
||||
@@ -86,7 +86,6 @@ void Sensor::clear_filters() {
|
||||
float Sensor::get_state() const { return this->state; }
|
||||
float Sensor::get_raw_state() const { return this->raw_state; }
|
||||
std::string Sensor::unique_id() { return ""; }
|
||||
const char *Sensor::get_component_type() const { return "sensor"; }
|
||||
|
||||
void Sensor::internal_send_state_to_frontend(float state) {
|
||||
this->has_state_ = true;
|
||||
|
||||
@@ -146,7 +146,6 @@ class Sensor : public EntityBase, public EntityBase_DeviceClass, public EntityBa
|
||||
std::string unique_id() override;
|
||||
|
||||
// Get the component type for this entity
|
||||
const char *get_component_type() const override;
|
||||
|
||||
void internal_send_state_to_frontend(float state);
|
||||
|
||||
|
||||
@@ -62,7 +62,6 @@ void Switch::add_on_state_callback(std::function<void(bool)> &&callback) {
|
||||
}
|
||||
void Switch::set_inverted(bool inverted) { this->inverted_ = inverted; }
|
||||
bool Switch::is_inverted() const { return this->inverted_; }
|
||||
const char *Switch::get_component_type() const { return "switch"; }
|
||||
|
||||
void log_switch(const char *tag, const char *prefix, const char *type, Switch *obj) {
|
||||
if (obj != nullptr) {
|
||||
|
||||
@@ -113,7 +113,6 @@ class Switch : public EntityBase, public EntityBase_DeviceClass {
|
||||
void set_restore_mode(SwitchRestoreMode restore_mode) { this->restore_mode = restore_mode; }
|
||||
|
||||
// Get the component type for this entity
|
||||
const char *get_component_type() const override;
|
||||
|
||||
protected:
|
||||
/** Write the given state to hardware. You should implement this
|
||||
|
||||
@@ -22,7 +22,5 @@ void Text::add_on_state_callback(std::function<void(std::string)> &&callback) {
|
||||
this->state_callback_.add(std::move(callback));
|
||||
}
|
||||
|
||||
const char *Text::get_component_type() const { return "text"; }
|
||||
|
||||
} // namespace text
|
||||
} // namespace esphome
|
||||
|
||||
@@ -36,8 +36,6 @@ class Text : public EntityBase {
|
||||
|
||||
void add_on_state_callback(std::function<void(std::string)> &&callback);
|
||||
|
||||
const char *get_component_type() const override;
|
||||
|
||||
protected:
|
||||
friend class TextCall;
|
||||
|
||||
|
||||
@@ -67,7 +67,6 @@ void TextSensor::internal_send_state_to_frontend(const std::string &state) {
|
||||
|
||||
std::string TextSensor::unique_id() { return ""; }
|
||||
bool TextSensor::has_state() { return this->has_state_; }
|
||||
const char *TextSensor::get_component_type() const { return "text_sensor"; }
|
||||
|
||||
} // namespace text_sensor
|
||||
} // namespace esphome
|
||||
|
||||
@@ -72,7 +72,6 @@ class TextSensor : public EntityBase, public EntityBase_DeviceClass {
|
||||
void internal_send_state_to_frontend(const std::string &state);
|
||||
|
||||
// Get the component type for this entity
|
||||
const char *get_component_type() const override;
|
||||
|
||||
protected:
|
||||
CallbackManager<void(std::string)> raw_callback_; ///< Storage for raw state callbacks.
|
||||
|
||||
@@ -34,7 +34,5 @@ void UpdateEntity::publish_state() {
|
||||
this->state_callback_.call();
|
||||
}
|
||||
|
||||
const char *UpdateEntity::get_component_type() const { return "update"; }
|
||||
|
||||
} // namespace update
|
||||
} // namespace esphome
|
||||
|
||||
@@ -41,8 +41,6 @@ class UpdateEntity : public EntityBase, public EntityBase_DeviceClass {
|
||||
|
||||
void add_on_state_callback(std::function<void()> &&callback) { this->state_callback_.add(std::move(callback)); }
|
||||
|
||||
const char *get_component_type() const override;
|
||||
|
||||
protected:
|
||||
UpdateState state_{UPDATE_STATE_UNKNOWN};
|
||||
UpdateInfo update_info_;
|
||||
|
||||
@@ -165,8 +165,6 @@ optional<ValveRestoreState> Valve::restore_state_() {
|
||||
bool Valve::is_fully_open() const { return this->position == VALVE_OPEN; }
|
||||
bool Valve::is_fully_closed() const { return this->position == VALVE_CLOSED; }
|
||||
|
||||
const char *Valve::get_component_type() const { return "valve"; }
|
||||
|
||||
ValveCall ValveRestoreState::to_call(Valve *valve) {
|
||||
auto call = valve->make_call();
|
||||
call.set_position(this->position);
|
||||
|
||||
@@ -136,8 +136,6 @@ class Valve : public EntityBase, public EntityBase_DeviceClass {
|
||||
/// Helper method to check if the valve is fully closed. Equivalent to comparing .position against 0.0
|
||||
bool is_fully_closed() const;
|
||||
|
||||
const char *get_component_type() const override;
|
||||
|
||||
protected:
|
||||
friend ValveCall;
|
||||
|
||||
|
||||
@@ -33,10 +33,6 @@ class EntityBase {
|
||||
// that need custom unique IDs
|
||||
virtual std::string unique_id() { return ""; }
|
||||
|
||||
// Get the component type for this entity, must be overridden by entities
|
||||
// Returns a static string stored in flash memory
|
||||
virtual const char *get_component_type() const = 0;
|
||||
|
||||
// Get/set whether this Entity should be hidden from outside of ESPHome
|
||||
bool is_internal() const;
|
||||
void set_internal(bool internal);
|
||||
|
||||
Reference in New Issue
Block a user