mirror of
https://github.com/esphome/esphome.git
synced 2025-10-06 20:03:46 +01:00
Remove deprecated fan speeds (#3397)
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
|
||||
#ifdef USE_MQTT
|
||||
#ifdef USE_FAN
|
||||
#include "esphome/components/fan/fan_helpers.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace mqtt {
|
||||
@@ -88,17 +87,6 @@ void MQTTFanComponent::setup() {
|
||||
});
|
||||
}
|
||||
|
||||
if (this->state_->get_traits().supports_speed()) {
|
||||
this->subscribe(this->get_speed_command_topic(), [this](const std::string &topic, const std::string &payload) {
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
this->state_->make_call()
|
||||
.set_speed(payload.c_str()) // NOLINT(clang-diagnostic-deprecated-declarations)
|
||||
.perform();
|
||||
#pragma GCC diagnostic pop
|
||||
});
|
||||
}
|
||||
|
||||
auto f = std::bind(&MQTTFanComponent::publish_state, this);
|
||||
this->state_->add_on_state_callback([this, f]() { this->defer("send", f); });
|
||||
}
|
||||
@@ -113,8 +101,6 @@ void MQTTFanComponent::dump_config() {
|
||||
if (this->state_->get_traits().supports_speed()) {
|
||||
ESP_LOGCONFIG(TAG, " Speed Level State Topic: '%s'", this->get_speed_level_state_topic().c_str());
|
||||
ESP_LOGCONFIG(TAG, " Speed Level Command Topic: '%s'", this->get_speed_level_command_topic().c_str());
|
||||
ESP_LOGCONFIG(TAG, " Speed State Topic: '%s'", this->get_speed_state_topic().c_str());
|
||||
ESP_LOGCONFIG(TAG, " Speed Command Topic: '%s'", this->get_speed_command_topic().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,10 +112,8 @@ void MQTTFanComponent::send_discovery(JsonObject root, mqtt::SendDiscoveryConfig
|
||||
root[MQTT_OSCILLATION_STATE_TOPIC] = this->get_oscillation_state_topic();
|
||||
}
|
||||
if (this->state_->get_traits().supports_speed()) {
|
||||
root["speed_level_command_topic"] = this->get_speed_level_command_topic();
|
||||
root["speed_level_state_topic"] = this->get_speed_level_state_topic();
|
||||
root[MQTT_SPEED_COMMAND_TOPIC] = this->get_speed_command_topic();
|
||||
root[MQTT_SPEED_STATE_TOPIC] = this->get_speed_state_topic();
|
||||
root[MQTT_PERCENTAGE_COMMAND_TOPIC] = this->get_speed_level_command_topic();
|
||||
root[MQTT_PERCENTAGE_STATE_TOPIC] = this->get_speed_level_state_topic();
|
||||
}
|
||||
}
|
||||
bool MQTTFanComponent::publish_state() {
|
||||
@@ -148,31 +132,6 @@ bool MQTTFanComponent::publish_state() {
|
||||
bool success = this->publish(this->get_speed_level_state_topic(), payload);
|
||||
failed = failed || !success;
|
||||
}
|
||||
if (traits.supports_speed()) {
|
||||
const char *payload;
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
// NOLINTNEXTLINE(clang-diagnostic-deprecated-declarations)
|
||||
switch (fan::speed_level_to_enum(this->state_->speed, traits.supported_speed_count())) {
|
||||
case FAN_SPEED_LOW: { // NOLINT(clang-diagnostic-deprecated-declarations)
|
||||
payload = "low";
|
||||
break;
|
||||
}
|
||||
case FAN_SPEED_MEDIUM: { // NOLINT(clang-diagnostic-deprecated-declarations)
|
||||
payload = "medium";
|
||||
break;
|
||||
}
|
||||
default:
|
||||
case FAN_SPEED_HIGH: { // NOLINT(clang-diagnostic-deprecated-declarations)
|
||||
payload = "high";
|
||||
break;
|
||||
}
|
||||
}
|
||||
#pragma GCC diagnostic pop
|
||||
bool success = this->publish(this->get_speed_state_topic(), payload);
|
||||
failed = failed || !success;
|
||||
}
|
||||
|
||||
return !failed;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user